OpenRouter
Call hundreds of models through one OpenAI-compatible endpoint, control which providers serve them, add fallbacks and spend limits, wire it into clients and a LiteLLM gateway, and clean up keys.
Scope: the OpenRouter hosted service: API, keys, routing, presets, BYOK, guardrails and data controls, caching, broadcast, limits. It cannot be installed or self-hosted, so there is no install workflow; the lifecycle is keys, credits and workspace settings. Out of scope: choosing a gateway (llm-gateway), running your own gateway (litellm, portkey, envoy-ai-gateway, kong-ai-gateway), provider accounts directly (cloud-llms).
Work through the steps in order. Load a reference only when a step names it. Docs were read on 2026-10-11; the model catalog and prices change daily, so list models from the API and never copy IDs or prices from examples.
Discover first
Read-only. Key values never print.
env | cut -d= -f1 | grep -iE 'openrouter|openai_(api|base)|anthropic_(base|auth)'
# Key valid? Shows limit, remaining credit, effective budget (no key echoed)
curl -fsS https://openrouter.ai/api/v1/key -H "Authorization: Bearer $OPENROUTER_API_KEY" \
| jq '.data | {label, limit, limit_remaining, usage_daily, usage_monthly, is_free_tier, effective_budget}'
# Models this key can use (text models by default), and one model's endpoints
curl -fsS https://openrouter.ai/api/v1/models -H "Authorization: Bearer $OPENROUTER_API_KEY" | jq -r '.data[].id' | head -20
curl -fsS "https://openrouter.ai/api/v1/models?output_modalities=all" | jq '.data | length'
curl -fsS "https://openrouter.ai/api/v1/models/<author>/<slug>/endpoints" | jq '.data.endpoints | length' # inspect one entry before filtering fields
Ask only what discovery cannot show: workloads, whether data may leave to third-party providers, monthly spend limit, who needs keys (people, CI, apps), and whether existing provider keys should be reused (BYOK).
Decision flow
- No key yet: create one with a credit limit. ->
references/setup-and-auth.md
- Any call fails: read
error.code and error.metadata.limit_source. -> references/troubleshooting.md
- Need predictable providers or latency:
provider object, sort, :nitro, :floor, order/only. -> references/routing-and-fallbacks.md
- Need failover across models:
models array (or fallbacks on /messages). -> references/routing-and-fallbacks.md
- Prompts are sensitive:
data_collection: "deny", zdr: true, guardrails, regional domains. -> references/data-controls.md
- Spending control for people, CI or agents: per-key limits, guardrail and workspace budgets. ->
references/limits-and-budgets.md
- Own provider contracts or rate limits: BYOK. ->
references/data-controls.md
- Several apps share one configuration: presets, caching, plugins. ->
references/features.md
- Agent or IDE client, or a gateway in front: ->
references/litellm-and-clients.md
- Traces and cost reporting: Broadcast or
/generation. -> references/observability.md
- Done with it:
references/teardown.md.
Rules
- Ask before spending or retaining. Adding credits, auto top-up, BYOK keys, guardrails and ZDR changes need approval. A key with no limit can spend the whole balance including auto top-ups.
- Secrets never touch output. Read
OPENROUTER_API_KEY from the environment or a 0600 file. Management keys (admin-only, cannot call completions) stay separate and carry an expiry.
- Limit every key. Set a credit limit with a reset interval per app, environment and agent. One key per workload.
- Pin what you can. Model IDs get renamed and retired; pass explicit IDs, avoid
latest aliases and routers like openrouter/auto where reproducibility matters, and check the model field of responses to see what served the call.
- Be explicit about data. Default routing may use providers that retain or train on prompts. Set
data_collection, zdr or a guardrail before sending anything sensitive.
- Route with intent. Setting
order or sort turns off default price-weighted load balancing; allow_fallbacks: false means a provider outage is an error.
- Never hardcode prices or free quotas. Read them from
/models, the endpoint listing and GET /api/v1/key.
- Verify features per model. Tools, structured outputs and reasoning differ by model and provider; use
require_parameters: true when a request depends on them.
Workflows
First request
Make routing and fallbacks predictable
Lock down data and spend
Connect clients
Observe and review
Tear down
Verify before done
Reference index
references/setup-and-auth.md: account, keys, headers, SDKs, management keys.
references/api-and-models.md: endpoints, model IDs and variants, parameters, errors.
references/routing-and-fallbacks.md: provider object, sort, models, routers.
references/data-controls.md: ZDR, data collection, guardrails, BYOK, regions.
references/limits-and-budgets.md: credit, budget and rate limits, workspaces.
references/features.md: presets, response caching, structured outputs, tools, plugins.
references/observability.md: Broadcast, generation stats, router metadata.
references/litellm-and-clients.md: LiteLLM, Claude Code, SDKs.
references/teardown.md: keys, BYOK, presets, credits.
references/troubleshooting.md: symptoms, causes and fixes.
Companion skills
Install any with npx skills add ScaleDockHQ/llm-skills --skill <name>.
llm-gateway: choose between OpenRouter, LiteLLM, Portkey, Envoy and Kong.
litellm: self-hosted gateway that can front OpenRouter.
cloud-llms: direct provider accounts and cost model.
llm-clients: pointing agents, IDEs and SDKs at a gateway.
llm-observability: Langfuse and other trace sinks.
1---2name: openrouter3description: Use OpenRouter, a hosted gateway with one OpenAI-compatible API for hundreds of models, provider routing, fallbacks, presets, BYOK and spend controls. Use when asked about OpenRouter, openrouter.ai, OPENROUTER_API_KEY, `openrouter/` LiteLLM models, provider order or sort, `models` fallbacks, `:nitro` or `:free`, `@preset/`, guardrails, ZDR, or 402, 403, 429 errors. No self-hosting; for a self-run gateway use litellm, for the choice use llm-gateway.4license: MIT5compatibility: Any OS with bash, curl and jq. Needs an OpenRouter API key in an env var or 0600 file and credits for paid models. Creating keys, adding credits, BYOK keys, guardrails and ZDR changes need the user's explicit approval.6metadata:7 source: https://skillmd.com/skills/scaledockhq/openrouter8 author: ScaleDockHQ9 version: "0.1.0"10---1112# OpenRouter1314Call hundreds of models through one OpenAI-compatible endpoint, control which providers serve them, add fallbacks and spend limits, wire it into clients and a LiteLLM gateway, and clean up keys.1516**Scope:** the OpenRouter hosted service: API, keys, routing, presets, BYOK, guardrails and data controls, caching, broadcast, limits. It cannot be installed or self-hosted, so there is no install workflow; the lifecycle is keys, credits and workspace settings. Out of scope: choosing a gateway (`llm-gateway`), running your own gateway (`litellm`, `portkey`, `envoy-ai-gateway`, `kong-ai-gateway`), provider accounts directly (`cloud-llms`).1718Work through the steps in order. Load a reference only when a step names it. Docs were read on 2026-10-11; the model catalog and prices change daily, so list models from the API and never copy IDs or prices from examples.1920## Discover first2122Read-only. Key values never print.2324```bash25env | cut -d= -f1 | grep -iE 'openrouter|openai_(api|base)|anthropic_(base|auth)'2627# Key valid? Shows limit, remaining credit, effective budget (no key echoed)28curl -fsS https://openrouter.ai/api/v1/key -H "Authorization: Bearer $OPENROUTER_API_KEY" \29 | jq '.data | {label, limit, limit_remaining, usage_daily, usage_monthly, is_free_tier, effective_budget}'3031# Models this key can use (text models by default), and one model's endpoints32curl -fsS https://openrouter.ai/api/v1/models -H "Authorization: Bearer $OPENROUTER_API_KEY" | jq -r '.data[].id' | head -2033curl -fsS "https://openrouter.ai/api/v1/models?output_modalities=all" | jq '.data | length'34curl -fsS "https://openrouter.ai/api/v1/models/<author>/<slug>/endpoints" | jq '.data.endpoints | length' # inspect one entry before filtering fields35```3637Ask only what discovery cannot show: workloads, whether data may leave to third-party providers, monthly spend limit, who needs keys (people, CI, apps), and whether existing provider keys should be reused (BYOK).3839## Decision flow40411. **No key yet:** create one with a credit limit. -> `references/setup-and-auth.md`422. **Any call fails:** read `error.code` and `error.metadata.limit_source`. -> `references/troubleshooting.md`433. **Need predictable providers or latency:** `provider` object, `sort`, `:nitro`, `:floor`, `order`/`only`. -> `references/routing-and-fallbacks.md`444. **Need failover across models:** `models` array (or `fallbacks` on `/messages`). -> `references/routing-and-fallbacks.md`455. **Prompts are sensitive:** `data_collection: "deny"`, `zdr: true`, guardrails, regional domains. -> `references/data-controls.md`466. **Spending control for people, CI or agents:** per-key limits, guardrail and workspace budgets. -> `references/limits-and-budgets.md`477. **Own provider contracts or rate limits:** BYOK. -> `references/data-controls.md`488. **Several apps share one configuration:** presets, caching, plugins. -> `references/features.md`499. **Agent or IDE client, or a gateway in front:** -> `references/litellm-and-clients.md`5010. **Traces and cost reporting:** Broadcast or `/generation`. -> `references/observability.md`5111. **Done with it:** `references/teardown.md`.5253## Rules5455- **Ask before spending or retaining.** Adding credits, auto top-up, BYOK keys, guardrails and ZDR changes need approval. A key with no limit can spend the whole balance including auto top-ups.56- **Secrets never touch output.** Read `OPENROUTER_API_KEY` from the environment or a 0600 file. Management keys (admin-only, cannot call completions) stay separate and carry an expiry.57- **Limit every key.** Set a credit limit with a reset interval per app, environment and agent. One key per workload.58- **Pin what you can.** Model IDs get renamed and retired; pass explicit IDs, avoid `latest` aliases and routers like `openrouter/auto` where reproducibility matters, and check the `model` field of responses to see what served the call.59- **Be explicit about data.** Default routing may use providers that retain or train on prompts. Set `data_collection`, `zdr` or a guardrail before sending anything sensitive.60- **Route with intent.** Setting `order` or `sort` turns off default price-weighted load balancing; `allow_fallbacks: false` means a provider outage is an error.61- **Never hardcode prices or free quotas.** Read them from `/models`, the endpoint listing and `GET /api/v1/key`.62- **Verify features per model.** Tools, structured outputs and reasoning differ by model and provider; use `require_parameters: true` when a request depends on them.6364## Workflows6566### First request6768- [ ] Create a key with a credit limit; store it in a 0600 file -> `references/setup-and-auth.md`.69- [ ] Run the discovery key check, then one chat call with an explicit model ID.70- [ ] Confirm `model` and provider in the response, and `usage` fields.7172### Make routing and fallbacks predictable7374- [ ] Choose `sort` or `order`, decide `allow_fallbacks`, add `models` fallbacks -> `references/routing-and-fallbacks.md`.75- [ ] Add `require_parameters: true` for tool calls or `response_format`.7677### Lock down data and spend7879- [ ] Choose a data posture (ZDR, `data_collection`, regional domain) -> `references/data-controls.md`.80- [ ] Set per-key limits and, for teams, guardrail or workspace budgets -> `references/limits-and-budgets.md`.8182### Connect clients8384- [ ] Base URL `https://openrouter.ai/api/v1` for OpenAI-style clients; `https://openrouter.ai/api` for Anthropic-style clients -> `references/litellm-and-clients.md`.85- [ ] Smoke test streaming and a tool call through the client.8687### Observe and review8889- [ ] Fetch cost by generation id, or enable Broadcast -> `references/observability.md`.9091### Tear down9293- [ ] Delete keys, BYOK keys and presets you no longer need; confirm by listing -> `references/teardown.md`.9495## Verify before done9697- [ ] `GET /api/v1/key` shows the expected limit and no unexpected `effective_budget`.98- [ ] A real request succeeded and its `model` and provider match the intent.99- [ ] Data posture is explicit, and no key was printed or committed.100- [ ] A fallback or failure test was run when fallbacks were configured.101102## Reference index103104- `references/setup-and-auth.md`: account, keys, headers, SDKs, management keys.105- `references/api-and-models.md`: endpoints, model IDs and variants, parameters, errors.106- `references/routing-and-fallbacks.md`: provider object, sort, `models`, routers.107- `references/data-controls.md`: ZDR, data collection, guardrails, BYOK, regions.108- `references/limits-and-budgets.md`: credit, budget and rate limits, workspaces.109- `references/features.md`: presets, response caching, structured outputs, tools, plugins.110- `references/observability.md`: Broadcast, generation stats, router metadata.111- `references/litellm-and-clients.md`: LiteLLM, Claude Code, SDKs.112- `references/teardown.md`: keys, BYOK, presets, credits.113- `references/troubleshooting.md`: symptoms, causes and fixes.114115## Companion skills116117Install any with `npx skills add ScaleDockHQ/llm-skills --skill <name>`.118119- `llm-gateway`: choose between OpenRouter, LiteLLM, Portkey, Envoy and Kong.120- `litellm`: self-hosted gateway that can front OpenRouter.121- `cloud-llms`: direct provider accounts and cost model.122- `llm-clients`: pointing agents, IDEs and SDKs at a gateway.123- `llm-observability`: Langfuse and other trace sinks.