# `SuperPi.AI.GeminiClient`
[🔗](https://github.com/oleksandr/super-pi-beam/blob/v0.1.0/lib/super_pi/ai/gemini_client.ex#L1)

Direct Google Generative AI (Gemini) client with SSE streaming, tool-calling schemas,
and cross-provider model normalization (`spec.md` §3).

Communicates via `Req` using Gemini's official `streamGenerateContent?alt=sse` endpoint:
- Model defaults to `gemini-3-flash-preview` or `gemini-2.5-flash`.
- Normalizes tool declarations from OpenAI/JSON-schema into Gemini function declaration specs.
- Automatically translates tool calls and results between SuperPi standard messages and Gemini `parts`.

# `api_key`

Returns the active Google Gemini API key from system environment or config.

# `build_gemini_body`

Translates a `SuperPi` provider payload (`messages`, `system_sections`, `tools`) into the
Google Gemini `generateContent` JSON structure.

# `configured?`

Returns true if a valid Gemini API key is configured and not running under mock LLM mode.

# `generate`

Streams a generation request to the live Gemini API (`streamGenerateContent?alt=sse`),
normalizing SSE chunks through `SuperPi.AI.StreamNormalizer`, and optionally invokes
`on_delta.(event)` as tokens stream in.

---

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