LlmCall.Dialect.Gemini.GenerateContent (llm_call v0.1.0)

Copy Markdown View Source

Gemini generateContent / streamGenerateContent (v1beta).

Messages become contents, where an assistant turn is role: "model". System instructions are a top-level systemInstruction, sampling and output controls live in generationConfig, and reasoning maps to thinkingConfig.

Gemini identifies a tool result by function name, not by a call id, so LlmCall.ToolResult.call_id is not represented on this protocol. A request without a function name on the result is rejected.

Streaming changes the method in the path (:streamGenerateContent) and adds alt=sse to the query; the transport still owns SSE framing.

provider_options accepts :gemini and its :google alias. The alias is collapsed per source before merging, so a request value wins over a config default even when the two use different names, and nested native objects are deep-merged (a request can extend a defaulted generationConfig).

finishReason maps into the canonical union: CONTINUATION is a resumable token-limit stop, so it reads as :max_tokens; the content-policy reasons (the safety, recitation, blocklist, language, image-safety, and escalation family) read as :content_filter; and the reasons that mean the generation failed (MALFORMED_FUNCTION_CALL, UNEXPECTED_TOOL_CALL, TOO_MANY_TOOL_CALLS, MISSING_THOUGHT_SIGNATURE, MALFORMED_RESPONSE, NO_IMAGE, IMAGE_OTHER, PUP_LIMITED_DISABLED) read as :error. The candidate's continuationToken has no canonical field and stays in Response.raw.