SDK Guide · As of 2026-11-25

Anthropic Messages API vs OpenAI Chat Completions vs Responses API: A Field-by-Field Comparison

As of 2026-11-25, nearly every AI coding tool talks to models through one of three wire protocols: Anthropic's Messages API (/v1/messages), OpenAI's Chat Completions (/v1/chat/completions) and OpenAI's Responses API (/v1/responses). All three can chat, call tools and stream, but they differ in request shape, where the system prompt goes, how tool calls round-trip, which streaming events you parse, how caching works and how reasoning is configured. Claude Code speaks Messages, Codex CLI speaks Responses, and the "OpenAI-compatible" mode in tools like Cursor and Cline is Chat Completions. On QCode the protocol is picked by the request path: /api for Anthropic, /openai/v1 for OpenAI.

QCode is an independent third-party API service. It is not affiliated with Anthropic, OpenAI or any model vendor. Protocol details below follow each vendor's official documentation as checked on 2026-11-25.

Updated 2026-11-26

Key facts

  • Three protocols, three paths: POST /v1/messages, POST /v1/chat/completions, POST /v1/responses.
  • The system prompt lives in different places: a top-level system field (Messages), a system/developer message inside messages (Chat Completions), or top-level instructions / a first developer item (Responses).
  • Tool schemas have different shapes: input_schema (Messages), nested under function (Chat Completions), flattened name + parameters (Responses).
  • Streaming is not interchangeable: named SSE events from message_start to message_stop (Messages), delta chunks ending in data: [DONE] (Chat Completions), typed semantic events such as response.output_text.delta (Responses).
  • Caching: explicit cache_control breakpoints on Anthropic; automatic prefix caching on both OpenAI APIs.
  • QCode routing rule: Claude models only on the Anthropic path, GPT models only on OpenAI paths (Chat and Responses), Chinese models (GLM, Kimi, DeepSeek, Qwen, MiniMax) on the Anthropic and OpenAI endpoints. Whether the Responses protocol serves them is not documented as of 2026-11-26; test a small request if you need it.

The comparison table

Dimension Anthropic Messages OpenAI Chat Completions OpenAI Responses
Endpoint POST /v1/messages POST /v1/chat/completions POST /v1/responses
Full QCode URL https://api.qcode.cc/api/v1/messages https://api.qcode.cc/openai/v1/chat/completions https://api.qcode.cc/openai/v1/responses
Auth headers x-api-key or Authorization: Bearer, plus anthropic-version Authorization: Bearer Authorization: Bearer
Input messages (user/assistant only) + top-level system messages (system, developer, user, assistant, tool) input (string or item list) + instructions
Output content blocks (text, thinking, tool_use) + stop_reason choices[].message + finish_reason output items (message, reasoning, function_call); SDK output_text helper
Output cap max_tokens (required) max_completion_tokens max_output_tokens
Tool definition {name, description, input_schema} {type:"function", function:{name, parameters}} {type:"function", name, parameters}
Tool call → result tool_use block → tool_result in a user message (tool_use_id) tool_calls[] → role:"tool" message (tool_call_id) function_call item → function_call_output item (call_id)
Streaming Named SSE events, plus ping and error data: chunks + data: [DONE] Typed response.* events
Caching Explicit cache_control; cache_read_input_tokens in usage Automatic; usage.prompt_tokens_details.cached_tokens Automatic; usage.input_tokens_details.cached_tokens
Reasoning thinking: {type:"adaptive"} + output_config.effort (Opus 5.5) reasoning_effort reasoning: {effort}, returns reasoning items
State Stateless; resend full history Stateless Stored by default; chain with previous_response_id

The sections below go through each row.

Request shape and the system prompt

Anthropic Messages puts the system prompt in a top-level system field. The messages array only contains alternating user and assistant turns, and each content can be a string or an array of content blocks (text, images, documents, tool results). max_tokens is required, and every request must carry an anthropic-version header; 2023-06-01 is the long-standing value. Anthropic released a newer version, 2026-10-21, which removes temperature, top_p and top_k; sending any of them returns HTTP 400 under that version (see our Claude API 2026-10-21 notes). Whether QCode passes the new version and beta headers through is not documented as of 2026-11-26 — if you rely on them, test with a small request first.

OpenAI Chat Completions has a single messages array. System instructions are a system message (newer models favor developer), and tool results come back as role: "tool" messages. The answer is at choices[0].message.content.

OpenAI Responses replaces messages with input, which can be a plain string or a list of items. One-off guidance goes in top-level instructions. The result is a typed output array, and the SDKs add an output_text convenience field. OpenAI's migration guide says Chat Completions remains supported, but Responses is recommended for new projects.

Here is the same "run my tests" request in all three protocols, pointed at QCode ($KEY is your cr_ key):

# 1) Anthropic Messages — the only path for Claude models
curl https://api.qcode.cc/api/v1/messages \
  -H "x-api-key: $KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "system": "You are a concise code-review assistant.",
    "tools": [{
      "name": "run_tests",
      "description": "Run the project unit tests",
      "input_schema": {"type": "object", "properties": {"path": {"type": "string"}}, "required": ["path"]}
    }],
    "messages": [{"role": "user", "content": "Run the tests in tests/"}]
  }'

# 2) OpenAI Chat Completions — GPT and Chinese models
curl https://api.qcode.cc/openai/v1/chat/completions \
  -H "Authorization: Bearer $KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "gpt-6.2-sol",
    "messages": [
      {"role": "developer", "content": "You are a concise code-review assistant."},
      {"role": "user", "content": "Run the tests in tests/"}
    ],
    "tools": [{
      "type": "function",
      "function": {"name": "run_tests", "description": "Run the project unit tests",
        "parameters": {"type": "object", "properties": {"path": {"type": "string"}}, "required": ["path"]}}
    }]
  }'

# 3) OpenAI Responses — the protocol Codex CLI uses
curl https://api.qcode.cc/openai/v1/responses \
  -H "Authorization: Bearer $KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "gpt-6.2-sol",
    "instructions": "You are a concise code-review assistant.",
    "input": "Run the tests in tests/",
    "tools": [{
      "type": "function", "name": "run_tests", "description": "Run the project unit tests",
      "parameters": {"type": "object", "properties": {"path": {"type": "string"}}, "required": ["path"]}
    }]
  }'

Tool calling: three ways to send results back

Tool use is where the protocols differ most, and where hand-written adapters break.

  • Messages: the model stops with stop_reason: "tool_use" and returns a tool_use block with an id, a name and an already-parsed input object. You run the tool and send a tool_result block in the next user message, matched by tool_use_id. From Opus 5.5 on, tool_choice values any and tool return HTTP 400; Anthropic recommends auto plus strict: true on the tool.
  • Chat Completions: message.tool_calls[] holds function.arguments as a JSON string you must parse yourself. Results go back as role: "tool" messages with tool_call_id. Strict mode is off by default.
  • Responses: the call and its result are separate items, function_call (with call_id) and function_call_output (which must carry the same call_id). If you omit strict, Responses tries strict mode and falls back to non-strict, returning strict: false, when the schema is incompatible.

If you maintain a multi-provider wrapper, the most common conversion is the tool definition itself. Two small Python helpers that turn a Chat Completions tool into the other two shapes:

def chat_tool_to_anthropic(t: dict) -> dict:
    f = t["function"]
    return {"name": f["name"], "description": f.get("description", ""),
            "input_schema": f.get("parameters", {"type": "object", "properties": {}})}

def chat_tool_to_responses(t: dict) -> dict:
    f = t["function"]
    out = {"type": "function", "name": f["name"],
           "description": f.get("description", ""), "parameters": f.get("parameters", {})}
    if "strict" in f:
        out["strict"] = f["strict"]
    return out

Streaming: different event models

Messages streaming sends named events in a fixed order: message_start, then for each content block content_block_start, any number of content_block_delta events and content_block_stop, then message_delta and finally message_stop. Delta types are text_delta, input_json_delta (partial JSON for tool input), thinking_delta and signature_delta. ping events can appear anywhere, and an error event (for example overloaded_error, the streaming twin of HTTP 529) can arrive mid-stream. Usage in message_delta is cumulative. Anthropic warns that new event types may be added, so ignore unknown ones instead of crashing.

event: message_start
data: {"type":"message_start","message":{"id":"msg_...","content":[],"usage":{"input_tokens":25,"output_tokens":1}}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Sure"}}

event: message_stop
data: {"type":"message_stop"}

Chat Completions streaming is just data: lines, each a chat.completion.chunk with content in choices[0].delta, terminated by data: [DONE].

Responses streaming emits typed semantic events you branch on by type: response.created, response.output_text.delta, response.function_call_arguments.delta / .done, response.completed, error and others.

One Opus 5.5 gotcha: thinking defaults to display: "omitted", and the narration between tool calls now arrives inside thinking blocks rather than text blocks. A UI that only renders text_delta goes quiet between tool calls without any error. Select blocks by type and set the display option if you want that text.

Prompt caching: explicit breakpoints vs automatic prefixes

  • Anthropic: mark breakpoints with cache_control: {"type": "ephemeral"} on system, tools or message content blocks. The default lifetime is 5 minutes, with a 1-hour option. Usage reports cache_creation_input_tokens (writes) and cache_read_input_tokens (hits). For Opus 5.5 the minimum cacheable prompt is 512 tokens and a cache read costs $0.20 per million tokens (per Anthropic, Nov 2026). Opus 5.5 also expects append-only conversations: editing an earlier system prompt, tool list or message breaks the prefix and with it the cache and thinking blocks.
  • OpenAI: both APIs cache automatically. Per OpenAI's docs, GPT-5.6 and later need a prefix of at least 1,024 visible tokens; prompt_cache_key is mainly for separating cache accounting; prompt_cache_options.ttl accepts "30m" (default) or "12h", the latter only on the Responses API. Hits show up in usage.prompt_tokens_details.cached_tokens (Chat Completions) or usage.input_tokens_details.cached_tokens (Responses).

On QCode, Anthropic and OpenAI models are billed at the official API price ×1.0, so cache reads follow the vendor's cache price (for example, Sonnet 5.5 cache reads are $0.10 per million tokens per Anthropic's November 2026 pricing). Live rates are on /models. For GPT-6.2 specifics see our GPT-6.2 Sol Responses API tool-calling and caching guide.

Reasoning parameters

  • Anthropic (Opus 5.5): thinking is always on. Send "thinking": {"type": "adaptive"} (or omit it) and control depth with "output_config": {"effort": "high"}; the default effort is medium. {"type": "disabled"} or a manual budget_tokens returns 400. Pass thinking blocks back unmodified in tool loops.
  • Chat Completions: a top-level reasoning_effort. Reasoning tokens count as output.
  • Responses: "reasoning": {"effort": "..."}, which returns reasoning items. With store: false or zero data retention, replay every returned reasoning item (they carry encrypted_content by default).

Conversation state

Messages and Chat Completions are stateless: you resend the whole transcript each turn. Responses stores responses by default, so you can chain turns with previous_response_id, append the previous output items to your next input yourself, or use the Conversations API. Prior input tokens in a chain are still billed as input. Set store: false if you don't want server-side storage. On QCode, whether previous_response_id, server-side storage and the Conversations API pass through is not documented as of 2026-11-26; if you rely on them, test with a small request first.

Which tools speak which protocol

Based on QCode's per-tool setup pages, checked 2026-11-25. For Codex CLI, the Codex setup page documents wire_api = "responses" as the supported value:

Tool Protocol QCode setting
Claude Code Anthropic Messages ANTHROPIC_BASE_URL=https://api.qcode.cc/api
Claude Agent SDK Anthropic Messages base_url=https://api.qcode.cc/api
Codex CLI OpenAI Responses base_url = "https://api.qcode.cc/openai", wire_api = "responses"
Cursor Messages via the Anthropic override; Chat Completions via the OpenAI override /api and /openai/v1 respectively
Cline Anthropic provider (Messages) / OpenAI Compatible (Chat Completions) /api or /openai/v1
Kilo Code Messages, OpenAI-compatible, Responses per provider
GitHub Copilot custom endpoint all three per provider
Cherry Studio OpenAI, Anthropic, Responses per provider
Open WebUI Chat Completions only /openai/v1
OpenAI SDK, LangChain and generic clients Chat Completions by default base_url=https://api.qcode.cc/openai/v1

The Codex config (~/.codex/config.toml):

model_provider = "qcode"
model = "gpt-6.2-sol"

[model_providers.qcode]
name = "qcode"
base_url = "https://api.qcode.cc/openai"   # no /v1; Codex appends /responses itself
wire_api = "responses"
requires_openai_auth = true

Full walkthroughs: Codex CLI third-party API setup and the ANTHROPIC_BASE_URL setup guide.

QCode path rules and common mistakes

One QCode key serves both protocol families, and the path decides the protocol:

  • Claude models (opus, sonnet, haiku, fable) only work on the Anthropic path /api/v1/messages. Sending a Claude model to the OpenAI Chat path returns model_not_available_on_endpoint, and that check runs before authentication.
  • GPT models such as gpt-6.2-sol and gpt-6.2-astra use OpenAI Chat or Responses, never the Anthropic path.
  • Chinese models (GLM, Kimi, DeepSeek, Qwen, MiniMax) work on the Anthropic and OpenAI endpoints. Whether /openai/v1/responses serves them is not documented as of 2026-11-26; test a small request first if you need the Responses protocol.
  • /api and /openai/v1 are path prefixes; SDKs append the rest. Requesting a bare prefix returns an HTML page with HTTP 200, which proves nothing.
  • No trailing slash on base URLs. It produces //v1/messages and a 404.

Quick self-test: POST with your key and no body. A 400 means path and key are fine; 401 is a key problem; 404 is a wrong prefix; 402 with a *_cost_limit_exceeded code means the quota is used up.

curl -s -o /dev/null -w '%{http_code}\n' -X POST https://api.qcode.cc/api/v1/messages -H "Authorization: Bearer $KEY"
curl -s -o /dev/null -w '%{http_code}\n' -X POST https://api.qcode.cc/openai/v1/chat/completions -H "Authorization: Bearer $KEY"
curl -s -o /dev/null -w '%{http_code}\n' -X POST https://api.qcode.cc/openai/v1/responses -H "Authorization: Bearer $KEY"

If Cline returns 400 on the Anthropic provider, see Cline Anthropic base URL 400 fix.

Which one should you use?

  • Mostly Claude for coding: use Messages. Thinking blocks, cache_control and strict tools are only fully available on the native protocol, and QCode serves Claude only on the Anthropic path.
  • Mostly GPT, new project: start with Responses. Typed events and call_id fit multi-step agents, and Codex CLI depends on it.
  • Lots of existing Chat Completions code, or Chinese models: stay on Chat Completions to avoid a rewrite. GLM, Kimi, DeepSeek and Qwen all work there.
  • One app using both Claude and GPT: keep one QCode key, choose the path per model, and add a thin adapter for tools and messages. No second account or second bill.

FAQ

Can I call Claude models with the OpenAI SDK?

Not on QCode. Claude models are only exposed on the Anthropic Messages path; sending one to /openai/v1/chat/completions returns model_not_available_on_endpoint. Use the Anthropic SDK, or pick your tool's Anthropic provider with https://api.qcode.cc/api.

Is Chat Completions being deprecated?

As of 2026-11-25, OpenAI says Chat Completions remains supported and recommends Responses for new projects. You can migrate existing flows gradually rather than all at once.

Why does Codex CLI need wire_api = "responses" ?

Codex talks to models over the Responses protocol, and QCode's Codex page lists responses as the only value. Set base_url to https://api.qcode.cc/openai without /v1; Codex requests /openai/responses itself.

Should Chinese models use the Anthropic or the OpenAI protocol?

Both the Anthropic and OpenAI endpoints work on QCode, so use whichever your tool supports natively: Anthropic in Claude Code, OpenAI Chat in Open WebUI. Chinese models are billed at the rate shown on /models.

How do I enable prompt caching on each protocol?

Anthropic needs explicit cache_control breakpoints. OpenAI's Chat Completions and Responses cache automatically. On all three, keeping the prefix stable (system prompt, tool list and early messages unchanged) is what drives the hit rate.

Which anthropic-version should I send?

2023-06-01 is the long-standing value. Anthropic's newer 2026-10-21 rejects temperature, top_p and top_k; remove those parameters before switching. QCode's pass-through of the new version and beta headers is not documented as of 2026-11-26, so test with a small request first.

Why does my streaming UI go silent between Opus 5.5 tool calls?

Opus 5.5 puts the narration between tool calls into thinking blocks, which are omitted by default. Handle events by content-block type and set the thinking display option described in Anthropic's docs.

Why does a trailing slash on the base URL cause a 404?

SDKs append paths like /v1/messages. A trailing slash turns that into //v1/messages, which the server does not match. Remove the slash.

Try all three protocols on the trial plan

To compare the protocols inside your own toolchain, start with the QCode Starter plan at $9 per month (see /pricing), with a $5 daily quota. The same key works on the Anthropic and OpenAI protocols. Anthropic and OpenAI models are billed at the official API price ×1.0; per-model rates are on /models. For occasional tests, the packs on /pay-as-you-go need no subscription.

Try all three protocols on the trial plan

One key for both the Anthropic Messages API and OpenAI-compatible APIs. Claude and GPT are billed at the official price ×1.0; live rates are on /models.

Not sure where to start?

Try it for a week

Small Pack: $4 for $30 of quota, valid 7 days

Use it every day

Starter: $9.00/month with $5 of quota every day — just $0.060 per $1 of quota, vs about $0.113 for the Medium Pack