Skip to main content
ARouter’s request and response schemas are very similar to the OpenAI Chat API, with a few small differences. ARouter normalizes the schema across models and providers so you only need to learn one.

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: See the Authentication Guide for details.

Requests

Request Format

Here is the request schema as a TypeScript type. This will be the body of your POST request to the /v1/chat/completions endpoint. For a complete list of parameters, see the Parameters reference.
ARouter’s OpenAI-compatible chat endpoint standardizes on 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

The response_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
For detailed usage and examples, see Structured Outputs. When using JSON mode, you should still instruct the model to respond with JSON in your system or user message.

Optional Request Headers

ARouter supports these optional headers to identify your application:
  • HTTP-Referer: Your app’s URL, used for source tracking in the Dashboard
  • X-Title: Your app’s display name used in ARouter analytics
See Request Attribution for details.

Model Routing

Specify the model using the provider/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

Set stream: 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 as logit_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 with role: "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’s finish_reason to one of the following values: The raw finish reason from the upstream provider is available via 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.

Error Responses

All errors follow a consistent JSON format:
See the Error Handling guide for the full list of error codes and retry strategies.