API Reference
OpenAI-Compatible REST API
Base URL: https://api.1router.com/v1
Authentication
All requests require a Bearer token in the Authorization header. Get your API key from the dashboard.
Authorization: Bearer router_sk_...Endpoints
POST
/v1/chat/completionsCreate a chat completion with any model
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model ID, e.g. openai/gpt-4o |
| messages | array | Yes | Array of message objects |
| temperature | number | No | 0–2, default 1 |
| max_tokens | integer | No | Max output tokens |
| stream | boolean | No | Stream response via SSE |
| response_format | object | No | JSON mode: { type: "json_object" } |
POST
/v1/completionsCreate a text completion (legacy)
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model ID |
| prompt | string | Yes | Input text |
| max_tokens | integer | No | Max output tokens |
GET
/v1/modelsList all available models
POST
/v1/embeddingsGenerate text embeddings
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Embedding model ID |
| input | string | Yes | Text to embed |
GET
/v1/usageGet usage statistics for your API key
| Parameter | Type | Required | Description |
|---|---|---|---|
| start_date | string | No | ISO 8601 date |
| end_date | string | No | ISO 8601 date |
Example
Request
POST /v1/chat/completions
Authorization: Bearer router_sk_...
{
"model": "openai/gpt-4o",
"messages": [
{"role": "user", "content": "Hi"}
]
}Response (200)
{
"id": "chatcmpl_abc123",
"model": "openai/gpt-4o",
"choices": [{
"message": {
"role": "assistant",
"content": "Hello! How can I help?"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 8,
"completion_tokens": 7,
"total_tokens": 15
}
}