Skip to content

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.

Header
Authorization: Bearer sk-cr-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Chat Completions

The endpoint is compatible with OpenAI / OpenRouter Chat Completions. Send an array of messages and receive the model's response.

POST/api/v1/chat/completions
curl -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

JSON
{
  "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].

POST/api/v1/chat/completions
curl -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

SSE
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.

POST/api/v1/images
curl -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

POST/api/v1/videos
cURL
curl -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

JSON
{
  "id": "vid_abc123",
  "status": "processing",
  "polling_url": "/api/v1/videos/vid_abc123"
}

2. Poll status

GET/api/v1/videos/{job_id}
cURL
curl https://router.cognify-labs.ru/api/v1/videos/vid_abc123 \
  -H "Authorization: Bearer sk-cr-..."

Response example

JSON
{
  "id": "vid_abc123",
  "status": "completed",
  "unsigned_urls": ["/api/v1/videos/vid_abc123/content?index=0"]
}

3. Download video

GET/api/v1/videos/{job_id}/content
cURL
curl https://router.cognify-labs.ru/api/v1/videos/vid_abc123/content?index=0 \
  -H "Authorization: Bearer sk-cr-..." \
  -o video.mp4

Models

The list of available models with ruble prices is available at /api/models (no auth required) or on the «Pricing» page.

GET/api/models
curl https://router.cognify-labs.ru/api/models

Response example

JSON
{
  "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.

StatusMeaning
200Success
401Invalid or expired key
402Insufficient funds — top up balance
403Account blocked or IP not allowlisted
429Key spending limit exceeded
502Upstream provider unavailable
503Service temporarily unavailable