---
title: "Anthropic vs OpenAI API Format: 7-Field Comparison Table (2026)"
description: "A 7-row table comparing Anthropic Messages and OpenAI Chat Completions: path, auth header, system prompt, max_tokens, response shape, streaming, tools."
url: https://cdnping.org/en/blog/anthropic-vs-openai-api-format
language: en
published: 2026-11-24
category: "AI concepts"
tags: ["API","Anthropic","OpenAI","API format","beginner guide"]
source: cdnping.org
license: Free to quote and summarize with a link to the url above.
---
# Anthropic vs OpenAI API Format: 7-Field Comparison Table (2026)

The Anthropic API and the OpenAI API differ mainly in the request path, the auth header, where the system prompt goes, whether `max_tokens` is required, the response shape, and the streaming events. They do the same job: you send a conversation, and the model sends back text. But the field names and structure differ, so you can't take the same request body and point it at the other address.

That is why many tools ask you to pick an "API type" or "API format." Pick the wrong one and the request goes to the right address in the wrong format, which usually ends in a 401, 404, or 400. What follows is based on the general conventions in both vendors' official docs; for exact fields and version strings, defer to the official documentation.

## What are the two APIs called?

- On the OpenAI side, the most common one is Chat Completions, at `/v1/chat/completions`. OpenAI has since added a Responses API with a different structure. This article covers only Chat Completions, because a huge number of third-party tools and compatible services still follow it.
- Anthropic's is the Messages API, at `/v1/messages`.

When people say "OpenAI-compatible API," they mean a service that implements the Chat Completions format. For details, see [What does "OpenAI-compatible API" mean?](/en/blog/openai-compatible-api-explained)

## The 7-field comparison table

| Item | OpenAI Chat Completions | Anthropic Messages |
|---|---|---|
| Request path | `POST /v1/chat/completions` | `POST /v1/messages` |
| Auth header | `Authorization: Bearer <key>` | `x-api-key: <key>` |
| Version header | Not needed | `anthropic-version` required; value per the official docs |
| System prompt | Inside `messages`, with role `system` (`developer` on some newer models) | Separate top-level `system` field |
| `max_tokens` | Optional | Required |
| Returned text | `choices[0].message.content`, a string | `content` array of blocks; the text is in the block with `type: "text"` |
| Usage fields | `usage.prompt_tokens` / `completion_tokens` | `usage.input_tokens` / `output_tokens` |

Beginners trip over three things most often: the auth header is different, Anthropic requires a version header, and Anthropic requires `max_tokens`.

## What do the two requests look like for the same question?

OpenAI format (example; replace the model name with one your account can use):

```bash
curl https://api.openai.com/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model>",
    "messages": [
      {"role": "system", "content": "你是一个简洁的助手。"},
      {"role": "user", "content": "用一句话解释 DNS。"}
    ]
  }'
```

(The system prompt reads "You are a concise assistant," and the user message reads "Explain DNS in one sentence.")

Anthropic format:

```bash
curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: <see the official docs>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model>",
    "max_tokens": 256,
    "system": "你是一个简洁的助手。",
    "messages": [
      {"role": "user", "content": "用一句话解释 DNS。"}
    ]
  }'
```

Side by side, the differences are exactly the rows in the table: the system prompt moves out of the message list to the top level, `max_tokens` is added, and the auth header has a different name.

## How do responses and streaming differ?

In a non-streaming response, OpenAI's text is a single string and the stop reason is in `finish_reason`. Anthropic's `content` is an array of blocks and the stop reason is in `stop_reason`. When you write parsing code for Anthropic, you iterate over the blocks and pull out the ones whose `type` is `text`, instead of reading one field directly.

Both use SSE (Server-Sent Events) for streaming, but the event structure is different:

- OpenAI: each data chunk carries `choices[0].delta`, the text increment is in `delta.content`, and the stream ends with `data: [DONE]`.
- Anthropic: events are named. The common ones are `message_start`, `content_block_start`, `content_block_delta`, `content_block_stop`, `message_delta`, and `message_stop`. The text increment is in the `content_block_delta` event.

So if you write your own streaming parser, you can't share logic between the two.

## Is the tool-calling (function calling) format the same?

The concept is the same; the structure is not. OpenAI uses `tools` in the request, with each tool's parameters described under `function.parameters`. The `tool_calls` the model returns contain `arguments` as a JSON string that you have to parse yourself. Anthropic describes parameters with `input_schema`, and the model returns a `tool_use` content block whose `input` is already an object. When you send the tool result back, you use a `tool_result` block. For details and newer fields, defer to the official docs.

## Which one should I pick when configuring a tool?

Choose based on whose address and key you are entering. Here is a checklist:

1. If the address is `api.openai.com`, or the provider's docs say "OpenAI-compatible," pick the OpenAI format. The key is generally whatever the provider gives you.
2. If the address is `api.anthropic.com`, or the docs say "Anthropic-compatible / Messages format," pick the Anthropic format.
3. Some tools split the two formats into separate options (for example, "OpenAI" and "Anthropic"). Whether the base URL should include `/v1` varies by tool, so check the tool's docs.
4. A 401: first check that the auth header and key match this format. A 404: first check whether you added or left out `/v1` in the path or base URL. A 400 complaining about a missing `max_tokens`: the request is in Anthropic format but doesn't include that field.
5. If you're unsure, get a minimal request working with curl first, then enter the same settings in the tool.

For how to get the key itself, see [How to get a Claude API key](/en/blog/how-to-get-claude-api-key) and [How to get an OpenAI API key](/en/blog/how-to-get-openai-api-key). If you're not sure how a key relates to a web subscription, read [Claude API vs the web subscription](/en/blog/claude-api-vs-subscription-difference) first. For basic key usage and storage, see [What is an API key?](/en/blog/what-is-api-key-beginner)

## Can one gateway support both formats?

Yes. A gateway implements both interfaces at its entry point, and whichever format the tool chooses is the one that gets served. AGI Plan works this way: it is compatible with both the OpenAI and Anthropic formats, so tools like Claude Code and Codex only need a different endpoint address, and you can also use it in Cherry Studio, Cline, Cursor, and any other tool that lets you enter an endpoint address plus an API key. AGI Plan is a commercial partner of cdnping. It is an aggregation gateway, not an officially authorized channel, and some models are marked "overseas only"; see [agiplan.dev/models](https://agiplan.dev/models) for the current list. For setup steps, see [agiplan.dev/startup](https://agiplan.dev/startup).

## Beyond the format, what else should I check?

If the format is right and requests still fail, look at the network and service status:

- On the cdnping home page, [/en](/en), measure the first-connection and round-trip time to each vendor's API, and compare latency to the OpenAI and Claude entry points.
- Check [/en/status/anthropic](/en/status/anthropic) and [/en/status/openai](/en/status/openai) to see whether the official endpoints have had recent problems.
- For common causes of high latency and how to troubleshoot, see [/en/learn/ai-api-latency-china](/en/learn/ai-api-latency-china).

## Next step

Run each of the two curl commands above once to confirm your key and format match, then go configure your tool. When the tool asks for an "API type," use the first two items of the checklist. If you want to switch between Claude Code, Codex, and similar tools on a single subscription and pay in CNY (Chinese yuan), see the three-step setup at [agiplan.dev/startup](https://agiplan.dev/startup).
