OpenAPI Specification
The complete ARouter API is documented using the OpenAPI specification: ARouter currently publishes the YAML specification. You can use it with tools like Swagger UI or Postman to explore the API or generate client libraries.Base URL
Authentication
All endpoints (except/healthz) require authentication via one of:
| Method | Header / Parameter | Used By |
|---|---|---|
| Bearer Token | Authorization: Bearer <key> | OpenAI SDK, most clients |
| API Key Header | X-Api-Key: <key> | Anthropic SDK |
| Query Parameter | ?key=<key> | Gemini SDK |
Requests
Request Format
Here is the request schema as a TypeScript type. This will be the body of yourPOST request to the /v1/chat/completions endpoint.
For a complete list of parameters, see the Parameters reference.
messages. If you want to send a provider’s native request body instead, use the native endpoint for that provider or the Provider Proxy.
Message Types
Tool Types
Structured Outputs
Theresponse_format parameter enforces structured JSON responses from the model. ARouter supports two modes:
{ type: 'json_object' }: Basic JSON mode — the model returns valid JSON{ type: 'json_schema', json_schema: { ... } }: Strict schema mode — the model returns JSON matching your exact schema
Optional Request Headers
ARouter supports these optional headers to identify your application:HTTP-Referer: Your app’s URL, used for source tracking in the DashboardX-Title: Your app’s display name used in ARouter analytics
Model Routing
Specify the model using theprovider/model format. ARouter parses the provider prefix and routes to the correct upstream.
If the model parameter is omitted, the tenant’s configured default is used. See the Model Routing guide for the full routing logic, including ordered candidate model lists using models[] and route.
Streaming
Setstream: true to receive token-by-token responses via Server-Sent Events. SSE streams can include comment lines in addition to data: payloads, and clients should ignore those comments. See the Streaming guide for SSE format, usage chunks, cancellation, and error handling.
Non-Standard Parameters
If the chosen model doesn’t support a request parameter (such aslogit_bias in non-OpenAI models, or top_k for OpenAI), the parameter is silently ignored. The rest are forwarded to the upstream model API.
Assistant Prefill
ARouter supports asking models to complete a partial response. Include a message withrole: "assistant" at the end of your messages array:
Responses
Response Format
ARouter normalizes the schema across models and providers to comply with the OpenAI Chat API.choices is always an array. Each choice contains a delta property if streaming was requested, and a message property otherwise.
Choice Types
Usage
Response Example
Finish Reason
ARouter normalizes each model’sfinish_reason to one of the following values:
| Value | Description |
|---|---|
stop | Model completed naturally |
length | max_tokens limit reached |
tool_calls | Model wants to call a tool |
content_filter | Content moderation triggered |
error | An error occurred during generation |
native_finish_reason.
Endpoint Groups
OpenAI Compatible
/v1/chat/completions, /v1/embeddings, /v1/modelsUse with any OpenAI-compatible SDK. Supports provider/model routing.Anthropic Native
/v1/messages, /v1/messages/batches, /v1/messages/count_tokensDrop-in compatible with the Anthropic SDK.Gemini Native
/v1beta/models/{model}:generateContentDrop-in compatible with the Google Gemini SDK.Key Management
/api/v1/keysCreate, list, update, and delete API keys.Billing
/api/v1/balance, /api/v1/transactionsQuery account balance and transaction history.Provider Proxy
/{provider}/{path}Proxy requests directly to any supported provider.Rate Limits
Rate limits are applied per API key. Default limits can be customized per key via the Dashboard or the management API.| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per window |
X-RateLimit-Remaining | Requests remaining |
X-RateLimit-Reset | Window reset time (Unix timestamp) |