Expand description
The Google Gemini adapter (DW-075).
Speaks the Gemini generateContent API
(POST /v1beta/models/{model}:generateContent โ note the model
rides in the PATH, not the body, which is why
ProviderAdapter::build_request takes the provider model
explicitly). Translation notes:
- System messages lift to
systemInstruction. - Roles are
user/modelonly; OpenAItoolresults become user turns carrying afunctionResponsepart. Gemini requires the FUNCTION NAME there, while the OpenAI shape carries only the call id โ the adapter resolves the name by scanning backward through the conversation for the assistanttool_callsentry with that id, and falls back to the id itself when the history does not contain it (a client that invented a tool_call_id out of thin air). - Tool declarations become
functionDeclarations; the JSON-Schemaparametersobject is passed through minus$schema(which Gemini rejects). data:URI images becomeinline_dataparts; remote image URLs have no Gemini equivalent in this API and are DROPPED (documented limitation of the translation, not a silent corruption โ the alternative, fetching the URL, is a side effect a gateway must not invent).- Finish reasons map
STOP-> stop,MAX_TOKENS-> length,SAFETY/PROHIBITED_CONTENT-> content filter,RECITATION-> other. Usage mapspromptTokenCount/candidatesTokenCount. - Streaming uses
:streamGenerateContent?alt=sse; each SSE data payload is aGenerateContentResponsetranslated like a single-choice fragment.
Structsยง
- Gemini
Adapter - The Gemini generateContent adapter. Stateless singleton.