On this page
Compatibility
Anthropic Messages
POST /v1/messages with the Anthropic request and response shape, executed on the native chat path.
POST
/v1/messagesAPI key (JWT also resolves)Aliases: /messages and /api/v1/messages. The request is translated to the relay's chat body, run through the same auth, allowlist, billing, quota and failover path, then translated back.
Request
curl -X POST https://api.relayrouter.org/v1/messages \ -H "Authorization: Bearer $RELAY_API_KEY" \ -H 'content-type: application/json' \ -d '{ "model": "deepseek-v4.1-flash-1017", "max_tokens": 512, "system": "be terse", "messages": [ { "role": "user", "content": "hello" } ] }'Response
{ "id": "chatcmpl-4cd151fe-a99e-4c13-ba76-38772e5f9e75", "type": "message", "role": "assistant", "model": "deepseek-v4.1-flash-1017", "content": [{ "type": "text", "text": "Hello! How can I help?" }], "stop_reason": "end_turn", "stop_sequence": null, "usage": { "input_tokens": 22, "output_tokens": 16 }}With stream: true the response is an Anthropic event stream: message_start, content_block_start, content_block_delta, content_block_stop, message_delta and message_stop.
Billing
Tokens and cost come from the real completion, exactly as chat: the model's prices × token_multiplier, plus the network fee. The recorded amount is in usage_logs.cost_micro and reflected by /usage.