### Installation Commands Source: https://github.com/aaronjmars/openroutercli/blob/main/README.md Methods to install or run the OpenRouter CLI using npm, npx, or source code. ```bash npm install -g @aaronjmars/openroutercli ``` ```bash npx -p @aaronjmars/openroutercli openrouter --help ``` ```bash git clone https://github.com/aaronjmars/openroutercli && cd openroutercli && npm link ``` -------------------------------- ### Accessing CLI Help Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Use the --help flag with any command to view available options and usage instructions. ```bash openrouter --help openrouter chat --help openrouter models --help openrouter keys --help openrouter guardrails --help # ...etc ``` -------------------------------- ### Basic CLI Usage Source: https://github.com/aaronjmars/openroutercli/blob/main/README.md Common commands for authenticating, chatting, and querying model data. ```bash openrouter login # OAuth in the browser openrouter chat "say hi" -m openai/gpt-4o-mini # streaming chat openrouter --json models --filter sonnet | jq '.data[].id' # pipeable JSON openrouter credits # what's left in the tank ``` -------------------------------- ### Model and Provider Discovery Source: https://github.com/aaronjmars/openroutercli/blob/main/README.md Commands to list, filter, and inspect available models, endpoints, and providers. ```bash # Discovery openrouter models --filter claude --sort prompt openrouter models show anthropic/claude-sonnet-4.5 openrouter models endpoints anthropic/claude-sonnet-4.5 --sort throughput --best openrouter providers ``` -------------------------------- ### Select best provider variant Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Query model endpoints to find the cheapest or highest-throughput provider before executing a request. ```bash # Cheapest provider for a given model openrouter --json models endpoints openai/gpt-4o-mini --sort prompt --best \ | jq -r '.data.endpoints[0] | "\(.provider_name): $\(.pricing.prompt)/tok"' # Highest throughput provider openrouter --json models endpoints anthropic/claude-sonnet-4.5 --sort throughput --best \ | jq -r '.data.endpoints[0] | "\(.provider_name) @ \(.throughput_last_30m.p50) tok/s"' ``` -------------------------------- ### Cut a new release Source: https://github.com/aaronjmars/openroutercli/blob/main/RELEASING.md Use these commands to bump the version in package.json, create a git tag, and push to the repository to trigger the automated release process. ```bash npm version patch # or: minor / major git push --follow-tags ``` -------------------------------- ### Manage OpenRouter API keys Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Use these commands to list, create, retrieve, update, and delete API keys. Note that the full secret is only displayed upon creation. ```bash openrouter keys list openrouter keys create "agent key" --limit 25 --limit-reset monthly openrouter keys get openrouter keys update --name "renamed" --limit 50 openrouter keys update --disabled openrouter keys delete ``` -------------------------------- ### Configure guardrails, workspaces, and organization members Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Commands for managing security guardrails, workspace environments, and organizational membership. ```bash openrouter guardrails list openrouter guardrails create "no-paid-models" --allowed-providers "" --enforce-zdr openrouter guardrails update --limit-usd 10 --reset-interval daily openrouter guardrails assign-key openrouter guardrails delete openrouter workspaces list openrouter workspaces create "staging" --slug staging --default-text-model openai/gpt-4o-mini openrouter workspaces add-members [...] openrouter workspaces delete openrouter org members ``` -------------------------------- ### Model discovery and pricing commands Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Commands to browse, filter, and inspect model catalog details and provider endpoints. ```bash # Browse / filter / sort the catalog openrouter models # all (~370) openrouter models --filter sonnet --sort prompt # cheapest first openrouter models --free # only :free models openrouter models --output-modalities image # image-output models openrouter models --supported tools # filter by capability # Full detail for one model: pricing breakdown, architecture, supported params openrouter models show anthropic/claude-sonnet-4.5 # Compare provider variants for one model - find the best one openrouter models endpoints anthropic/claude-sonnet-4.5 --sort throughput --best openrouter models endpoints openai/gpt-4o-mini --sort latency openrouter models endpoints openai/gpt-4o-mini --sort prompt # Supporting metadata openrouter providers # all providers openrouter embed models # embedding models openrouter video models # video gen models openrouter zdr # ZDR-eligible endpoints ``` -------------------------------- ### Account and usage management commands Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Commands to check account balance, usage statistics, and retrieve request metadata. ```bash openrouter credits # total balance + total usage openrouter whoami # label, daily/weekly/monthly usage, rate limit openrouter generation gen-1234567890 # full per-request metadata + cost openrouter generation gen-1234567890 --content # + the input/output content # Activity (management key required) - daily aggregates per endpoint openrouter activity --date 2026-04-28 openrouter activity --api-key-hash ``` -------------------------------- ### Authenticate and Manage CLI Sessions Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Commands for logging in, managing API keys, and verifying current session status. ```bash # Browser OAuth (PKCE) - recommended for humans openrouter login # Save an existing key non-interactively openrouter login --key sk-or-v1-... echo "sk-or-v1-..." | openrouter login --stdin openrouter login --no-browser # SSH / headless - prints URL, you open it # Inspect / forget openrouter whoami openrouter logout ``` -------------------------------- ### Resource Management Source: https://github.com/aaronjmars/openroutercli/blob/main/README.md Commands for managing API keys, guardrails, and workspaces. Requires a management-enabled API key. ```bash # Management (provisioning key required) openrouter keys create "agent-key" --limit 25 --limit-reset monthly openrouter guardrails create "no-paid-models" --allowed-providers "" --enforce-zdr openrouter workspaces create "staging" --slug staging --default-text-model openai/gpt-4o-mini ``` -------------------------------- ### Authentication and Login Source: https://github.com/aaronjmars/openroutercli/blob/main/README.md Commands for authenticating with OpenRouter using either browser-based OAuth or manual API key entry. ```bash # Browser OAuth login (recommended) openrouter login # Manual key entry (and management/provisioning key) openrouter login --key sk-or-v1-... openrouter login --management --key sk-or-v1-... ``` -------------------------------- ### Usage and Activity Monitoring Source: https://github.com/aaronjmars/openroutercli/blob/main/README.md Commands to check account credits, identity, and specific generation or activity logs. ```bash # Spend / runs openrouter credits openrouter whoami openrouter generation gen-1234567890 --content openrouter activity --date 2026-04-28 --api-key-hash ``` -------------------------------- ### Inference commands for OpenRouter CLI Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Commands for performing chat, tool calling, reasoning, and multimodal tasks using various models. ```bash # Streaming chat (default in TTY) openrouter chat "Write a haiku about caching" -m anthropic/claude-sonnet-4.5 # One-shot, JSON for scripts openrouter --json chat "Reply: ok" -m openai/gpt-4o-mini --no-stream # From stdin echo "summarize this" | openrouter chat -m openai/gpt-4o-mini # Multimodal openrouter chat "What's in this picture?" -m google/gemini-2.5-flash --image ./photo.jpg openrouter chat "Caption this" -m openai/gpt-4o --image https://example.com/cat.png # Strict structured output (JSON schema, strict mode) openrouter chat "Pick 3 fruits" -m openai/gpt-4o-mini \ --schema '{"type":"object","properties":{"fruits":{"type":"array","items":{"type":"string"}}},"required":["fruits"],"additionalProperties":false}' # Tool calling openrouter chat "What is 2+2?" -m openai/gpt-4o-mini \ --tool '{"name":"add","parameters":{"type":"object","properties":{"a":{"type":"number"},"b":{"type":"number"}},"required":["a","b"]}}' \ --tool-choice required --raw # Reasoning effort openrouter chat "tricky question" -m anthropic/claude-sonnet-4.5 --reasoning high # Provider routing / fallback models openrouter chat "..." -m primary/model --models fallback1/m,fallback2/m openrouter chat "..." -m anthropic/claude-sonnet-4.5 --provider '{"order":["Google","Anthropic"]}' # Interactive REPL openrouter chat -i -m openrouter/auto # Inside the REPL: /model , /reset, /exit # Anthropic-format and OpenAI Responses API are also available openrouter messages "..." -m anthropic/claude-sonnet-4.5 openrouter responses "..." -m openai/gpt-4o-mini # Embeddings, rerank, TTS, video openrouter embed -m openai/text-embedding-3-small "hello" "world" openrouter rerank -m cohere/rerank-v3.5 --query "italian food" -d pizza -d sushi -d pasta openrouter speech "Hello there" -m elevenlabs/eleven-turbo-v2 --voice alloy -o out.mp3 openrouter video create "a sunset over mountains" -m google/veo-3 openrouter video wait && openrouter video download -o out.mp4 ``` -------------------------------- ### Implement fail-fast error handling Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Check the exit status of an OpenRouter command to handle API failures immediately. ```bash if ! openrouter --json chat "..." -m model > /tmp/r.json; then echo "API call failed (exit $?)" >&2 exit 1 fi ``` -------------------------------- ### openrouter models Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Commands for discovering and filtering available models, checking pricing, and viewing provider endpoints. ```APIDOC ## openrouter models ### Description Commands for discovering and filtering available models, checking pricing, and viewing provider endpoints. ### Subcommands - **openrouter models** - List all available models. - **openrouter models show [model_id]** - Show full details for a specific model. - **openrouter models endpoints [model_id]** - Compare provider variants for a model. ``` -------------------------------- ### Chat and Multimodal Interactions Source: https://github.com/aaronjmars/openroutercli/blob/main/README.md Commands for sending prompts to models, including streaming, image input, and structured JSON output. ```bash # Streaming chat openrouter chat "Write a haiku about caching" -m anthropic/claude-sonnet-4.5 # Multimodal openrouter chat "What's in this picture?" -m google/gemini-2.5-flash --image ./photo.jpg # Strict JSON output openrouter chat "List 3 fruits" -m openai/gpt-4o-mini \ --schema '{"type":"object","properties":{"fruits":{"type":"array","items":{"type":"string"}}},"required":["fruits"]}' # Tool calling openrouter chat "What is 2+2?" -m openai/gpt-4o-mini \ --tool @calc.json --tool-choice required --raw ``` -------------------------------- ### Execute raw API requests Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Use the request command to interact with endpoints not covered by specific subcommands, supporting custom headers, bodies, and binary output. ```bash openrouter request GET /credits openrouter request POST /chat/completions --body @body.json openrouter request POST /chat/completions --body - < body.json # stdin openrouter request GET /models --query category=programming --query supported_parameters=tools openrouter request POST /audio/speech --body @speech.json --binary out.mp3 openrouter request GET /key --header "X-Custom: value" ``` -------------------------------- ### Check spend on a specific key Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Retrieve usage and limit information for a specific API key hash. ```bash openrouter --json keys get | jq '.data | {usage, usage_daily, limit_remaining}' ``` -------------------------------- ### Raw API Requests Source: https://github.com/aaronjmars/openroutercli/blob/main/README.md Directly interact with any OpenRouter API endpoint using the request command. ```bash # Raw escape hatch - call any endpoint openrouter request POST /chat/completions --body @body.json openrouter request GET /endpoints/zdr ``` -------------------------------- ### Pipe OpenRouter CLI output to jq Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Use jq to parse and filter JSON output from various OpenRouter CLI commands. ```bash openrouter --json models --filter sonnet | jq -r '.data[].id' openrouter --json chat "Say hi" -m openrouter/auto | jq -r '.choices[0].message.content' openrouter --json credits | jq '.data.total_credits - .data.total_usage' ``` -------------------------------- ### openrouter generation Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Retrieves metadata and cost information for a specific generation request. ```APIDOC ## openrouter generation [id] ### Description Retrieves full per-request metadata and cost for a specific generation ID. ### Options - **--content** (flag) - Include the input/output content in the response. ``` -------------------------------- ### openrouter chat Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Sends a chat prompt to a specified model. Supports streaming, JSON output, multimodal inputs, structured output schemas, and tool calling. ```APIDOC ## openrouter chat ### Description Sends a chat prompt to a specified model. Supports streaming, JSON output, multimodal inputs, structured output schemas, and tool calling. ### Usage `openrouter chat [prompt] -m [model_id] [options]` ### Options - **--json** (flag) - Output parsed JSON to stdout instead of streaming. - **--no-stream** (flag) - Disable streaming output. - **--image** (path/url) - Path or URL to an image for multimodal models. - **--schema** (json) - JSON schema for strict structured output. - **--tool** (json) - Tool definition for tool calling. - **--reasoning** (string) - Set reasoning effort (e.g., 'high'). - **--provider** (json) - Specify provider routing order. ``` -------------------------------- ### Save generation ID for audit Source: https://github.com/aaronjmars/openroutercli/blob/main/SKILL.md Capture the generation ID from a chat response to perform follow-up audits later. ```bash out=$(openrouter --json chat "..." -m openai/gpt-4o-mini) gen_id=$(echo "$out" | jq -r '.id') echo "$out" | jq -r '.choices[0].message.content' # ...later, after ~30s... openrouter generation "$gen_id" --content ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.