Coding Tools
ShareUse KiteRouter as the gateway for coding agents by configuring each tool with the API shape it already speaks. Codex uses OpenAI Responses, Claude Code uses Anthropic Messages, and Gemini CLI uses the Gemini API.
Share this section with teammates: https://kiterouter.com/docs/coding-tools
| Tool | Configure this base URL | Key env var | Protocol sent by the tool |
|---|---|---|---|
| Codex | https://kiterouter.com/api/v1 | KITEROUTER_API_KEY | OpenAI Responses: /responses |
| Claude Code | https://kiterouter.com/api | ANTHROPIC_AUTH_TOKEN | Anthropic Messages: /v1/messages |
| Gemini CLI | https://kiterouter.com/api | GEMINI_API_KEY | Gemini API: /v1/models/... |
Info: The Claude Code and Gemini CLI base URL intentionally ends at /api, not /api/v1. Those tools append /v1/... themselves.
Before you start
- Create a KiteRouter API key from Dashboard -> API Keys.
- Copy the exact model id from the Models page.
- Restart the coding tool after changing env vars or config files.
- Test with a tiny prompt before launching a long agent task.
Config file locations
Use the user-level file for API keys and personal provider settings. Project-level files can be committed for team defaults, but do not put kr- keys in a repository.
| Tool | Windows user file | macOS user file | Linux / WSL user file |
|---|---|---|---|
| Codex | %USERPROFILE%\.codex\config.toml | ~/.codex/config.toml | ~/.codex/config.toml |
| Claude Code | %USERPROFILE%\.claude\settings.json | ~/.claude/settings.json | ~/.claude/settings.json |
| Gemini CLI | %USERPROFILE%\.gemini\settings.json | ~/.gemini/settings.json | ~/.gemini/settings.json |
| Gemini env | %USERPROFILE%\.gemini\.env | ~/.gemini/.env | ~/.gemini/.env |
Info: In WSL, use the Linux paths inside the WSL home directory, not the Windows %USERPROFILE% path.
Codex
Codex reads config.toml from the Codex user directory above. Current Codex custom providers use the Responses API, so point base_url at KiteRouter's OpenAI-compatible versioned base URL and keep wire_api = "responses".
1model = "openai/gpt-5.5" 2model_provider = "kiterouter" 3 4[model_providers.kiterouter] 5name = "KiteRouter" 6base_url = "https://kiterouter.com/api/v1" 7env_key = "KITEROUTER_API_KEY" 8wire_api = "responses"
macOS / Linux / WSL:
1export KITEROUTER_API_KEY="kr-your-api-key" 2codex exec "Reply with: ready"
Windows PowerShell:
1$env:KITEROUTER_API_KEY = "kr-your-api-key" 2codex exec "Reply with: ready"
Use the model value for the KiteRouter model you want Codex to run. If you switch models often, set the provider once and override the model from the Codex CLI when needed.
Claude Code
Claude Code supports LLM gateways through ANTHROPIC_BASE_URL. Use ANTHROPIC_AUTH_TOKEN for KiteRouter so Claude Code sends your kr- key as a Bearer token.
macOS / Linux / WSL:
1export ANTHROPIC_BASE_URL="https://kiterouter.com/api" 2export ANTHROPIC_AUTH_TOKEN="kr-your-api-key" 3export ANTHROPIC_MODEL="anthropic/claude-sonnet-4-5" 4claude -p "Reply with: ready"
Windows PowerShell:
1$env:ANTHROPIC_BASE_URL = "https://kiterouter.com/api" 2$env:ANTHROPIC_AUTH_TOKEN = "kr-your-api-key" 3$env:ANTHROPIC_MODEL = "anthropic/claude-sonnet-4-5" 4claude -p "Reply with: ready"
For a persistent setup, put the same values in the user settings.json file from the platform table:
1{ 2 "env": { 3 "ANTHROPIC_BASE_URL": "https://kiterouter.com/api", 4 "ANTHROPIC_AUTH_TOKEN": "kr-your-api-key", 5 "ANTHROPIC_MODEL": "anthropic/claude-sonnet-4-5" 6 } 7}
If you want Claude Code's /model picker to discover gateway models, enable gateway model discovery:
1export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
Gemini CLI
Gemini CLI supports a custom Gemini API base URL with GOOGLE_GEMINI_BASE_URL. Set the API version to v1 so requests land on KiteRouter's /api/v1/models/... routes.
macOS / Linux / WSL:
1export GEMINI_API_KEY="kr-your-api-key" 2export GOOGLE_GEMINI_BASE_URL="https://kiterouter.com/api" 3export GOOGLE_GENAI_API_VERSION="v1" 4export GEMINI_MODEL="gemini-2.5-pro" 5gemini -p "Reply with: ready"
Windows PowerShell:
1$env:GEMINI_API_KEY = "kr-your-api-key" 2$env:GOOGLE_GEMINI_BASE_URL = "https://kiterouter.com/api" 3$env:GOOGLE_GENAI_API_VERSION = "v1" 4$env:GEMINI_MODEL = "gemini-2.5-pro" 5gemini -p "Reply with: ready"
For a persistent setup, put the env values in the Gemini .env file from the platform table:
1GEMINI_API_KEY=kr-your-api-key 2GOOGLE_GEMINI_BASE_URL=https://kiterouter.com/api 3GOOGLE_GENAI_API_VERSION=v1 4GEMINI_MODEL=gemini-2.5-pro
Then make sure Gemini CLI is set to API-key auth in the user settings.json file:
1{ 2 "security": { 3 "auth": { 4 "selectedType": "gemini-api-key" 5 } 6 }, 7 "model": { 8 "name": "gemini-2.5-pro" 9 } 10}
Use a Gemini-family model id from the Models page.
CC Switch
If you manage several coding agents on the same machine, create one KiteRouter provider per protocol:
| Provider name | Use with | Base URL |
|---|---|---|
| KiteRouter OpenAI | Codex | https://kiterouter.com/api/v1 |
| KiteRouter Anthropic | Claude Code | https://kiterouter.com/api |
| KiteRouter Gemini | Gemini CLI | https://kiterouter.com/api |
Keep the provider name tied to the protocol, not the model. That makes it obvious when a tool is about to send OpenAI, Anthropic, or Gemini-shaped requests.
Troubleshooting
| Symptom | What to check |
|---|---|
401 or invalid_api_key | Use a KiteRouter kr- key and restart the tool after setting env vars. |
404 from Claude Code | ANTHROPIC_BASE_URL should be https://kiterouter.com/api, not https://kiterouter.com/api/v1. |
404 from Gemini CLI | Use GOOGLE_GEMINI_BASE_URL="https://kiterouter.com/api" and GOOGLE_GENAI_API_VERSION="v1". |
| Codex config rejected | Put provider settings in ~/.codex/config.toml and keep wire_api = "responses". |
| Model not found | Copy the exact model id from the Models page and match it to the tool protocol. |
Security: Never commit kr- keys. Prefer environment variables, OS keychain storage, or your coding tool's secret manager.