API Documentation
Guide to using the Cognify Router API proxy for making requests to OpenRouter models.
Authentication
All API requests are made with a key you create in the dashboard under the «API keys» tab. The key has the format sk-cr-… and is passed in the Authorization header as a Bearer token.
Authorization: Bearer sk-cr-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxChat Completions
The endpoint is compatible with OpenAI / OpenRouter Chat Completions. Send an array of messages and receive the model's response.
/api/v1/chat/completionscurl -X POST https://router.cognify-labs.ru/api/v1/chat/completions \
-H "Authorization: Bearer sk-cr-..." \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [
{"role": "system", "content": "Ты полезный ассистент."},
{"role": "user", "content": "Объясни квантовую запутанность простыми словами"}
],
"temperature": 0.7
}'Response example
{
"id": "chatcmpl-abc123",
"model": "openai/gpt-4o-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Квантовая запутанность — это явление..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 150,
"total_tokens": 175
}
}Streaming
For streaming responses, pass "stream": true. The response comes as an SSE stream (Server-Sent Events), terminated by data: [DONE].
/api/v1/chat/completionscurl -N -X POST https://router.cognify-labs.ru/api/v1/chat/completions \
-H "Authorization: Bearer sk-cr-..." \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": "Напиши сказку про кота"}],
"stream": true
}'SSE stream format
data: {"choices":[{"delta":{"content":"Ж"}, "index":0}]}
data: {"choices":[{"delta":{"content":"ил"}, "index":0}]}
data: {"choices":[{"delta":{"content":"-был"}, "index":0}]}
data: {"choices":[{"delta":{}, "index":0}], "finish_reason":"stop"}
data: [DONE]Image Generation
Image generation via POST /api/v1/images. Streaming of partial results is supported.
/api/v1/imagescurl -X POST https://router.cognify-labs.ru/api/v1/images \
-H "Authorization: Bearer sk-cr-..." \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-2.5-flash-image",
"prompt": "Космический кот в стиле киберпанк",
"stream": true
}'Video Generation
Video generation is asynchronous. Create a job, poll for status, and download the result.
1. Create job
/api/v1/videoscurl -X POST https://router.cognify-labs.ru/api/v1/videos \
-H "Authorization: Bearer sk-cr-..." \
-H "Content-Type: application/json" \
-d '{
"model": "google/veo-3",
"prompt": "Закат над океаном, slow motion"
}'Response example
{
"id": "vid_abc123",
"status": "processing",
"polling_url": "/api/v1/videos/vid_abc123"
}2. Poll status
/api/v1/videos/{job_id}curl https://router.cognify-labs.ru/api/v1/videos/vid_abc123 \
-H "Authorization: Bearer sk-cr-..."Response example
{
"id": "vid_abc123",
"status": "completed",
"unsigned_urls": ["/api/v1/videos/vid_abc123/content?index=0"]
}3. Download video
/api/v1/videos/{job_id}/contentcurl https://router.cognify-labs.ru/api/v1/videos/vid_abc123/content?index=0 \
-H "Authorization: Bearer sk-cr-..." \
-o video.mp4Models
The list of available models with ruble prices is available at /api/models (no auth required) or on the «Pricing» page.
/api/modelscurl https://router.cognify-labs.ru/api/modelsResponse example
{
"models": [
{
"id": "openai/gpt-4o-mini",
"context_length": 128000,
"pricing": {
"prompt": "0.15 RUB",
"completion": "0.60 RUB"
}
}
]
}Error Handling
Errors are returned with the appropriate HTTP status. Error bodies are sanitized: OpenRouter URLs, IDs, and internal metadata are not relayed. 402 means you need to top up your balance.
| Status | Meaning |
|---|---|
| 200 | Success |
| 401 | Invalid or expired key |
| 402 | Insufficient funds — top up balance |
| 403 | Account blocked or IP not allowlisted |
| 429 | Key spending limit exceeded |
| 502 | Upstream provider unavailable |
| 503 | Service temporarily unavailable |