openrouter-cli
openrouter-cli is a workspace CLI companion for openrouter-rs.
Current Scope
- OR-19: command bootstrap and config/profile resolution
- OR-20: discovery commands for models/providers/endpoints
- OR-21: management commands for API keys and guardrails
- OR-22: usage and billing commands with stable output contracts
Installation
Install from crates.io:
Install from local source:
Install prebuilt binaries from GitHub Releases:
VERSION=0.1.0
|
For macOS and Windows, use the matching target archive from the same release tag.
Config And Profile Convention
By default, config is loaded from:
$XDG_CONFIG_HOME/openrouter/profiles.toml, or$HOME/.config/openrouter/profiles.toml
You can override with:
--config <path>OPENROUTER_CLI_CONFIG
Config format:
= "default"
[]
= "sk-or-v1-..."
= "or-mgmt-..."
= "https://openrouter.ai/api/v1"
Resolution Priority
For api_key, management_key, and base_url:
- CLI flags (
--api-key,--management-key,--base-url) - Environment (
OPENROUTER_API_KEY,OPENROUTER_MANAGEMENT_KEY,OPENROUTER_BASE_URL) - Active profile values from config file
- Defaults (for
base_url:https://openrouter.ai/api/v1)
For profile selection:
--profileOPENROUTER_PROFILEdefault_profilein config"default"
Discovery Commands (OR-20)
openrouter-cli now supports discovery workflows:
models listwith optional filters:--category--supported-parameter
models show <model_id>models endpoints <model_id>providers list
Examples:
# List models in a category
# List models supporting tool-calling parameter
# Show one model
# Show endpoints for one model
# List providers
Management Commands (OR-21)
openrouter-cli supports management workflows:
keys list|create|get|update|deleteguardrails list|create|get|update|deleteguardrails assignments keys list|assign|unassignguardrails assignments members list|assign|unassign
Examples:
# List keys
# Create and update key
# Delete key (requires explicit confirmation)
# Update guardrail and clear allowlists
Usage And Billing Commands (OR-22)
Supported command groups:
credits showcredits charge --amount --sender --chain-idusage activity [--date YYYY-MM-DD]
Examples:
# Show total credits and usage
# Create Coinbase charge
# Query usage activity for a specific day (requires management key)
Output Contract
--output supports:
table(default)json
JSON output is wrapped with schema metadata for automation stability:
Error output in JSON mode follows:
CLI Live Smoke Tests
This repo includes an opt-in CLI live smoke suite (tests/live_smoke.rs) for real API verification.
Environment switches:
OPENROUTER_CLI_RUN_LIVE=1: enable live tests.OPENROUTER_CLI_RUN_LIVE_WRITE=1: also enable write-path lifecycle checks (create/delete keys and guardrails).
Required secrets:
OPENROUTER_API_KEY(read smoke)OPENROUTER_MANAGEMENT_KEY(usage activity and write smoke)
Local examples:
# Read-only live smoke
OPENROUTER_CLI_RUN_LIVE=1 \
OPENROUTER_API_KEY=... \
# Include write lifecycle smoke
OPENROUTER_CLI_RUN_LIVE=1 \
OPENROUTER_CLI_RUN_LIVE_WRITE=1 \
OPENROUTER_API_KEY=... \
OPENROUTER_MANAGEMENT_KEY=... \