# `LlmCall.Dialect.Gemini.GenerateContent`
[🔗](https://github.com/gilbertwong96/llm_call/blob/main/lib/llm_call/dialect/gemini/generate_content.ex#L1)

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.

A media part is either inline (`inlineData`) or a reference Gemini resolves
itself (`fileData.fileUri`), and that reference is a `gs://` object or a Files API
URI — not a URL anyone can fetch. So `{:uri, uri}` is the source that reaches it,
an `https://` URL is refused with the shape that works, and `capabilities/2` declares
`:inline` and `:uri` for both images and files.

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

Tool `parameters` and `responseSchema` must already be in Gemini's OpenAPI
subset. The codec rejects a lowercase `type`, `additionalProperties`,
`$ref`/`$defs`, `prefixItems`, `oneOf` or `const` as a `:validation` error
rather than sending a request the provider would reject.

`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`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
