321AI Model MarketplaceLive marketplace →

OpenAI-compatible endpoints vs Anthropic Messages

Protocols · 2026-11-12 · 321AI engineering notes · get a key

Quick answer: OpenAI Chat Completions and Anthropic Messages are the two protocols every AI tool speaks. They model the same conversation differently — roles, content blocks, event streams — and mixing up their conventions is the top cause of broken integrations. This is a practical map of the differences that matter, on one gateway that speaks both natively.

Sign up & get trial creditSee live pricing

Same conversation, two shapes

Both protocols are a list of messages sent to an endpoint, but the shapes differ. OpenAI keeps the system prompt as a message with a system role (or a top-level parameter), and tool interactions ride in tool_calls fields on assistant messages. Anthropic pulls the system prompt out as a dedicated top-level system parameter, and models conversation content as typed blocks — text, tool_use, tool_result — which is why Claude’s tool loop looks different from GPT’s even when the logic is identical.

Neither shape is better — they encode different philosophies, and both are stable targets with mature SDK ecosystems. What matters operationally is that a team picks one per service and stays there: the bugs that hurt are the mixed-convention ones, where a system prompt silently becomes a user message or a tool result lands in the wrong block type.

Endpoints and base URLs on 321AI

The gateway exposes both protocols natively, and the base URL convention differs in one character-class that trips everyone:

OpenAI protocolAnthropic protocol
Endpoint/v1/chat/completions, /v1/responses, /v1/embeddings/v1/messages
Base URL formhttps://321ai.cc/v1 (with /v1)https://321ai.cc (no /v1)
Auth headersAuthorization: Bearerx-api-key (Bearer also accepted)
System promptsystem role / parametertop-level system parameter
Content modelstring content + tool_callstyped content blocks
StreamingSSE with delta choicesSSE with typed events

In practice: OpenAI-protocol clients get base_url = https://321ai.cc/v1; Claude Code gets an environment variable — ANTHROPIC_BASE_URL=https://321ai.cc with ANTHROPIC_AUTH_TOKEN set to your key. The Messages endpoint is verified in production for both non-streaming and streaming, with both auth header styles; the /v1/responses endpoint used by Codex CLI works too. One honest limitation: count_tokens is not exposed yet, so Claude Code falls back to local token estimation — normal usage is unaffected.

Streaming: both are SSE, but the events differ

Both protocols stream as server-sent events. OpenAI streams chat-completion chunks whose deltas accumulate into the message; Anthropic streams named lifecycle events — message start, content-block deltas, message stop — that a client must route by event type. Libraries handle this for you; hand-rolled parsers are where teams get bitten. Test streaming explicitly during setup rather than discovering it in production.

One more streaming nuance: token usage arrives differently — OpenAI reports usage in the final chunk when requested, Anthropic in the message-start and message-delta events — so cost accounting for streamed calls needs its own parsing path in both stacks. If your metering reads only non-streamed responses today, your real spend is higher than your dashboard says.

Tool calling differences

The loop logic is the same — declare tools, receive a call, execute, return the result — but the wire shapes differ: OpenAI carries tool calls as tool_calls with JSON arguments, Anthropic as tool_use blocks answered by tool_result blocks. Porting a tool loop between protocols is mechanical but not copy-paste; keep your tool execution layer protocol-agnostic and adapt at the edges. The Anthropic Messages via 321AI guide covers the Claude-side loop in full.

A five-minute conformance test

Before pointing production at any new endpoint — this gateway included — run the same four calls against both protocols: a plain completion, a streaming completion, a tool-call round trip, and an error case with a bad key. The first three prove the happy paths; the fourth proves the error contract your retry logic depends on. Both protocol stacks pass all four here, and the setup guides give you the exact fields for the twenty most common clients.

Which protocol should you use?

Whichever your tool already speaks — both reach every model on the platform, so protocol choice is about your client stack, not model access. Per-tool setup guides for 20+ tools (Claude Code, Cursor, Cline, Cherry Studio, Dify and more) live under /en/guides/, and the FAQ answers the common setup questions. One account reaches both protocols; the key and balance are shared.

FAQ

Does the Anthropic protocol really work natively here?

Yes. The Messages endpoint (/v1/messages) is verified in production, non-streaming and streaming, accepting both x-api-key and Authorization: Bearer headers. Claude Code works with ANTHROPIC_BASE_URL set to https://321ai.cc.

Why does my Anthropic base URL not include /v1?

SDKs built for the Anthropic protocol append /v1/messages themselves. Setting ANTHROPIC_BASE_URL to https://321ai.cc (no /v1) is correct; adding /v1 produces the wrong path.

Are tool calls supported on both protocols?

Yes. OpenAI-protocol tool_calls and Anthropic tool_use/tool_result blocks both work; keep your tool execution layer protocol-agnostic and adapt at the wire edge.

Is count_tokens available?

Not yet. Claude Code falls back to local token estimation automatically, which does not affect normal usage. Everything else in the Messages flow works as documented.

Keep reading

What is an AI API aggregation platform? How multi-supplier bidding keeps model prices low 9 checks before you top up an AI API relay Claude API cost guide: the per-1M-token math GPT-5.x family pricing guide for developers Gemini 3.x pricing and long-context cost math

Live prices: /en/models/ · billing: /en/pricing · setup: /en/guides/ · FAQ

All model pricesFeatured · 321AI communityFeatured · Open-source toolsFeatured · Advertise with usFeatured