Synrouter Docs
API reference
Synrouter exposes OpenAI-compatible, Anthropic-compatible, and Synrouter-specific public endpoints for model inference and pricing metadata.
Authentication
All API calls require a Synrouter API key in the Authorization header as a Bearer token. Keys use the sk-sr-* prefix.
http
1Authorization: Bearer sk-sr-...
Endpoints
GET /v1/models
Returns the current OpenAI-compatible model list. Use as source of truth for available model IDs.
POST /v1/chat/completions
Creates a chat completion through the OpenAI-compatible API. Supports streaming via
stream: true.POST /anthropic/v1/messages
Creates a message through the Anthropic-compatible Messages API. Supports streaming and tool use.
GET /api/sr/pricing
Returns Synrouter pricing metadata for all configured models in USD/MTok.
Chat Completions
Use this endpoint with OpenAI-compatible SDKs and clients. Production base URL: https://synrouter.ai/api/v1.
bash
1curl https://synrouter.ai/api/v1/chat/completions \
2 -H "Authorization: Bearer sk-sr-..." \
3 -H "Content-Type: application/json" \
4 -d '{
5 "model": "deepseek/deepseek-v4-flash",
6 "messages": [
7 { "role": "user", "content": "Return a JSON object with one greeting." }
8 ]
9 }'
Response shape:
json
1{
2 "id": "chatcmpl-...",
3 "object": "chat.completion",
4 "created": 1710374400,
5 "model": "deepseek/deepseek-v4-flash",
6 "choices": [
7 {
8 "index": 0,
9 "message": {
10 "role": "assistant",
11 "content": "{\"greeting\": \"Hello from Synrouter!\"}"
12 },
13 "finish_reason": "stop"
14 }
15 ],
16 "usage": {
17 "prompt_tokens": 25,
18 "completion_tokens": 12,
19 "total_tokens": 37
20 }
21}
Anthropic Messages
Use this endpoint with Anthropic-compatible clients. Production base URL: https://synrouter.ai/api/anthropic.
bash
1curl https://synrouter.ai/api/anthropic/v1/messages \
2 -H "Authorization: Bearer sk-sr-..." \
3 -H "Content-Type: application/json" \
4 -d '{
5 "model": "anthropic/claude-sonnet-4.6",
6 "max_tokens": 256,
7 "messages": [
8 { "role": "user", "content": "Explain session-aware caching." }
9 ]
10 }'
Models
bash
1curl https://synrouter.ai/api/v1/models \
2 -H "Authorization: Bearer sk-sr-..."
Pricing
Returns model pricing in USD per million tokens. Use for cost estimation; final billing is based on actual request usage.
bash
1curl https://synrouter.ai/api/sr/pricing
Response headers
Every chat completion and message response includes Synrouter-specific headers with savings and session metadata:
x-synrouter-session-id— session identifier assigned by Synrouter for cache grouping.x-synrouter-cache-savings-usd— estimated USD saved from cache reads on this request.x-synrouter-trim-savings-usd— estimated USD saved from tool-result trimming on this request.x-synrouter-trimmed-tokens— estimated number of input tokens removed by trimming before routing.
Error codes
| Status | Meaning |
|---|---|
| 200 | Request succeeded. |
| 400 | Invalid request body or parameters. |
| 401 | Missing or invalid API key. |
| 429 | Rate limit exceeded. Retry after Retry-After seconds. |
| 500 | Upstream provider error after Synrouter retries. |
| 503 | Service temporarily unavailable. |