openrouter-cli
openrouter-cli is the workspace CLI companion for openrouter-rs.
It currently focuses on four areas:
- profile/config resolution
- model and provider discovery
- API-key and guardrail management
- credits, billing, and usage activity
The implementation lives in crates/openrouter-cli/src, and the crate currently publishes as 0.1.1.
Install
From crates.io:
From this workspace:
Prebuilt GitHub release archives follow the openrouter-cli-v<version> tag naming:
VERSION=0.1.1
|
For macOS and Windows, use the matching artifact from the same release tag.
Command Surface
profile show
config show|path
models list|show|endpoints
providers list
credits show|charge
keys list|create|get|update|delete
guardrails list|create|get|update|delete
guardrails assignments keys list|assign|unassign
guardrails assignments members list|assign|unassign
usage activity
Auth expectations by command group:
models,providers,credits show,credits charge: API keykeys,guardrails,usage activity: management keyprofile,config: no API call required
Config And Resolution Order
Default config path:
$XDG_CONFIG_HOME/openrouter/profiles.toml, or$HOME/.config/openrouter/profiles.toml
Overrides:
--config <path>OPENROUTER_CLI_CONFIG
Profile config format:
= "default"
[]
= "sk-or-v1-..."
= "or-mgmt-..."
= "https://openrouter.ai/api/v1"
Resolution order:
- Flags:
--api-key,--management-key,--base-url - Environment:
OPENROUTER_API_KEY,OPENROUTER_MANAGEMENT_KEY,OPENROUTER_BASE_URL - Profile values from the selected config profile
- Default base URL:
https://openrouter.ai/api/v1
Profile selection order:
--profileOPENROUTER_PROFILEdefault_profilein config"default"
Useful inspection commands:
Discovery Workflows
Examples:
# List models
# Filter by category
# Filter by supported parameter
# Show one model
# Show endpoints for one model
# List providers
models list accepts either --category or --supported-parameter, not both.
Management Workflows
API keys
# List keys
# Create one
# Inspect one
# Update one
# Delete one
Guardrails
# List guardrails
# Create one
# Update and clear allowlists
# Delete one
Guardrail assignments
# List global key assignments
# List assignments for one guardrail
# Assign keys
# Unassign keys
Member assignment commands mirror the same shape under guardrails assignments members ....
Credits And Usage
# Show purchased/used credits
# Create a Coinbase charge
# Show activity for a specific day
Output Contract
--output supports:
table(default)json
JSON output is wrapped in a versioned envelope:
Errors in JSON mode use:
Live Smoke Tests
The workspace includes an opt-in live smoke suite at tests/live_smoke.rs.
Environment switches:
OPENROUTER_CLI_RUN_LIVE=1: enable live smokeOPENROUTER_CLI_RUN_LIVE_WRITE=1: also enable create/delete write-path checks
Required secrets:
OPENROUTER_API_KEYfor read smokeOPENROUTER_MANAGEMENT_KEYfor usage and write smoke
Examples:
# Read-only live smoke
OPENROUTER_CLI_RUN_LIVE=1 \
OPENROUTER_API_KEY=... \
# Include write-path smoke
OPENROUTER_CLI_RUN_LIVE=1 \
OPENROUTER_CLI_RUN_LIVE_WRITE=1 \
OPENROUTER_API_KEY=... \
OPENROUTER_MANAGEMENT_KEY=... \