OpenRouter CLI
A powerful command-line interface for OpenRouter, enabling seamless integration with multiple language models and AI services. Currently featuring Claude Code integration with more capabilities coming soon.
✨ Features
- Multi-Model Support: Access any model available on OpenRouter through a unified interface
- Claude Code Integration: Use any OpenRouter model with Claude Code for enhanced development workflows
- Smart Model Routing: Automatically route requests to optimal models based on task type (reasoning, long context, web search, etc.)
- Dynamic Model Switching: Change models on-the-fly using simple commands
- Extensible Architecture: Built to support future OpenRouter features and integrations
🚀 Getting Started
1. Installation
Install the OpenRouter CLI:
npm install -g @openrouter/cli
For Claude Code integration, ensure you have Claude Code installed:
npm install -g @anthropic-ai/claude-code
2. Configuration
Create and configure your ~/.openrouter/config.json file. For more details, see the included config.example.json.
The configuration file supports several key sections:
OPENROUTER_API_KEY: Your OpenRouter API key for accessing models
LOG (optional): Enable/disable logging. Default is true
LOG_LEVEL (optional): Set logging verbosity: "fatal", "error", "warn", "info", "debug", "trace". Default is "debug"
- Logging Systems: The OpenRouter CLI uses two separate logging systems:
- Server logs: HTTP requests and API events in
~/.openrouter/logs/
- Application logs: Routing decisions and operations in
~/.openrouter/router.log
models: Configure model routing for different task types
API_TIMEOUT_MS: API call timeout in milliseconds
Environment Variable Support
The OpenRouter CLI supports environment variable interpolation for secure credential management. Reference environment variables in your config using $VAR_NAME or ${VAR_NAME} syntax:
{
"OPENROUTER_API_KEY": "$OPENROUTER_API_KEY"
}
Keep sensitive credentials secure by storing them as environment variables rather than in configuration files.
Example Configuration
{
"OPENROUTER_API_KEY": "$OPENROUTER_API_KEY",
"LOG": true,
"models": {
"default": "deepseek/deepseek-chat",
"background": "qwen/qwen3-30b-a3b",
"think": "deepseek/deepseek-reasoner",
"longContext": "google/gemini-2.5-pro-preview",
"longContextThreshold": 60000,
"webSearch": "google/gemini-2.5-flash:online"
}
}
3. Usage
Claude Code Integration
Use any OpenRouter model with Claude Code:
openrouter code "your prompt here"
Service Management
openrouter start # Start the proxy service
openrouter stop # Stop the proxy service
openrouter restart # Restart the service (required after config changes)
openrouter status # Check service status
4. Model Routing
Configure intelligent model routing based on task requirements:
default: Primary model for general tasks
background: Cost-efficient model for background operations
think: Advanced reasoning model for complex problem-solving
longContext: Model optimized for large context windows (>60K tokens)
longContextThreshold: Token threshold for automatic long-context routing (default: 60000)
webSearch: Model with web search capabilities (append :online to model name)
Dynamic Model Selection
Switch models on-the-fly within Claude Code:
/model anthropic/claude-sonnet-4
🚧 Coming Soon
The OpenRouter CLI is actively expanding to support:
- Direct model querying/chat
- Ability to intercept all calls on your system to openai or anthropic through your openai account to use any model
- API usage monitoring and analytics
- Account management
- And much more!
Stay tuned for updates as we build out the complete OpenRouter experience.