LLM.Adapter.Gemini (LLM v0.1.2)

Copy Markdown View Source

Google Gemini API adapter.

Handles the wire format for the /v1beta/models/{model}:streamGenerateContent endpoint.

Capabilities

  • Streaming via SSE
  • Tool/function calling with functionCall and functionResponse
  • Extended thinking via thinkingConfig with thinkingBudget
  • Model listing via /v1beta/models

Request format

Uses Gemini's contents array with parts:

  • Text: %{"text" => "..."}
  • Tool call: %{"functionCall" => %{"name" => ..., "args" => ...}}
  • Tool result: %{"functionResponse" => %{"name" => ..., "response" => ...}}

System instructions are sent as a top-level systemInstruction field.

SSE events

  • data: {"candidates": [{"content": {"parts": [...]}}]} — text, thinking, or tool call parts
  • data: {"usageMetadata": ...} — token usage (no content)