Claude to Gemini API Request Converter
Paste an Anthropic (Claude) Messages 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 two published request schemas — there is no model call. It reads your Anthropic Messages request, applies a fixed set of mapping rules transcribed from the official Anthropic 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/messagesonapi.anthropic.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 headers.
x-api-key+anthropic-version: 2023-06-01become a singlex-goog-api-keyheader (or a?key=query parameter — your choice in the tool). - System prompt. Claude's top-level
system(a string or an array of text blocks) is hoisted into Gemini'ssystemInstruction.parts[].text, because Gemini has no in-array system role. - messages → contents. Turns keep their order.
role:"assistant"becomesrole:"model";userstaysuser. A stringcontentbecomesparts:[{text}]; animagebase64 block becomesinlineData{mimeType,data}. - Sampling → generationConfig.
max_tokens→maxOutputTokens,top_p→topP,top_k→topK,stop_sequences→stopSequences.temperaturepasses through, but note Claude caps it at 1 while Gemini allows up to 2, so the reverse direction clamps any value above 1. - Extended thinking.
thinking:{type:"enabled",budget_tokens}maps togenerationConfig.thinkingConfig.thinkingBudget. - tools & tool_choice. Anthropic's
tools[].{name,description,input_schema}is wrapped intotools[].functionDeclarations[](input_schema→parameters).tool_choicemaps totoolConfig.functionCallingConfig.mode:{type:auto}→AUTO,{type:any}→ANY,{type:none}→NONE, and{type:tool,name}→ANYplusallowedFunctionNames. - Required max_tokens gotcha. Anthropic requires
max_tokens. When converting Gemini → Claude and the source has nomaxOutputTokens, the tool injectsmax_tokens: 1024and flags it so Anthropic will not reject the request. - No equivalent.
metadata.user_id,cache_controlandservice_tierhave no Gemini field; going the other way,safetySettings,cachedContent,candidateCountandresponseMimeType/responseSchemahave no Anthropic 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 Claude → Gemini → Claude must recover the same system content, max_tokens, stop sequences and tool definitions. Two independent code paths agreeing is the guarantee that the rename rules are inverse.
Worked examples
Frequently asked questions
Sources & references
- Anthropic — Messages API reference
- Google Gemini API — generateContent reference
- Google Gemini API — function calling
The mapping rules, the Gemini endpoint shape and the 1/2 temperature ceilings were last cross-checked against the official references on 2026-07-12. 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.