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:
# Define KushRouter as a custom model provider
[model_providers.kushrouter]
name = "KushRouter"
base_url = "https://api.kushrouter.com/api/openai/v1"
env_key = "KUSHROUTER_API_KEY"
wire_api = "chat"
# Create a profile for your model
[profiles.kushrouter_gpt5]
model = "gpt-5-2025-08-07"
model_provider = "kushrouter"
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"
Run Codex with Profile
codex --profile kushrouter_gpt5
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-2025-08-07
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"
claude
Windows PowerShell:
$env:ANTHROPIC_BASE_URL = "https://api.kushrouter.com/api/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = "your-kushrouter-api-key"
claude
Optional 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@20250514"
# 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=1
OpenCode
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@20250514": {
"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
opencode
Once running, use the /models
command to switch between configured models.
Alternative: Using opencode auth login
You can also add credentials interactively:
opencode auth login
Select "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
/v1
suffix:https://api.kushrouter.com/api/openai/v1
- The base URL will have
/chat/completions
automatically appended by Codex - Verify your config.toml file is at
~/.codex/config.toml
(or$CODEX_HOME/config.toml
if you've customized it) - Check that the
env_key
matches your environment variable name exactly - Use
codex mcp list
to 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 codex
Claude Code
npm install -g @anthropic-ai/claude-code