POST /v1/messages accepts Anthropic Messages API requests and answers in Anthropic format. Use it when your code or tools already speak Anthropic: the gateway translates the request, so the model behind it can be any provider — OpenAI, Bedrock, Gemini, a self-hosted model, or Anthropic itself.

How it works

  1. The gateway converts the Anthropic body into an OpenAI chat completion.
  2. The request runs through the same pipeline as /v1/chat/completions: RBAC, policies, guardrails, PII redaction, cache, routing, metering and audit.
  3. The response — or the SSE stream — is converted back into Anthropic framing.
Because the request runs as a chat completion, models from workspace providers and routing configs (including virtual models) work here too.

Request structure

Key fields

Fields not listed — for example top_k, metadata, thinking, cache_control, and image or document blocks — are ignored rather than rejected, with one exception: a hosted tool (a tools entry with a type other than custom and no input_schema, such as web_search_20250305, bash_… or computer_…) is refused with 400 invalid_request_error. Requests without model or with max_tokens missing or 0 return 400 invalid_request_error.

Responses

A non-streaming response is an Anthropic message:
stop_reason maps from the upstream finish reason: stop → end_turn, length → max_tokens, tool_calls → tool_use. Tool calls come back as tool_use content blocks.

Streaming

With "stream": true the gateway emits Anthropic SSE events in this order: message_start, then content_block_start / content_block_delta / content_block_stop for each text block (text_delta) or tool call (input_json_delta), then message_delta with the stop_reason, and finally message_stop. No ping events are sent.

Errors

Errors raised by the translation or the inference pipeline use the Anthropic envelope with the gateway’s HTTP status:
Every error on /v1/messages, including authentication and entitlement failures, uses the Anthropic envelope. error.type follows the HTTP status: authentication_error (401), billing_error (402), permission_error (403), not_found_error (404), request_too_large (413), rate_limit_error (429), timeout_error (504), overloaded_error (529), api_error (other 5xx) and invalid_request_error (other 4xx). Authentication and entitlement errors also carry the gateway code (for example invalid_api_key, key_expired); errors from the inference pipeline do not. Unrouted paths such as /v1/messages/count_tokens and wrong methods still use the OpenAI envelope.

Authentication

The gateway accepts the token as Authorization: Bearer <token> or as x-api-key; the bearer token wins when both are sent. The Anthropic SDK default (api_key= / ANTHROPIC_API_KEY) works as is, and auth_token / ANTHROPIC_AUTH_TOKEN works too. The client key is never forwarded to the provider.

Common configurations

Point Claude Code at the gateway with environment variables. Set either ANTHROPIC_AUTH_TOKEN (sent as Authorization: Bearer) or ANTHROPIC_API_KEY (sent as x-api-key); the gateway accepts both.
Make sure the model names Claude Code requests exist in your workspace, as models, aliases or virtual models.
Send any model name from GET /v1/models, or a virtual model, as model. The translation is the same whatever the provider.
Return each tool’s output as a tool_result block whose content is a string or an array of text blocks, with tool_use_id set to the id of the matching tool_use block.
Translation covers text and tool use. Images, documents, extended thinking and prompt caching blocks are dropped. /v1/messages/count_tokens isn’t implemented and returns 404 unsupported_endpoint. Agents that depend on those features — including some Claude Code workflows — may not behave as they do against Anthropic directly.
X-ManyLayers-* request headers (config, metadata, guardrails, cache control) work on /v1/messages, and response headers such as X-ManyLayers-Trace-Id are passed through.

Next steps

Making Requests

OpenAI SDK, LangChain and LlamaIndex setup.

Request & Response Headers

Steer and inspect requests with headers.

Routing

Fallback and virtual models behind one name.

Endpoints

Everything else the gateway serves.