

OpenRouter API Guide: One API for Top AI Models
Getting started with the OpenRouter API: keys, your first request, model slugs and variants, streaming, rate limits and fallbacks — plus multimodal options.
One API key, one endpoint, hundreds of language models. That is the pitch of the OpenRouter API — and because it speaks the OpenAI schema, most apps can adopt it by changing a base URL. This guide takes you from zero to production-ready calls.
What you will learn:
-
Create a key and make your first request with curl, Python and TypeScript
-
Read model slugs (
vendor/model) and use variants like:free,:nitroand:floor -
Handle streaming, rate limits and multi-model fallbacks
-
Know what the platform costs — and when a multimodal gateway is a better fit

How OpenRouter works
The model catalog
OpenRouter lists hundreds of models from OpenAI, Anthropic, Google, Meta, Mistral, DeepSeek, Qwen and more, each with per-token pricing and context specs on its model page [1].
How a request flows
Your request hits the unified endpoint, the router picks an upstream provider for that model (many models have several), executes, and normalizes the response to the OpenAI format. Provider selection balances price and availability by default [2].
What it costs
Inference is billed at provider list price with no markup; the platform charges 5.5% (min $0.80) when you buy credits, and free models are capped at 50 requests/day (1,000/day once you have purchased $10+ of credits) [3].
Quick start
1. Create an account and key
Sign up, buy a small credit pack (unlocks the higher free-tier limit too), and mint a key from the dashboard. Keys are bearer tokens — keep them server-side.
2. First request with curl
curl https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.2",
"messages": [{"role": "user", "content": "Hello from the unified API"}]
}'
3. Python and TypeScript
The official OpenAI SDKs work as-is:
from openai import OpenAI
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key="sk-or-...",
)
resp = client.chat.completions.create(
model="google/gemini-2.5-pro",
messages=[{"role": "user", "content": "Three taglines for a coffee app"}],
)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://openrouter.ai/api/v1",
apiKey: process.env.OPENROUTER_API_KEY,
});
Model slugs and variants
Reading a slug
Model IDs follow vendor/model-name, e.g. anthropic/claude-sonnet-4.5 or deepseek/deepseek-chat. The exact string on the model page is the exact string the API expects.
The suffix variants
| Variant | Effect |
|---|---|
:free | Free capacity, hard daily caps, no SLA |
:nitro | Sort providers by throughput — pay for speed |
:floor | Sort providers by price — cheapest first |
Variants are routing hints, not different weights — same model, different provider selection [2].
Picking a model
Filter the catalog by price, context window and modality, then benchmark on your own task. The pragmatic ladder: prototype on a :free variant, ship on a mid-tier model, keep a frontier model for the hard 10% of requests.
Production concerns
Streaming
Set "stream": true and consume server-sent events — identical to the OpenAI streaming contract, so existing streaming UI code works unchanged.
Rate limits and retries
Limits scale with your credit balance rather than fixed tiers; 429s should trigger exponential backoff. For free models, budget around the 50/1,000-per-day caps [3].
Fallbacks
Pass a ranked models array and the router retries the next model on errors or rate limits server-side [4]:
{
"model": "openai/gpt-5.2",
"models": ["anthropic/claude-sonnet-4.5", "deepseek/deepseek-chat"],
"messages": [{ "role": "user", "content": "..." }]
}
When you need more than language models
OpenRouter unifies text. The moment your roadmap says "generate a product image" or "add a video clip", you are back to per-vendor integrations — unless your gateway covers those modalities natively.
A unified API that includes media models
APIMart applies the same one-key pattern to 500+ models across chat, image (GPT-Image-2), video (Sora 2, Kling, Veo) and audio (Suno).
Pricing below list instead of at list
Models are offered at roughly 20% under official prices, with per-model original-vs-discounted rates published on the pricing page — no separate fee math needed.
Drop-in for the same code
Endpoints are OpenAI-compatible, so the quick-start above works with a different base URL and key. Your model registry and fallback logic carry over untouched.
Access 500+ AI Models with One API Key
Chat, image, video and audio models behind a single OpenAI-compatible API — transparent pay-as-you-go pricing at about 20% below official rates.
Start BuildingRecap
Point an OpenAI SDK at the unified endpoint, reference models by vendor/model slug, use :floor or :nitro when cost or speed matters, add a models fallback array before production, and remember the real cost is list price plus the 5.5% top-up fee [3]. If your app needs images, video or audio too, start with a gateway that already covers them.
Choose the model you want in the model marketplace
Try chat, image and video models in the APIMart model marketplace, and experience model capabilities quickly with one unified API.
