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/v1

All endpoints are versioned under /v1. Breaking changes bump the version (/v2) without removing older versions for a minimum 12-month deprecation window.

Common headers

HeaderRequiredDescription
Authorization: Bearer <key>YesAnyRouter API key.
Content-Type: application/jsonPOSTRequired on POST endpoints.
X-AnyRouter-ProviderNoForce routing to a specific upstream provider.
X-AnyRouter-Trace-IdNoClient-supplied trace id surfaced in audit logs.

Endpoints

MethodPathDescription
POST/chat/completionsChat completions (OpenAI-compatible)
POST/messagesAnthropic Messages passthrough
POST/completionsLegacy text completions
POST/embeddingsVector embeddings
GET/modelsList models
GET/models/:idModel metadata
GET/models/countTotal model count
POST/batchSubmit batched requests
GET/generation/:idPer-request stats (tokens, cost, latency)
GET/providersList upstream providers
GET/creditsRemaining credit balance
GET/auth/keyCurrent API key info
GET/healthGateway + 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 Deprecation response header.
  • Breaking — land on a new /v2 path; /v1 remains available for the deprecation window.