# One key, six agent tools

Claude Code, Codex, Gemini CLI, OpenCode, Cline, and Cursor speak different protocols, yet all can share one RouterOne key and gateway URL. A comparison table plus six minimal configs cover what to fill in and where the traps are.

Switching tools shouldn't mean switching keys. Claude Code, Codex, Gemini CLI, OpenCode, Cline, and Cursor span four protocols, yet all of them can point at the same gateway with the same RouterOne key. Each tool installs on its own, but the configuration is filled in once: one URL, one key, and the only remaining choice is which model to use.
If you'd rather not edit config files by hand, third-party tools are the easier route — both of these are worth installing:
| Tool                                                        | What it is                                                                                                     | Good for                                         |
| ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| [CC Switch](https://routerone.ai/en/integrations/cc-switch) | GUI for switching providers and models; writes to each tool's own config file                                  | Just want to flip between a few models           |
| [Magpie](https://usemagpie.ai)                              | Local gateway plus menu bar; pick a model per agent in one place, with routing groups and subscription sharing | Managing multiple agents and providers centrally |
The manual configs below are for readers who want to understand what every field does. For everyday model switching, the two tools above are faster.
## Six tools at a glance
| Tool                  | Protocol           | Where the config lives                   | URL (`/v1` or not)       | The gotcha in one line                                                      |
| --------------------- | ------------------ | ---------------------------------------- | ------------------------ | --------------------------------------------------------------------------- |
| Claude Code           | Anthropic Messages | Environment variables (`~/.zshrc`, etc.) | `{{BASE_URL}}`, no `/v1` | Leave `ANTHROPIC_API_KEY` empty, or it takes precedence over the auth token |
| Codex (CLI + desktop) | OpenAI             | `~/.codex/config.toml`                   | Include `/v1`            | `env_key` takes a variable name, not the key itself                         |
| Gemini CLI            | Gemini             | `~/.gemini/.env` + `settings.json`       | `{{BASE_URL}}`, no `/v1` | Without `selectedType` in `settings.json`, it falls back to Google sign-in  |
| OpenCode              | OpenAI-compatible  | `opencode.json` in the project directory | Include `/v1`            | `apiKey` uses `{env:variable name}`, never plaintext                        |
| Cline (VS Code)       | OpenAI-compatible  | Extension settings panel                 | `{{BASE_URL}}`           | Enter the canonical Model ID by hand; don't pick from the dropdown          |
| Cursor                | OpenAI-compatible  | Settings → Models                        | `{{BASE_URL}}`           | Custom models need Pro; both toggles must be on                             |
Whether to include `/v1` depends on the protocol: Anthropic and Gemini clients build the path themselves, while OpenAI-style clients need you to include `/v1`. Get it backwards and you'll see a 404.
## Claude Code
The official install now uses a native script (npm is no longer recommended). Put the config in your shell profile:
```bash
export ANTHROPIC_BASE_URL={{BASE_URL}}
export ANTHROPIC_AUTH_TOKEN=<your RouterOne key>
export ANTHROPIC_API_KEY=
```
- Leave `/v1` off the URL: the client appends `/v1/messages` itself.
- Leave `ANTHROPIC_API_KEY` empty — if it has a value, it overrides the auth token and authentication fails.
- The three model tiers don't all need to be Claude. Protocol and model are separate things: any model that speaks the Anthropic protocol works. Use `/status` to check the current URL and auth method.
## Codex
Install the CLI with `npm i -g @openai/codex`, and the desktop app from the official page; both read the same `~/.codex/config.toml`. Keep the key in an environment variable rather than in the config:
```bash
export ROUTERONE_API_KEY=<your RouterOne key>
```
```toml
model_provider = "routerone"
model = "openai/gpt-5.6"

[model_providers.routerone]
name = "RouterOne"
base_url = "{{BASE_URL}}/v1"
env_key = "ROUTERONE_API_KEY"
wire_api = "responses"
```
- Include `/v1` in `base_url`: the client appends `/chat/completions` or `/responses`.
- `env_key` takes the variable name `ROUTERONE_API_KEY`, not the key itself; put the key value there and it will be read as a variable name, which shows up as an auth failure.
- Set `wire_api` to `responses` or `chat` — both endpoints are supported. After editing the config, open a new terminal for the CLI; quit the desktop app fully and relaunch it.
## Gemini CLI
Install with `npm i -g @google/gemini-cli`. Alongside the three environment variables, there's one more place to edit: `settings.json`.
```bash
export GOOGLE_GEMINI_BASE_URL={{BASE_URL}}
export GEMINI_API_KEY=<your RouterOne key>
export GEMINI_MODEL=google/gemini-3-pro
```
```json
{
  "security": {
    "auth": {
      "selectedType": "gemini-api-key"
    }
  }
}
```
- That `settings.json` block is required. Without `selectedType`, the CLI uses Google account sign-in and ignores the key above entirely.
- Leave `/v1` off the URL: the client appends `/v1beta/models/{model}:generateContent` itself.
- Shell variables override `~/.gemini/.env`; when troubleshooting, check what `env | grep GEMINI_` actually shows.
## OpenCode
Install via the official script or `npm i -g opencode-ai@latest`. First put the key in an environment variable, then create `opencode.json` in your project directory:
```bash
export ROUTERONE_API_KEY=<your RouterOne key>
```
```json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "routerone": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "RouterOne",
      "options": {
        "baseURL": "{{BASE_URL}}/v1",
        "apiKey": "{env:ROUTERONE_API_KEY}"
      },
      "models": {
        "anthropic/claude-opus-5": { "name": "Claude Opus 5" }
      }
    }
  }
}
```
- Reference the key with `{env:ROUTERONE_API_KEY}` in `apiKey` — never put plaintext here, since this file usually gets committed with the project.
- Include `/v1` in `baseURL`; to use `/v1/responses`, switch `npm` to `@ai-sdk/openai`.
- The config is read from `opencode.json` in the **current working directory**. If the model listed above shows up under `/models`, you're connected.
## Cline (VS Code)
Install Cline from the extension marketplace, choose **OpenAI Compatible** as the API Provider in settings, and fill in three fields:
| Field                     | What to enter                                |
| ------------------------- | -------------------------------------------- |
| Base URL                  | `{{BASE_URL}}`                               |
| OpenAI Compatible API Key | Your RouterOne key                           |
| Model ID                  | Canonical ID, e.g. `anthropic/claude-opus-5` |
- Type the Model ID manually; don't pick from a dropdown — the OpenAI Compatible option doesn't fetch a model list.
- To verify, give it a small task that requires a tool (for example, "read the README and summarize it"); plain text won't exercise the tool path.
- It uses the standard OpenAI-compatible protocol, so neither of the Cursor limitations applies.
## Cursor
Open Settings → Models and fill in the following:
- **OpenAI API Key**: switch it on and paste in your RouterOne key.
- **Override OpenAI Base URL**: switch it on and enter `{{BASE_URL}}`.
- **+ Add Custom Model**: enter the canonical ID (e.g. `anthropic/claude-opus-5`) and make sure the toggle is green.
(Custom models in Cursor require a Pro subscription.)
Known limitations come from Cursor's implementation of custom URLs:
| Model         | Symptom                                  | Status                                                                                 |
| ------------- | ---------------------------------------- | -------------------------------------------------------------------------------------- |
| GPT models    | `Parameter messages is required`         | Responses-shaped requests don't match the Chat Completions path; no workaround for now |
| Claude models | Tool definitions error out in some modes | Tool-definition shape isn't fully compatible with Chat Completions                     |
- Both toggles must be on. If you enter the key but leave Override off, requests still go to the official endpoint and you'll see an auth failure.
- Tab completion doesn't use this URL — the custom URL only affects chat; completion runs through Cursor's own service.
## The most common traps
| Symptom                     | What to check                                                                                                                                                                                                                                                                                                                         |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Auth failure                | Claude Code: is `ANTHROPIC_API_KEY` empty? Codex: does `env_key` hold a variable name rather than the key? Gemini CLI: is `selectedType` set to `gemini-api-key` in `settings.json`? General: was the key copied in full (no leading/trailing spaces or newlines), is it still enabled in the console, and is the balance sufficient? |
| 404                         | The URL has an extra `/v1` — Anthropic clients then build `/v1/v1/messages`; conversely, OpenAI-style clients that need `/v1` are missing it                                                                                                                                                                                          |
| Model not found             | IDs need a provider prefix (`anthropic/claude-opus-5`, not `claude-opus-5`), and the upstream must support the protocol you selected; the model detail page says which protocols are supported                                                                                                                                        |
| Tool calls fail             | The model isn't suited to the scenario — switch to one with stronger tool-calling ability; this matters especially for Cline and Cursor                                                                                                                                                                                               |
| Config not taking effect    | For CLIs, reopen the terminal or `source` the profile; fully quit and relaunch desktop apps; confirm the file is in the right place (`~/.codex/config.toml`, `opencode.json` in the project directory, etc.); Gemini CLI shell variables override `.env`                                                                              |
| Model missing from dropdown | Neither Cline nor Cursor fetches a model list — enter the Model ID manually; Cursor's toggle for a newly added model may be off by default                                                                                                                                                                                            |
## General rules for choosing a model
- **Canonical IDs include a provider prefix**: `anthropic/claude-opus-5`, `openai/gpt-5.6`, `google/gemini-3-pro`; omit the prefix and you'll get a model-not-found error.
- **Pin a provider**: add a colon after the model name, e.g. `anthropic/claude-opus-5:anthropic`. The same model is often served by several providers at different prices and speeds.
- **Set a routing policy**: `:@price` prioritizes price, `:@latency` latency, `:@reliability` reliability; see the [API reference](https://routerone.ai/en/api-reference#model-names).
- **Match the protocol**: Claude Code speaks Anthropic, so pick a model whose upstream supports Anthropic. An incompatible combination fails explicitly rather than silently falling back; the model detail page indicates support.
- **You're not limited to the native provider**: protocol and model are separate — running `openai/gpt-5.6` in Claude Code or `anthropic/claude-opus-5` in Codex both work.
RouterOne provides one key and one gateway URL, and all of the tools above are supported.
