API Overview
AnyRouter's REST API is a superset of the OpenAI API. Learn about base URLs, headers, error shapes, versioning, and the full list of endpoints.
API Overview
The AnyRouter API is a superset of the OpenAI API. Any existing OpenAI tooling, SDK, or framework works out of the box — just override the base URL.
Base URL
TEXT
text
https://anyrouter.dev/api/v1All endpoints are versioned under /v1. Breaking changes bump the version (/v2) without removing older versions for a minimum 12-month deprecation window.
Common headers
| Header | Required | Description |
|---|---|---|
Authorization: Bearer <key> | Yes | AnyRouter API key. |
Content-Type: application/json | POST | Required on POST endpoints. |
X-AnyRouter-Provider | No | Force routing to a specific upstream provider. |
X-AnyRouter-Trace-Id | No | Client-supplied trace id surfaced in audit logs. |
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /chat/completions | Chat completions (OpenAI-compatible) |
| POST | /messages | Anthropic Messages passthrough |
| POST | /completions | Legacy text completions |
| POST | /embeddings | Vector embeddings |
| GET | /models | List models |
| GET | /models/:id | Model metadata |
| GET | /models/count | Total model count |
| POST | /batch | Submit batched requests |
| GET | /generation/:id | Per-request stats (tokens, cost, latency) |
| GET | /providers | List upstream providers |
| GET | /credits | Remaining credit balance |
| GET | /auth/key | Current API key info |
| GET | /health | Gateway + provider status |
Error shape
All errors follow the OpenAI error envelope:
JSON
json
{
"error": {
"message": "Rate limit exceeded for model openai/gpt-4-turbo",
"type": "rate_limit_error",
"code": "rate_limited",
"param": null
}
}See Errors for the full list of codes and recommended retry behavior.
Rate limits
Rate limits are enforced per-key. Every response carries:
TEXT
text
X-RateLimit-Limit: <requests per minute>
X-RateLimit-Remaining: <remaining in current window>
X-RateLimit-Reset: <unix seconds until window reset>Versioning
Changes are categorized as:
- Additive (new fields, new endpoints) — ship continuously, no notice.
- Deprecation — announced with a 12-month sunset window and
Deprecationresponse header. - Breaking — land on a new
/v2path;/v1remains available for the deprecation window.