How to hit the OpenRouter API

OpenRouter at https://openrouter.ai/api/v1 routes one OpenAI-compatible API to hundreds of models from many providers. Model ids are provider/model.

Authentication

Get a key at openrouter.ai. Send it as Authorization: Bearer <key>. Listing models needs no key. In the examples it's written {{OPENROUTER_API_KEY}}.

Full reference: https://openrouter.ai/docs/api-reference/overview

List models

No key needed. Pricing is per token, in USD.

curl https://openrouter.ai/api/v1/models
Run in PostTaco
Example response (trimmed)
{
  "data": [
    {
      "id": "qwen/qwen3.8-max-prime",
      "canonical_slug": "qwen/qwen3.8-max-prime-20260923",
      "hugging_face_id": null,
      "name": "Qwen: Qwen3.8 Max Prime",
      "created": 1790191228,
      "description": "Qwen3.8 Max Prime is a higher-throughput variant of Qwen3.8 Max from Alibaba's Qwen team, served as a separate SKU at a higher price point. It accepts text, image, and video...",
      "context_length": 1000000,
      "architecture": {
        "modality": "text+image+video->text",
        "input_modalities": [
          "text",
          "image"
        ],
        "output_modalities": [
          "text"
        ],
        "tokenizer": "Qwen",
        "instruct_type": null
      },
      "pricing": {
        "prompt": "0.000004",
        "completion": "0.000012",
        "input_cache_read": "0.0000005"
      },
      "top_provider": {
        "context_length": 1000000,
        "max_completion_tokens": 131072,
        "is_moderated": false
      },
      "per_request_limits": null,
      "supported_parameters": [
        "frequency_penalty",
        "include_reasoning"
      ],
      "default_parameters": {},
      "supported_voices": null,
      "knowledge_cutoff": null
    },
    {
      "id": "stealth/space-bunny-alpha",
      "canonical_slug": "stealth/space-bunny-alpha",
      "hugging_face_id": null,
      "name": "Space Bunny Alpha",
      "created": 1790174884,
      "description": "Space Bunny Alpha is an anonymous large model with blazing-fast inference, strong coding capabilities and native multimodal input support. It delivers adjustable reasoning effort, and a 1M-token context window. Space...",
      "context_length": 1000000,
      "architecture": {
        "modality": "text+image+video->text",
        "input_modalities": [
          "text",
          "image"
        ],
        "output_modalities": [
          "text"
        ],
        "tokenizer": "Other",
        "instruct_type": null
      },
      "pricing": {
        "prompt": "0",
        "completion": "0"
      },
      "top_provider": {
        "context_length": 1000000,
        "max_completion_tokens": 524288,
        "is_moderated": false
      },
      "per_request_limits": null,
      "supported_parameters": [
        "include_reasoning",
        "max_tokens"
      ],
      "default_parameters": {},
      "supported_voices": null,
      "knowledge_cutoff": null
    }
  ],
  "total_count": 457,
  "links": {
    "next": null
  }
}

Chat completion

Swap model for any id from the list.

curl https://openrouter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer {{OPENROUTER_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-oss-120b", "messages": [{"role": "user", "content": "What is a 429 status code?"}]}'
Run in PostTaco

Check your key

Usage and limits for the key.

curl https://openrouter.ai/api/v1/key \
  -H "Authorization: Bearer {{OPENROUTER_API_KEY}}"
Run in PostTaco