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
- The gateway converts the Anthropic body into an OpenAI chat completion.
- The request runs through the same pipeline as
/v1/chat/completions: RBAC, policies, guardrails, PII redaction, cache, routing, metering and audit. - The response — or the SSE stream — is converted back into Anthropic framing.
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 Anthropicmessage:
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:/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 asAuthorization: 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
Claude Code
Claude Code
Point Claude Code at the gateway with environment variables. Set either Make sure the model names Claude Code requests exist in your workspace, as models, aliases or virtual models.
ANTHROPIC_AUTH_TOKEN (sent as Authorization: Bearer) or ANTHROPIC_API_KEY (sent as x-api-key); the gateway accepts both.Route Anthropic-format traffic to another provider
Route Anthropic-format traffic to another provider
Send any model name from
GET /v1/models, or a virtual model, as model. The translation is the same whatever the provider.Tool use loop
Tool use loop
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.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.