Multi-Model Protocol Layer
Modern generative AI applications rarely depend on a single model vendor. As teams benchmark latency, quality, and cost across providers, switching from OpenAI's Chat Completions API to Anthropic's Messages API or Google's Gemini REST API often reveals subtle schema incompatibilities. The LLM API Request Converter provides a client-side AST engine that parses requests into a neutral representation and emits clean payloads matching the official specification for each provider.
How to Convert API Payloads
- Paste your Source JSON: Paste an OpenAI
chat/completions, Anthropic/v1/messages, or Google GeminigenerateContentpayload into the left editor. - Select Target Format: Choose your target provider from the dropdown. The engine detects the input dialect automatically or accepts manual selection.
- Review Warnings & Export: Inspect any lossy warnings (such as unsupported frequency penalties or role merges) and export converted JSON or copy cURL, Node.js fetch, or Python code.
Format Differences At A Glance
OpenAI Chat Format
/v1/chat/completions
Encapsulates all roles (system, developer, user, assistant, tool) inside a single ordered messages array. Function tools are declared with parameters.
Anthropic Claude
/v1/messages
Requires max_tokens as a mandatory integer. System instructions must live in a top-level string system parameter, not in the messages list. Alternating turn constraints are strictly enforced.
Google Gemini
generateContent
Uses contents where turns contain parts: [{ text: "..." }] and roles are user or model. System prompts live under systemInstruction, and hyper-parameters are under generationConfig.
Common Lossy Mappings & Gotchas
- Penalty Parameters: Claude does not support
frequency_penaltyorpresence_penalty. These properties are safely omitted with clear warning badges. - Consecutive Turns: Claude rejects consecutive turns with the same role. The engine automatically merges adjacent same-role messages into coherent blocks.
- Tool Schema Declarations: Gemini wraps tools under
functionDeclarations, Anthropic requiresinput_schema, while OpenAI specifiesparameters.
Frequently Asked Questions
How do I switch from OpenAI to Claude in code?
Extract any system messages from your messages array into Anthropic's top-level system parameter, ensure max_tokens is explicitly specified, format multi-modal content parts with image source objects, and point your client endpoint to /v1/messages.
What differs between OpenAI, Claude, and Gemini formats?
The major differences include role naming (assistant vs model), system prompt placement (messages array vs root field vs systemInstruction), function/tool declarations (parameters vs input_schema vs functionDeclarations), and multi-turn turn alternating rules.
Why is the model name not blindly translated?
Models feature distinct context windows, capabilities, and pricing. When converting from GPT-4o, the tool sets industry equivalents like claude-3-5-sonnet-20241022 or gemini-1.5-pro, but keeps the field editable so you maintain complete control.
Is my request or API key uploaded to any server?
Never. Parsing, AST transformation, and diff analysis execute in-memory inside your local web browser engine. You can inspect your browser's Network tab or run this utility offline with zero network requests dispatched.
Can I convert tool/function calling schemas?
Yes. Toggle to the 'Tools only' tab or include tools within your input payload. The converter maps JSON Schema objects to Claude's tool array or Gemini's function declarations seamlessly.
Related Free Tools Built by MafLabs
- Extract Files from AI Reply — Split ChatGPT and Claude code responses into downloadable files.
- Codebase to Prompt — Pack local project repositories for LLM context windows.
- Hidden Text Detector — Uncover zero-font, invisible text and prompt injection in DOCX and HTML.