Messages (Anthropic API)
Anthropic Messages API-compatible endpoint for native Claude SDK integration.
POST /v1/messages
Send a chat completion using the Anthropic Messages API format. This endpoint runs through the exact same pipeline as /v1/chat/completions — same BYOK, budget, guardian, guardrails, tool firewall, audit, and routing — but accepts and returns Anthropic-format requests and responses.
This allows tools that natively speak the Anthropic Messages API (e.g., Claude SDKs, Microsoft 365 Copilot add-ins, custom integrations) to connect to BrainstormRouter without any format conversion on the client side.
Request
curl https://api.brainstormrouter.com/v1/messages \
-H "Authorization: Bearer br_live_..." \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "anthropic/claude-sonnet-4-20250514",
"max_tokens": 1024,
"system": "You are a helpful assistant.",
"messages": [
{"role": "user", "content": "Explain quantum computing in one sentence."}
]
}'
Response (Non-Streaming)
{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"model": "anthropic/claude-sonnet-4-20250514",
"stop_reason": "end_turn",
"stop_sequence": null,
"content": [
{
"type": "text",
"text": "Quantum computing uses quantum bits that can exist in multiple states simultaneously, enabling parallel processing of complex calculations."
}
],
"usage": {
"input_tokens": 25,
"output_tokens": 28
}
}
Streaming
Set "stream": true to receive Anthropic-format SSE events:
data: {"type":"message_start","message":{"id":"msg_abc123","type":"message","role":"assistant","content":[],"model":"anthropic/claude-sonnet-4-20250514","stop_reason":null,"usage":{"input_tokens":25,"output_tokens":0}}}
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Quantum"}}
event: content_block_stop
data: {"type":"content_block_stop","index":0}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":28}}
event: message_stop
data: {"type":"message_stop"}
Cross-Provider Routing
You can route to any provider through this endpoint — not just Anthropic. The request format is always Anthropic, but the model can be any BrainstormRouter model:
{
"model": "openai/gpt-4o",
"max_tokens": 1024,
"messages": [{ "role": "user", "content": "Hello" }]
}
The response will always be in Anthropic Messages format regardless of which provider handled the request.
Tool Use
{
"model": "anthropic/claude-sonnet-4-20250514",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "Get current weather for a city",
"input_schema": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}
],
"messages": [{ "role": "user", "content": "What's the weather in SF?" }]
}
BrainstormRouter Headers
All standard X-BR-* headers are present on /v1/messages responses, confirming the full pipeline ran:
X-BR-Guardian-Status— Guardian processing statusX-BR-Estimated-Cost/X-BR-Actual-Cost— Cost trackingX-BR-Routing-Overhead-Ms— Routing overhead latencyX-BR-Total-Latency-Ms— Total request latency
Authentication
Same as all /v1/* endpoints: Authorization: Bearer br_live_...
Required RBAC permission: router.write (same as /v1/chat/completions).