Connecting Claude Code, Cursor, Codex and the rest

The tools you code with every day reach every model with one address and one key.

10 minLesson 5 of 80 of 3 steps

Coding tools usually have somewhere to put an address and a key. Give IranRouter's address instead of the default. Make a separate key for each tool, so each one's spending shows on its own.

The panel's home also has a Connect card with ready commands for several tools.

Claude Code

Shell
export ANTHROPIC_BASE_URL="https://iranrouter.com/anthropic"
export ANTHROPIC_API_KEY="ir-..."
claude

The prefix is /anthropic, not /v1, because Claude Code appends /v1/messages itself.

Cursor

In Settings under Models, put your key in OpenAI API Key, turn on Override OpenAI Base URL and enter this address. Then add the model by its full id as a custom model.

Text
https://iranrouter.com/v1

Codex

Codex only speaks the /responses route. Put this in ~/.codex/config.toml and keep the key in the IRANROUTER_KEY environment variable:

toml
model = "openai/gpt-5.6-sol"
model_provider = "iranrouter"

[model_providers.iranrouter]
name = "IranRouter"
base_url = "https://iranrouter.com/v1"
env_key = "IRANROUTER_KEY"
wire_api = "responses"

Codex's own web search works too, and each search has its own fixed charge on top of the tokens. Its other tools work as well, file edits included.

Gemini CLI

Shell
export GOOGLE_GEMINI_BASE_URL="https://iranrouter.com/genai"
export GEMINI_API_KEY="ir-..."
gemini -m google/gemma-4-31b-it

On the first run, choose Gemini API Key as the sign-in method.

Continue and the rest

YAML
models:
  - name: Claude via IranRouter
    provider: openai
    model: anthropic/claude-sonnet-4.6
    apiBase: https://iranrouter.com/v1
    apiKey: ir-...

Any other tool that takes a base_url connects the same way. The full list is in the tools guide.

To make variables permanent, put those export lines in ~/.zshrc or ~/.bashrc.

Connect your own tool0 of 3 steps

  1. Make a separate key with a monthly cap for your tool.
  2. Enter the setting above and give the tool a small job.
  3. On the panel's home or in the logs, see that the tool is recognised by name.
Create a key
Coding tools send your whole codebase and history too, and can use millions of tokens in an hour. Don't forget the monthly cap, and check in the log that prompt caching is engaging.

A quick check

Just for you: your answers aren't sent anywhere.

For Claude Code, which prefix does the IranRouter address end with?

Why make a separate key for each tool?

What you learned

  • The address and key go in the tool's settings.
  • /anthropic for Claude Code, /genai for Gemini CLI, /v1 for the rest.
  • Next: how OpenClaw carries a job through.
OpenClaw: an agent on your own machineIf you want to hand off a job and walk away, this gets it running and keeps its bill in your hands.Done, next lesson