OpenAI to Gemini API Request Converter
Paste an OpenAI Chat Completions request and get the equivalent Google Gemini generateContent request — endpoint, headers and body remapped field by field — as ready-to-run cURL, Python or Node/TS. Works both ways. Runs entirely in your browser: no key, no upload, no signup.
How it works
The converter is a deterministic transformation of a published request schema — there is no model call. It reads your OpenAI Chat Completions request, applies a fixed set of mapping rules transcribed from the official OpenAI and Google Gemini API references, and emits the equivalent Gemini generateContent request. Every rule is a static table entry, so the same input always produces the same output, and the result is testable.
- Endpoint.
POST /v1/chat/completionsonapi.openai.combecomesPOST /v1beta/models/{model}:generateContentongenerativelanguage.googleapis.com. Whenstream:trueit switches to:streamGenerateContent?alt=sse. The model goes in the URL path, not the body. - Auth header.
Authorization: Bearer …becomesx-goog-api-key: …(or a?key=query parameter — your choice in the tool). - System prompt. Gemini has no in-array system role. Every
role:"system"turn is pulled out of the messages array and concatenated into the top-levelsystemInstruction.parts[].text. - messages → contents. Turns keep their order.
role:"assistant"becomesrole:"model";userstaysuser. A stringcontentbecomesparts:[{text}]. - Sampling → generationConfig.
max_tokens→maxOutputTokens,top_p→topP,n→candidateCount,stop→stopSequences.temperaturepasses through — both APIs accept 0.0–2 on current models. - JSON mode.
response_format:{type:"json_object"}→generationConfig.responseMimeType:"application/json"; ajson_schemaalso fillsgenerationConfig.responseSchema. - tools & tool_choice.
tools[].function.{name,description,parameters}is unwrapped intotools[].functionDeclarations[].tool_choicemaps totoolConfig.functionCallingConfig.mode:"auto"→AUTO,"required"→ANY,"none"→NONE, a named function →ANYplusallowedFunctionNames. - No equivalent.
logit_bias,user,store,metadata,service_tier,logprobsandtop_logprobshave no Gemini field — each is dropped and noted rather than silently mis-converted.
As a credibility check, three worked conversions ship as fixtures and are reconciled against the references on every load, and the converter is verified by a round-trip invariant: converting OpenAI → Gemini → OpenAI must recover the same system content, stop sequences and tool definitions. Two independent code paths agreeing is the guarantee that the rename rules are inverse. If you prefer a near drop-in migration, the tool also surfaces Gemini's OpenAI-compatible base URL (https://generativelanguage.googleapis.com/v1beta/openai/) with its trade-offs.
Worked examples
Frequently asked questions
Sources & references
- OpenAI API Reference — Chat Completions
- Google Gemini API — generateContent reference
- Google Gemini API — OpenAI compatibility layer
The mapping rules, the Gemini endpoint shape and the 2 temperature ceiling were last cross-checked against the official references on 2026-07-08. This page is reviewed whenever either provider ships a breaking request-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 parameter that maps wrong, or want another provider added?
Email me at [email protected] — most fixes ship within 24 hours.