In November 2026, the Anthropic Messages API and OpenAI Chat Completions accept the same kind of conversation in different shapes. Messages puts instructions in a top-level system field, requires max_tokens and returns typed content blocks. Chat Completions puts instructions in a message, uses max_completion_tokens and returns choices. A gateway can translate between the formats, but you still need to check fields and features when porting an application.
Map the request and response fields
Anthropic's Messages API and OpenAI's Chat Completions API both take a conversation and return a model response. The differences show up in the fields your code reads and writes:
| What you need | Anthropic Messages | OpenAI Chat Completions |
|---|---|---|
| Endpoint | POST /v1/messages | POST /v1/chat/completions |
| Instructions | Top-level system parameter | A system or developer message |
| Output limit | Required max_tokens | max_completion_tokens |
| Response | content array of typed blocks | choices[].message |
| Stop status | stop_reason | choices[].finish_reason |
| Token usage | usage.input_tokens and usage.output_tokens | usage.prompt_tokens and usage.completion_tokens |
| Tool definition | Tool with an input_schema | Function tool with parameters |
| Tool call | tool_use content block | message.tool_calls |
| Tool result | tool_result block with tool_use_id | tool message with tool_call_id |
| Image input | image block with a base64 or URL source | image_url content part |
Start with the output limit. OpenAI's reference deprecates Chat Completions max_tokens in favor of max_completion_tokens, which includes visible output and reasoning tokens. Anthropic requires max_tokens on Messages requests.
Anthropic's OpenAI compatibility layer moves system and developer messages into the top-level system field, including messages that appear later in the conversation. Anthropic also documents that some models accept a system message after a user turn for mid-conversation instructions. Test the translated conversation if your application depends on where an instruction appears.
Stop statuses use different vocabularies as well. Anthropic documents end_turn, max_tokens, stop_sequence, tool_use, pause_turn and refusal; OpenAI documents stop, length, content_filter, tool_calls and the deprecated function_call. Check your branching logic against the response format your client receives, particularly for tool calls and refusals. See the Messages reference and the Chat Completions reference.
Run both formats through Requesty
The two Python examples below send the same prompt to the same provider-pinned Claude model. The first makes a Messages request over HTTP, and the second uses the OpenAI SDK for Chat Completions; both read the Requesty key from REQUESTY_API_KEY.
import os
import httpx
response = httpx.post(
"https://router.requesty.ai/v1/messages",
headers={
"x-api-key": os.environ["REQUESTY_API_KEY"],
"anthropic-version": "2023-06-01",
"content-type": "application/json",
},
json={
"model": "anthropic/claude-opus-5-5",
"max_tokens": 256,
"system": "Answer in one sentence.",
"messages": [
{"role": "user", "content": "What is a token in an LLM?"},
],
},
timeout=60,
)
response.raise_for_status()
for block in response.json()["content"]:
if block["type"] == "text":
print(block["text"])import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["REQUESTY_API_KEY"],
base_url="https://router.requesty.ai/v1",
)
response = client.chat.completions.create(
model="anthropic/claude-opus-5-5",
max_completion_tokens=256,
messages=[
{"role": "system", "content": "Answer in one sentence."},
{"role": "user", "content": "What is a token in an LLM?"},
],
)
print(response.choices[0].message.content)With the Anthropic SDK, use the same key and set base_url="https://router.requesty.ai"; the SDK calls /v1/messages for you. Requesty's Messages documentation shows the SDK configuration and says the gateway converts Messages requests for compatible non-Anthropic models.
The base URLs differ because of what each SDK expects. The Anthropic SDK is configured with the host and calls /v1/messages; the OpenAI SDK uses the /v1 base.
The model ID anthropic/claude-opus-5-5 pins the Anthropic provider. A bare claude-opus-5-5 ID uses a managed policy that combines several providers for the model.
For more on the OpenAI side of the connection, see our guide to OpenAI-compatible APIs. Our LLM gateway guide explains where a gateway sits between an application and model providers.
Tool calls need a return path
A tool call asks your application to run a function for the model. The application runs the function, then sends its result back in the conversation.
On Anthropic Messages, a tool definition carries an input_schema. Claude returns a tool_use block whose input is an object, and your application sends back a tool_result block with a tool_use_id matching the call's ID. When one turn contains several calls, return their results together in one user message, with the result blocks immediately after the tool use blocks in the history. See Anthropic's tool use overview and tool call handling guide.
Chat Completions puts the calls in message.tool_calls. Function arguments arrive as a JSON-formatted string, and the result goes back in a tool message with the matching tool_call_id, as shown in the OpenAI reference. Code that expects an object on one side must parse the string on the other.
Tool selection changes shape too:
| Behavior | Anthropic tool_choice | OpenAI tool_choice |
|---|---|---|
| Let the model choose | {"type":"auto"} | auto |
| Do not call a tool | {"type":"none"} | none |
| Require a tool call | {"type":"any"} | required |
| Force a named tool | {"type":"tool","name":"..."} | A named function object |
Sources: Anthropic tool choice and OpenAI Chat Completions.
Streaming has different events
Both APIs can stream over server-sent events. A client built for one event format still needs to handle the other.
Anthropic's named events include message_start, content_block_delta, message_delta and message_stop. Tool inputs arrive as content_block_delta events whose delta has type input_json_delta and a partial_json string. Concatenate the parts and parse them once the content block stops. The full event sequence is in Anthropic's streaming guide.
Chat Completions uses data-only events and finishes with data: [DONE]. When stream_options includes include_usage, a final chunk before [DONE] carries usage with an empty choices array. See OpenAI's Chat Completions reference.
Check what compatibility leaves out
Anthropic has an OpenAI SDK compatibility layer at https://api.anthropic.com/v1/. Its documentation describes Chat Completions and recommends the layer mainly for testing and comparing model capabilities.
The layer differs from a native Messages request in four documented cases:
response_formataccepts onlyjson_schemawithstrict: true; other values return a 400.- The layer ignores the
strictparameter on function tools, so tool-call input is not guaranteed to follow the supplied schema. - Prompt caching is not supported through the layer.
- The OpenAI SDK has no
thinkingparameter, so the layer takes it as an extra field in the request body. The response does not include Claude's thinking.
For a JSON schema on the native Messages API, use output_config.format, as described in Anthropic's structured outputs guide.
Those behaviors belong to Anthropic's compatibility layer. Requesty separately provides auto caching for Chat Completions and Responses: where a provider needs explicit cache breakpoints, Requesty can add them when auto_cache is enabled.
What caching changes in a repeated prompt
Take a 1,000-token prefix repeated across ten requests. The prefix qualifies for caching, the first request writes a five-minute cache, and the next nine read it before it expires. Only the input cost of that prefix is counted.
November 2026 Anthropic prompt caching prices list a five-minute cache write at 1.25 times the base input price and a cache read at 0.1 times for most models. Opus 5.5 and Sonnet 5.5 reads cost 0.05 times, so their saving is larger; our Anthropic prompt caching guide has the per-model rates. Using base input token equivalents, the arithmetic is:
| Calculation | Base input token cost units |
|---|---|
| Ten requests without caching: 10 x 1,000 | 10,000 |
| One cache write: 1,000 x 1.25 | 1,250 |
| Nine cache reads: 9 x 1,000 x 0.1 | 900 |
| Total with caching | 2,150 |
The repeated input prefix costs 78.5% less in this example. Output tokens and any other input are outside the calculation, and a different prefix or timing can change the number of cache reads.
Set the base URL your client expects
Claude Code through Requesty needs the host without /v1, with the Requesty key passed as the authentication token:
export ANTHROPIC_BASE_URL="https://router.requesty.ai"
export ANTHROPIC_AUTH_TOKEN="$REQUESTY_API_KEY"
export ANTHROPIC_MODEL="openai/gpt-6.1-sol"Requesty's Claude Code guide documents these settings. For EU data residency, it uses https://router.eu.requesty.ai. Our Claude Code configuration guide has more detail on the environment variables.
Check the final URL as well as the body. A client that appends /v1/messages to a base URL ending in /v1 can produce /v1/v1/messages and a 404. A Chat Completions request body belongs on the Chat Completions endpoint; the Messages endpoint expects the Anthropic format.
Claude 4.7 and later models do not support the temperature, top_p and top_k sampling parameters, and from API version 2026-10-21 no model does. The Anthropic Messages guide also says prefill returns an error on Claude 4.6 and later.
Before switching an application, send one ordinary request and one tool call through the intended endpoint. Then verify the returned stop status, tool arguments and usage fields in your own code.
Frequently asked questions
- How does the Anthropic Messages API differ from Chat Completions?
- The Anthropic Messages API uses a top-level system field, requires max_tokens, and returns typed content blocks. OpenAI Chat Completions puts instructions in a message, uses max_completion_tokens, and returns choices containing messages.
- Can the Anthropic SDK call models from other providers?
- Yes. Requesty's Messages endpoint accepts the Anthropic format for Claude and compatible models from other providers, converting the format for non-Anthropic models. Set the Anthropic SDK base URL to https://router.requesty.ai.
- What is the correct ANTHROPIC_BASE_URL for Requesty?
- For Claude Code through Requesty, set ANTHROPIC_BASE_URL to https://router.requesty.ai and ANTHROPIC_AUTH_TOKEN to your Requesty key. The client appends /v1/messages to the base URL.
- How do tool results differ between Messages and Chat Completions?
- Anthropic Messages returns tool_use blocks with an input object and expects tool_result blocks linked by tool_use_id. Chat Completions returns message.tool_calls with JSON-formatted argument strings and expects tool messages linked by tool_call_id.
- SEP '26
OpenAI-compatible APIs: format, providers and limits
An OpenAI-compatible API lets you reuse the OpenAI SDK. Compare provider endpoints and see where structured outputs and finish reasons vary.
- JUN '26
Claude Code Environment Variables: How to Set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN
A complete reference for the Claude Code environment variables that control where requests go: ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_MODEL and more. Set them in your shell or settings.json, with copy and paste examples.
