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.
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.
The gateway exposes both protocols natively, and the base URL convention differs in one character-class that trips everyone:
| OpenAI protocol | Anthropic protocol | |
|---|---|---|
| Endpoint | /v1/chat/completions, /v1/responses, /v1/embeddings | /v1/messages |
| Base URL form | https://321ai.cc/v1 (with /v1) | https://321ai.cc (no /v1) |
| Auth headers | Authorization: Bearer | x-api-key (Bearer also accepted) |
| System prompt | system role / parameter | top-level system parameter |
| Content model | string content + tool_calls | typed content blocks |
| Streaming | SSE with delta choices | SSE 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.
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.
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.
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.
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.
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.
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.
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.
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.
Live prices: /en/models/ · billing: /en/pricing · setup: /en/guides/ · FAQ