Anthropic Messages API
An API communication protocol specification defined by Anthropic. Third-party providers can implement the same request/response structure and authentication method on their servers, allowing compatible clients to connect without modification.
Timeline (last 90 days)
Claude Code uses Anthropic's Messages protocol rather than OpenAI's chat completions protocol, so setting only the Base URL cannot directly connect to OpenAI-shaped endpoints.
When using a custom relay station, you need to fill in both the Base URL and the API Key, and ensure that the service is compatible with the Anthropic Messages API format; otherwise, requests will fail or streaming output will be abnormal.
The stop_reason field in the top-level response of the Anthropic Messages API has seven possible values in total: end_turn, tool_use, max_tokens, stop_sequence, refusal, pause_turn, and model_context_window_exceeded.
In streaming (SSE) mode, stop_reason is given in the message_delta event, immediately before message_stop, rather than arriving with the first event.
When stop_reason is stop_sequence, the stop_sequence field in the response carries back the actual stop sequence string that was hit.
In January 2026, Ollama natively supported the Anthropic Messages API, with LM Studio and llama.cpp following closely behind.
Claude Code can point to localhost by setting the ANTHROPIC_BASE_URL environment variable, communicating with local models without a proxy translation layer.
Anthropic's Messages API allows system content to be inserted at any position in the conversation.
The max_tokens parameter is required in the Anthropic Messages protocol.
Mainstream large language model APIs differ significantly in message format: Anthropic uses a messages array structure with a special system prompt separation approach, while OpenAI uses role/content key-value pairs and supports the function calling format.
All Facts (11)
Claude使用Anthropic Messages API格式,而GPT系列使用OpenAI Chat Completions格式,两者接口规范存在本质差异
95%UnverifiedMainstream large language model APIs differ significantly in message format: Anthropic uses a messages array structure with a special system prompt separation approach, while OpenAI uses role/content key-value pairs and supports the function calling format.
60%UnverifiedClaude Code uses Anthropic's Messages protocol rather than OpenAI's chat completions protocol, so setting only the Base URL cannot directly connect to OpenAI-shaped endpoints.
50%UnverifiedWhen using a custom relay station, you need to fill in both the Base URL and the API Key, and ensure that the service is compatible with the Anthropic Messages API format; otherwise, requests will fail or streaming output will be abnormal.
50%UnverifiedWhen stop_reason is stop_sequence, the stop_sequence field in the response carries back the actual stop sequence string that was hit.
50%UnverifiedThe stop_reason field in the top-level response of the Anthropic Messages API has seven possible values in total: end_turn, tool_use, max_tokens, stop_sequence, refusal, pause_turn, and model_context_window_exceeded.
50%UnverifiedIn streaming (SSE) mode, stop_reason is given in the message_delta event, immediately before message_stop, rather than arriving with the first event.
50%UnverifiedClaude Code can point to localhost by setting the ANTHROPIC_BASE_URL environment variable, communicating with local models without a proxy translation layer.
50%UnverifiedAnthropic's Messages API allows system content to be inserted at any position in the conversation.
50%UnverifiedThe max_tokens parameter is required in the Anthropic Messages protocol.
50%UnverifiedIn January 2026, Ollama natively supported the Anthropic Messages API, with LM Studio and llama.cpp following closely behind.
50%