Anthropic Messages
Drop-in Anthropic-compatible POST /v1/messages endpoint with system prompts, image inputs, and tool use.
POST /v1/messages is a drop-in replacement for the Anthropic Messages API. Point the Anthropic SDK (or any Anthropic-compatible client) at the gateway base URL and your existing code keeps working, including system prompts, image inputs, and tool use.
Endpoint#
/v1/messagesCreate a message. Responses follow the Anthropic message object shape; errors use the Anthropic-shaped envelope ({ type: "error", error: {...} }).
Parameters
The model identifier (`<public-name>`). See [Model Catalog](/en/docs/api-reference/models).
The conversation as an ordered array of `{ role, content }` objects.
A top-level system prompt, Anthropic style. Optional but recommended for steering behavior.
The maximum number of tokens to generate. Required by the Anthropic Messages API.
falseSet `true` to receive Server-Sent Events. See [Streaming & SSE](/en/docs/api-reference/streaming).
Sampling temperature. Forwarded to the upstream unchanged when provided.
Request Example
curl -X POST "https://api.zrouter.dev/v1/messages" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<public-name>",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Say hello!"}]
}'Responses
{
"id": "msg_...",
"type": "message",
"role": "assistant",
"model": "<public-name>",
"content": [
{ "type": "text", "text": "Hello!" }
],
"stop_reason": "end_turn",
"usage": { "input_tokens": 9, "output_tokens": 3 }
}Streaming#
With "stream": true the gateway relays the native Anthropic event stream unchanged, ending with message_stop. Raw event examples are in Streaming & SSE.