CLI Integration
Use official CLIs by pointing their base URLs to KushRouter and providing your KushRouter API key.
OpenAI Codex CLI
Configuration via config.toml
Codex uses a configuration file at ~/.codex/config.toml. Add a custom model provider:
# Kushrouter endpoint
model_provider="kushrouter"
model="gpt-5.1-codex"
[model_providers.kushrouter]
name="kushrouter"
api_base = "https://api.kushrouter.com/api/openai/v1"
base_url="https://api.kushrouter.com/api/openai/v1"
api_key_env = "KUSHROUTER_API_KEY"
env_key="KUSHROUTER_API_KEY"
wire_api = "responses"Set Environment Variable
Set your API key:
Bash/Linux/macOS:
export KUSHROUTER_API_KEY="your-kushrouter-api-key"Windows PowerShell:
$env:KUSHROUTER_API_KEY = "your-kushrouter-api-key"Alternative: Environment Variable Override
You can also override the base URL for the default OpenAI provider:
export OPENAI_BASE_URL="https://api.kushrouter.com/api/openai/v1"
export OPENAI_API_KEY="your-kushrouter-api-key"
codex --model gpt-5-codexNote: gpt-5-codex is routed via the OpenAI Responses API only.
Claude Code
Claude Code uses environment variables for configuration.
Set Environment Variables
Bash/Linux/macOS:
export ANTHROPIC_BASE_URL="https://api.kushrouter.com/api/anthropic"
export ANTHROPIC_AUTH_TOKEN="your-kushrouter-api-key"
claudeWindows PowerShell:
$env:ANTHROPIC_BASE_URL = "https://api.kushrouter.com/api/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = "your-kushrouter-api-key"
claudeOptional Configuration
You can also configure additional settings if needed:
# Optional: Set a specific model (Claude Code will use its default if not set)
export ANTHROPIC_MODEL="claude-sonnet-4-5-20250929"
# Optional: Increase timeout for long-running requests (in milliseconds)
export API_TIMEOUT_MS=600000
# Optional: Disable non-essential network traffic
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1OpenCode
OpenCode uses a JSON configuration file and supports custom providers with OpenAI-compatible APIs.
Configuration via opencode.json
Create or edit ~/.config/opencode/opencode.json (global config) or opencode.json in your project root:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"kushrouter": {
"npm": "@ai-sdk/openai-compatible",
"name": "KushRouter",
"options": {
"baseURL": "https://api.kushrouter.com/api/openai/v1",
"apiKey": "{env:KUSHROUTER_API_KEY}"
},
"models": {
"gpt-5-2025-08-07": {
"name": "GPT-5"
},
"claude-sonnet-4-5-20250929": {
"name": "Claude Sonnet"
}
}
}
},
"model": "kushrouter/gpt-5-2025-08-07"
}Set Environment Variable
Bash/Linux/macOS:
export KUSHROUTER_API_KEY="your-kushrouter-api-key"Windows PowerShell:
$env:KUSHROUTER_API_KEY = "your-kushrouter-api-key"Run OpenCode
opencodeOnce running, use the /models command to switch between configured models.
Alternative: Using opencode auth login
You can also add credentials interactively:
opencode auth loginSelect "Other" and enter:
- Provider ID:
kushrouter - API Key: your KushRouter API key
Then add the provider configuration to your opencode.json as shown above (without the apiKey field, as it's already stored).
Troubleshooting
OpenAI Codex
- Ensure your base URL includes the full path with
/v1suffix:https://api.kushrouter.com/api/openai/v1 - The base URL will have
/chat/completionsautomatically appended by Codex - Verify your config.toml file is at
~/.codex/config.toml(or$CODEX_HOME/config.tomlif you've customized it) - Check that the
env_keymatches your environment variable name exactly - Use
codex mcp listto verify your configuration
Claude Code
- Ensure your base URL matches the Anthropic endpoint format:
https://api.kushrouter.com/api/anthropic - Verify the API key is set with
ANTHROPIC_AUTH_TOKEN(notANTHROPIC_API_KEY) - Claude Code does not use a config file - all configuration is via environment variables
General
- Verify your KushRouter API key has sufficient credits
- Check that your base URL matches the correct endpoint family:
- OpenAI/Codex:
/api/openai/v1 - Anthropic/Claude Code:
/api/anthropic
- OpenAI/Codex:
- Test your connection with a simple request first
Installation
OpenAI Codex
# via npm
npm install -g @openai/codex
# via Homebrew
brew install codexClaude Code
npm install -g @anthropic-ai/claude-code