Skip to content

Quickstart

Create an Openrouter API key and send your first chat, image and video requests in five minutes with cURL, Python or Node.js.

All documentation

Openrouter API gives you one API key and one base URL for every model in the model directory. If you have used the OpenAI API before, you already know how to use Openrouter API: change the base URL, use your Openrouter API key, and pick a model id.

1. Create an account and a key

  1. Sign in with Google or a one-time email code. Your account is created automatically.
  2. Open the console and top up your balance. The minimum top-up is $50 and the balance does not expire.
  3. Click Create key, give it a name such as development, and copy the key. It starts with sk-ora- and is shown in full only once.

Tip

Store the key in an environment variable such as OPENROUTERAPI_API_KEY instead of hard-coding it. Never ship it in browser or mobile app code.

2. Send your first chat request

The base URL is https://openrouterapi.ru/v1. Every chat model uses the OpenAI-compatible POST /v1/chat/completions endpoint.

cURL
curl https://openrouterapi.ru/v1/chat/completions \
  -H "Authorization: Bearer $OPENROUTERAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [
      {"role": "system", "content": "You are a concise assistant."},
      {"role": "user", "content": "Explain what an API gateway does in two sentences."}
    ]
  }'
Python
from openai import OpenAI

client = OpenAI(api_key="sk-ora-...", base_url="https://openrouterapi.ru/v1")

resp = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Explain what an API gateway does in two sentences."}],
)
print(resp.choices[0].message.content)
Node.js
import OpenAI from "openai";

const client = new OpenAI({ apiKey: process.env.OPENROUTERAPI_API_KEY, baseURL: "https://openrouterapi.ru/v1" });

const resp = await client.chat.completions.create({
  model: "gpt-5.5",
  messages: [{ role: "user", content: "Explain what an API gateway does in two sentences." }],
});
console.log(resp.choices[0].message.content);

To switch to Claude, Gemini or DeepSeek, change only the model field — for example claude-sonnet-4-6, gemini-3.5-flash or deepseek-v4-pro.

3. Stream tokens

Add "stream": true to receive server-sent events as the model writes. The final chunk includes token usage, which is what you are billed for.

Python
stream = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Write a haiku about the sea."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

4. Generate an image (async)

Image and video models are asynchronous. The generation endpoint returns a task_id; you then poll the task until it is completed.

cURL
curl https://openrouterapi.ru/v1/images/generations \
  -H "Authorization: Bearer $OPENROUTERAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-image-2", "prompt": "A lighthouse on a cliff at dawn, film photo", "size": "16:9", "resolution": "1k"}'

# => {"code":200,"data":[{"status":"submitted","task_id":"task_01..."}]}

curl https://openrouterapi.ru/v1/tasks/task_01... \
  -H "Authorization: Bearer $OPENROUTERAPI_API_KEY"

When status is completed, the response contains the image URLs. Result URLs are temporary, so download anything you want to keep.

5. Generate a video (async)

Python
import time, requests

API = "https://openrouterapi.ru/v1"
H = {"Authorization": "Bearer sk-ora-..."}

task = requests.post(f"{API}/videos/generations", headers=H, json={
    "model": "seedance-2.0",
    "prompt": "A paper boat drifting down a rainy street, cinematic, slow push-in",
    "duration": 5,
    "resolution": "720p",
}).json()["data"][0]["task_id"]

while True:
    r = requests.get(f"{API}/tasks/{task}", headers=H).json()["data"]
    if r["status"] in ("completed", "failed"):
        print(r)
        break
    time.sleep(5)

Video models are usually billed per second of output, so this 5-second 720p clip costs five times the per-second 720p rate shown on the Seedance 2.0 page.

Next steps

Found a problem in these docs? Email support@openrouterapi.ru.