CLI Tool Setup Guides

Step-by-step instructions to connect your favorite coding tools to KRouter. All tools use the same base URL and API key.

link
Base URL for all tools:https://krouter.net/v1
search
terminal

Claude Code

Managed config

Install Claude Code CLI, then point `ANTHROPIC_BASE_URL` to KRouter and set model aliases in `~/.claude/settings.json`.

folder~/.claude/settings.json

checklistSetup Steps

1

Install Claude Code and run `claude` once to verify the CLI is available.

2

Set `ANTHROPIC_BASE_URL` to `https://KRouter.net/v1` and `ANTHROPIC_AUTH_TOKEN` to your KRouter API key.

3

Optionally map the default opus, sonnet, and haiku model variables to your chosen KRouter model paths.

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://KRouter.net/v1",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_KROUTER_API_KEY",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "provider/model-id"
  }
}
downloadnpm install -g @anthropic-ai/claude-code
terminal

OpenAI Codex CLI

Managed config

Codex uses a provider block in `~/.codex/config.toml` plus an API key in `~/.codex/auth.json`.

folder~/.codex/config.toml + ~/.codex/auth.json

checklistSetup Steps

1

Install Codex CLI and verify with `codex`.

2

Set `base_url` to `https://KRouter.net/v1` inside the `model_providers.krouter` block and keep `wire_api = "responses"`.

3

Store `OPENAI_API_KEY` in `~/.codex/auth.json`, then set your main model and optional subagent model.

toml
model = "provider/model-id"
model_provider = "krouter"

[model_providers.krouter]
name = "KRouter"
base_url = "https://KRouter.net/v1"
wire_api = "responses"

[agents.subagent]
model = "provider/model-id"
downloadnpm install -g @openai/codex
terminal

OpenCode

Managed config

OpenCode stores provider and model configuration in `~/.config/opencode/opencode.json`.

folder~/.config/opencode/opencode.json

checklistSetup Steps

1

Install OpenCode and verify the CLI is available.

2

Create a provider named `krouter` that uses the OpenAI-compatible SDK with `baseURL = https://KRouter.net/v1`.

3

Attach your KRouter API key, register one or more models, and optionally set a subagent explorer model.

json
{
  "provider": {
    "krouter": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://KRouter.net/v1",
        "apiKey": "YOUR_KROUTER_API_KEY"
      }
    }
  },
  "model": "krouter/provider/model-id"
}
downloadnpm install -g opencode-ai
terminal

Open Claw

Managed config

Open Claw uses `~/.openclaw/openclaw.json` and can map a default model plus per-agent overrides.

folder~/.openclaw/openclaw.json

checklistSetup Steps

1

Define provider `krouter` with `baseUrl = https://KRouter.net/v1` and your KRouter API key.

2

Set the default agent model to `krouter/provider/model-id`.

3

If needed, override individual agent models for specific workflows.

json
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "krouter/provider/model-id"
      }
    }
  },
  "models": {
    "providers": {
      "krouter": {
        "baseUrl": "https://KRouter.net/v1",
        "apiKey": "YOUR_KROUTER_API_KEY"
      }
    }
  }
}
terminal

Factory Droid

Managed config

Factory Droid writes a custom model entry in `~/.factory/settings.json` or `%USERPROFILE%\\.factory\\settings.json`.

folder~/.factory/settings.json

checklistSetup Steps

1

Add a custom model entry whose `baseUrl` is `https://KRouter.net/v1`.

2

Use your KRouter API key in the `apiKey` field.

3

Set the model field to the routed model path you want the tool to call.

json
{
  "customModels": [
    {
      "model": "provider/model-id",
      "id": "custom:KRouter-0",
      "baseUrl": "https://KRouter.net/v1",
      "apiKey": "YOUR_KROUTER_API_KEY",
      "provider": "openai"
    }
  ]
}
terminal

Cursor

Guide-based setup

Cursor uses the custom OpenAI API flow and expects an externally reachable endpoint.

folderCursor Settings > Models

checklistSetup Steps

1

Open Cursor Settings and go to Models.

2

Enable the OpenAI API key option, then set Base URL to `https://KRouter.net/v1`.

3

Paste your KRouter API key and add a custom model path.

info

The current setup flow marks Cursor as requiring an external URL rather than localhost.

terminal

Cline / Kilo Code / Roo

OpenAI-compatible guide

These tools mainly need provider selection, base URL, API key, and a model path.

folderTool settings panel

checklistSetup Steps

1

Open each tool's settings panel.

2

Choose an OpenAI-compatible provider. Roo follows the Ollama-style path in the original guide.

3

Set Base URL to `https://KRouter.net/v1` for Cline and Kilo, or `https://KRouter.net` for Roo if the client expects the raw host.

4

Paste the API key and select your routed model path.

terminal

Continue

Config file

Continue expects an OpenAI provider model object in its configuration file.

folderContinue config file

checklistSetup Steps

1

Open the Continue configuration file.

2

Add an OpenAI model object whose `apiBase` points to `https://KRouter.net/v1`.

3

Fill in the KRouter API key and the model path you want to route.

json
{
  "apiBase": "https://KRouter.net/v1",
  "title": "provider/model-id",
  "model": "provider/model-id",
  "provider": "openai",
  "apiKey": "YOUR_KROUTER_API_KEY"
}
terminal

Antigravity / Copilot / Kiro

MITM flow

These tools do not follow the normal custom-provider path. The current product routes them through MITM-oriented setup inside the dashboard.

folderDashboard > CLI Tools > MITM

checklistSetup Steps

1

Open the MITM tools section and start the MITM service with the required system permissions.

2

Accept certificate and DNS/network changes required by the tool-specific flow.

3

Select a KRouter API key and map each exposed alias to the upstream model route you want.

info

This mirrors the intent of the current CLI Tools tab, where MITM tools link to a separate flow instead of using the same generic setup card.