induwara.lk
induwara.lkDeveloper · AI

OpenAI to Anthropic (Claude) API Converter

Paste an OpenAI Chat Completions request and get the equivalent Anthropic Messages API 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.

By Induwara AshinsanaUpdated Jun 30, 2026
Convert a OpenAI requestto Anthropic
Direction

Paste a OpenAI Chat Completions request body. It is parsed in your browser — nothing is uploaded.

We suggest a tier; you confirm the model. We never claim behavioural parity.

Output language
Endpoint
/v1/messages
Fields mapped
4
Dropped / manual
0 / 0
Auth header
x-api-key

Request headers (Anthropic)

x-api-key: $ANTHROPIC_API_KEY
anthropic-version: 2023-06-01
content-type: application/json
cURL — ready to run
curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "system": "You are a helpful assistant.",
    "messages": [
      {
        "role": "user",
        "content": "Hello"
      }
    ],
    "max_tokens": 1024,
    "temperature": 0.7
  }'
Converted Anthropic request body
{
  "model": "claude-sonnet-4-6",
  "system": "You are a helpful assistant.",
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ],
  "max_tokens": 1024,
  "temperature": 0.7
}

Field-by-field mapping

FromToStatusDetail
model: gpt-4omodel: claude-sonnet-4-6MappedSuggested tier: claude-sonnet-4-6 — confirm before shipping.
1 system messagesystem (top-level string)RenamedExtracted from messages and concatenated into the top-level system field.
max_tokens: 1024max_tokens: 1024MappedCarried over unchanged.
temperature: 0.7temperature: 0.7MappedWithin Anthropic's 0–1 range; passed through.

Mapping follows the official OpenAI Chat Completions and Anthropic Messages references. The anthropic-version: 2023-06-01 header and the 0–1 temperature range are pinned and dated. Sources are listed below the tool.

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 Anthropic API references, and emits the equivalent Anthropic Messages request. Every rule is a static table entry, so the same input always produces the same output, and the result is testable.

  1. Endpoint. POST /v1/chat/completions on api.openai.com becomes POST /v1/messages on api.anthropic.com.
  2. Auth & version headers. Authorization: Bearer … becomes x-api-key: … plus the required anthropic-version: 2023-06-01 header.
  3. System prompt. Anthropic takes system as a top-level string. Every role:"system" turn is pulled out of the messages array and concatenated; the remaining user and assistant turns stay in messages, which must start with a user turn.
  4. max_tokens. Optional in OpenAI, required in Anthropic. If it is absent, the converter injects 1024 and flags it Required-now.
  5. temperature. OpenAI's range is 0.0–2; Anthropic's is 0.0–1. A value above 1 is clamped and flagged Range-changed. top_p shares the same 0–1 range and passes through.
  6. stop → stop_sequences. A string or array becomes an array. stream passes through unchanged.
  7. tools & tool_choice. tools[].function.{name,description,parameters} becomes tools[].{name,description,input_schema} — the JSON Schema object moves from function.parameters to input_schema. tool_choice values are remapped: "auto"→{type:auto}, "required"→{type:any}, {function:{name}}→{type:tool,name}.
  8. No equivalent. n, frequency_penalty, presence_penalty, logit_bias, logprobs and seed have no Anthropic field — each is dropped and noted. response_format (JSON mode) is flagged Manual with the recommended tool-use or prompt workaround.

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 → Anthropic → 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. Model IDs (for example claude-sonnet-4-6) are cross-checked against the in-repo AI model cheat sheet and the Anthropic models reference; the version header and temperature range are pinned and dated below.

Worked examples

A — simple chat (OpenAI → Anthropic)

  1. In: {"model":"gpt-4o","messages":[{"role":"system",
  2. "content":"You are a helpful assistant."},
  3. {"role":"user","content":"Hello"}],
  4. "temperature":0.7,"max_tokens":1024}
  5. Out: model → claude-sonnet-4-6
  6. system: "You are a helpful assistant." (lifted out of messages)
  7. messages: [{"role":"user","content":"Hello"}]
  8. temperature 0.7 ≤ 1.0 → passes through
  9. max_tokens 1024 already present → no injection
  10. Endpoint → /v1/messages; header → x-api-key + anthropic-version

B — function calling, no max_tokens (OpenAI → Anthropic)

  1. In: tools:[{"type":"function","function":{
  2. "name":"get_weather","description":"Get current weather",
  3. "parameters":{"type":"object",...}}}], tool_choice:"auto"
  4. Out: tools:[{"name":"get_weather","description":"Get current weather",
  5. "input_schema":{"type":"object",...}}] (parameters → input_schema)
  6. tool_choice: {"type":"auto"}
  7. max_tokens absent → injected 1024, flagged Required-now

C — temperature out of range (edge case)

  1. temperature 1.0 → passes through as 1.0 (boundary, NOT changed)
  2. temperature 1.5 → clamped to 1.0, flagged Range-changed
  3. temperature 2.0 → clamped to 1.0, flagged Range-changed
  4. Reverse (Anthropic → OpenAI): no clamp needed —
  5. OpenAI also accepts up to 2.0, so temperature passes through.

Frequently asked questions

Sources & references

The mapping rules, the anthropic-version: 2023-06-01 header and the 1 temperature ceiling were last cross-checked against the official references on 2026-06-30. This page is reviewed whenever either provider ships a breaking request-schema change.

Related tools

Rate this tool
Be the first to rate

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.