/openrouter:openrouterfrom openrouter
Drives the @mrgoonie/openrouter CLI to call OpenRouter API for chat completions, embeddings, rerank, video generation, key management, and model browsing from shell or scripts.
Ships in openrouter. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Practical instructions for driving openrouter (the @mrgoonie/openrouter-cli binary) from Claude Code. This skill handles CLI invocation, JSON envelopes, config resolution, and agent-safe workflows. Does NOT handle: direct HTTP calls to openrouter.ai, non-OpenRouter providers, or CLI source-code changes (use repo docs for that).
sk-or-v1-… as secret.auth set-key or env var — do NOT write it into tracked files.Pick one:
brew install openrouter/tap/openrouter # macOS / Linux
curl -fsSL https://raw.githubusercontent.com/mrgoonie/openrouter-cli/main/install.sh | sh
npm install -g @mrgoonie/openrouter-cli # npm
Verify: openrouter --version && openrouter --help.
openrouter auth login (PKCE flow, stores key in OS keychain).openrouter auth set-key sk-or-v1-....export OPENROUTER_API_KEY=sk-or-v1-....credits, keys, guardrails, org) need a separate key:
export OPENROUTER_MANAGEMENT_KEY=sk-or-v1-... OR openrouter auth set-key <key> --management.Check resolution: openrouter auth status and openrouter config doctor --json.
--api-key, --model, --base-url, --timeout)OPENROUTER_API_KEY, OPENROUTER_MANAGEMENT_KEY, OPENROUTER_BASE_URL).env file (searched from cwd upward)~/.config/openrouter/config.toml)Set persistent defaults: openrouter config set defaults.model openai/gpt-4o.
--json to every command so output is a stable envelope:
{"schema_version":"1","success":true,"data":{...},"error":null,"meta":{"request_id":"gen-...","elapsed_ms":312}}
--no-stream when you need a single blocking response (safe for parsing).--output ndjson for streaming where each line is a parseable JSON object.$? after every call — exit codes are stable across patch versions.| Code | Meaning | Handling |
|---|---|---|
| 0 | Success | parse data |
| 1 | Unexpected error | log error.message, retry once |
| 2 | Bad flags / args | fix invocation, do NOT retry |
| 64 | API key not set | prompt user for auth set-key |
| 65 | Unauthorized (401) | key invalid → rotate |
| 66 | Forbidden (403) | wrong scope (need --management?) |
| 67 | Not found (404) | check model/ID slug |
| 68 | Insufficient credits (402) | openrouter credits show |
| 69 | Rate limited (429) | backoff; client already retries 3× w/ exp |
| 70 | Server error (5xx) | retry with jitter |
| 71 | Request timeout | raise --timeout |
| 72 | Unexpected API response shape | report bug |
| 73 | Async video job failed | inspect error in envelope |
openrouter chat send "Summarize the following." \
--model openai/gpt-4o --json --no-stream <<< "$(cat document.txt)"
Parse data.choices[0].message.content. Log meta.request_id for tracing.
openrouter chat send "Write a haiku about Bun" \
--model openai/gpt-4o --output ndjson
Consume line-by-line; each token chunk is one JSON object.
openrouter embeddings create "hello world" \
--model openai/text-embedding-3-small --json
openrouter rerank create \
--query "What is Bun?" \
--documents "Bun is a JS runtime." --documents "Python is a language." \
--model cohere/rerank-english-v3.0 --json
openrouter models list --json | jq '.data[] | select(.pricing.prompt=="0") | .id'
openrouter credits show --json
openrouter keys list --json
openrouter keys create --name "ci-bot" --limit 5 --json
JOB=$(openrouter video create "cat surfing" --model some/video-model --json | jq -r .data.id)
openrouter video wait "$JOB" --json # blocks until terminal state
openrouter video download "$JOB" -o out.mp4
video wait exits 73 on failure/cancel — always check $?.
openrouter config doctor --json # shows resolved sources per key
openrouter auth whoami --json # live API check
--json.$? — a 200-shaped body with success:false still means failure.chat send without --model — no default unless set in TOML config.--timeout — default may be too short for large outputs.credits/keys/guardrails — exit 64/66; needs --management key.| User intent | Command |
|---|---|
| "chat with gpt-4o" | openrouter chat send "<msg>" --model openai/gpt-4o --json |
| "stream a response" | add --output ndjson (drop --no-stream) |
| "what models are free?" | openrouter models list --json | jq '.data[] | select(.pricing.prompt=="0")' |
| "embed this text" | openrouter embeddings create "<text>" --model openai/text-embedding-3-small --json |
| "how many credits left?" | openrouter credits show --json (needs management key) |
| "set default model" | openrouter config set defaults.model <slug> |
| "why is my key not working?" | openrouter config doctor --json && openrouter auth whoami |
| "generate a video" | see workflow 7 (create → wait → download) |
| "list my api keys" | openrouter keys list --json (needs management key) |
| "rerank these docs" | see workflow 4 |
references/command-reference.md — full command/flag matrix.references/agent-json-mode.md — JSON envelope schema + NDJSON parsing patterns.references/chat-workflows.md — multi-turn, stdin piping, tool calling recipes.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub mrgoonie/openrouter-cli --plugin openrouterOther plugins' skills for the same job