API Reference
Complete documentation for all AIRouter endpoints
Base URL: http://localhost:3000
Chat Completions
POST
/api/v1/chat/completionsCreate a chat completion with intelligent routing
Request Body:
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Hello, world!"
}
],
"temperature": 0.7,
"routingStrategy": "cost",
"enableCache": true
}Response:
{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-3.5-turbo",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finishReason": "stop"
}],
"usage": {
"promptTokens": 10,
"completionTokens": 9,
"totalTokens": 19
},
"provider": "openai",
"cost": 28,
"cached": false
}Authentication
All API requests require an API key in the Authorization header:
Authorization: Bearer sk-air-your-api-keyKey Parameters
| Parameter | Type | Description |
|---|---|---|
| model | string | Model name (e.g., "gpt-3.5-turbo") |
| messages | array | Array of message objects |
| routingStrategy | string | cost, latency, priority, fallback |
| enableCache | boolean | Enable response caching (default: true) |
| temperature | number | 0-2, controls randomness |
Error Codes
| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid API key |
| 402 | Payment Required - Insufficient credits |
| 429 | Rate Limited - Too many requests |
| 503 | Service Unavailable - No providers available |
Try the Interactive API
Want to test the API directly in your browser? Check out our Swagger UI with live examples.
Open Interactive API Docs →