SuperPi.AI.GeminiClient (super_pi v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

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

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

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

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.

Functions

api_key()

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

build_gemini_body(payload)

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(payload, opts \\ [])

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.