Gemini to OpenAI API Converter
Paste a Google Gemini generateContent request or response and get the equivalent OpenAI Chat Completions JSON — systemInstruction, functionCall, finishReason and usageMetadata mapped field by field. Runs entirely in your browser: no key, no upload, no signup.
How it works
The converter is a deterministic transformation of a published schema — there is no model call. It reads your Gemini generateContent payload, applies a fixed set of rules transcribed from the official Google and OpenAI API references, and emits the equivalent OpenAI Chat Completions JSON. Every rule is a static mapping, so the same input always produces the same output, and two worked examples are reconciled field-by-field on every load.
Requests are rebuilt turn by turn:
- System prompt. The top-level
systemInstruction.parts[].textis hoisted into a leading{role:"system"}message — OpenAI has no separate instruction field. - contents → messages. Order is preserved.
role:"model"becomesassistant;userstaysuser. Text parts become acontentstring, or a{type:"text"}/{type:"image_url"}content-part array when aninlineDatapart is present (encoded as adata:URL). - functionCall → tool_calls. A model
functionCall{name,args}becomes an assistanttool_callsentry. Theargsobject is JSON-stringified intoarguments. Gemini calls carry no id, so a stablecall_0,call_1… is synthesized in order. - functionResponse → tool message. A user-turn
functionResponse{name,response}becomes a separate{role:"tool",tool_call_id,content}message, linked back to the matching synthesized call id by name and order. - tools & toolConfig.
tools[].functionDeclarations[]is unwrapped intotools[].function(upper-caseTypeenums likeSTRINGare lower-cased to JSON Schema).functionCallingConfig.mode:AUTO→"auto",ANY→"required"(or a named function),NONE→"none". - generationConfig.
maxOutputTokens→max_tokens(ormax_completion_tokensper the toggle),topP→top_p,stopSequences→stop,candidateCount→n(flagged), andresponseMimeType/responseSchema→response_format.
Responses wrap candidates[] into a chat.completion object: each candidate becomes a choice{index,message,finish_reason}, part text becomes message.content, and finishReason maps to finish_reason (STOP→stop, MAX_TOKENS→length, SAFETY/RECITATION→content_filter; forced tool_calls when calls are present). usageMetadata maps to usage — promptTokenCount→prompt_tokens, candidatesTokenCount→completion_tokens, totalTokenCount→total_tokens. Fields with no clean target — topK, safetySettings, thinking parts, extra candidates — are listed in the notes panel, never silently dropped.
Worked examples
Frequently asked questions
Sources & references
- Google Gemini API — generateContent reference
- Google Gemini API — function calling (functionCall, functionResponse, functionCallingConfig)
- OpenAI API Reference — Chat Completions
The mapping rules were last cross-checked against the official Gemini and OpenAI references on 2026-07-12. This page is reviewed whenever either provider ships a breaking request- or response-schema change.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a field that maps wrong, or want another provider pair added?
Email me at [email protected] — most fixes ship within 24 hours.