Google Gemini API adapter.
Handles the wire format for the /v1beta/models/{model}:streamGenerateContent endpoint.
Capabilities
- Streaming via SSE
- Tool/function calling with
functionCallandfunctionResponse - Extended thinking via
thinkingConfigwiththinkingBudget - 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 partsdata: {"usageMetadata": ...}— token usage (no content)