CrossModel
Claude Code

Integration guide

Claude Code

Claude Code is Anthropic's official command-line coding assistant. It lets you override the API endpoint, so once you point it at CrossModel you can drive every model in the catalog from inside Claude Code.

Quickstart

1. Install Claude Code

macOS / Linux:

curl -fsSL https://claude.ai/install.sh | bash

Or install with npm (requires Node.js 18+):

npm install -g @anthropic-ai/claude-code

2. Create an API key

Sign in to the Console and create a key that starts with cm- on the API Keys page. The key is shown only once, so copy it somewhere safe.

3. Point Claude Code at CrossModel

The cleanest place is your project's .claude/settings.json, under env:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.crossmodel.ai",
    "ANTHROPIC_AUTH_TOKEN": "cm-YOUR_KEY",
    "ANTHROPIC_API_KEY": ""
  }
}

You can also export them from your shell profile (~/.zshrc or ~/.bashrc):

export ANTHROPIC_BASE_URL=https://api.crossmodel.ai
export ANTHROPIC_AUTH_TOKEN=cm-YOUR_KEY
export ANTHROPIC_API_KEY=

Set ANTHROPIC_API_KEY to an empty value explicitly. If a stale key lingers there, it conflicts with ANTHROPIC_AUTH_TOKEN and your requests will keep going to Anthropic directly.

4. Sign out of any existing account

If you've logged in with an Anthropic account before, sign out first so a cached session doesn't override the config above:

/logout

5. Launch and verify

Start Claude Code from your project directory:

cd /path/to/your/project
claude

Run /status and confirm that Anthropic base URL points to https://api.crossmodel.ai and that auth is using ANTHROPIC_AUTH_TOKEN.

How it works

By default Claude Code talks to Anthropic's API. Setting ANTHROPIC_BASE_URL redirects every request to CrossModel's /v1/messages endpoint, authenticated with your cm- key carried in ANTHROPIC_AUTH_TOKEN.

Claude Code appends /v1/messages to the base URL for you, so ANTHROPIC_BASE_URL should be https://api.crossmodel.ai — without a trailing /v1.

Choosing models

Claude Code maps its work onto three tiers — opus, sonnet, and haiku. Use these environment variables to point each tier at a CrossModel model ID:

export ANTHROPIC_DEFAULT_OPUS_MODEL=anthropic/claude-opus-4.7
export ANTHROPIC_DEFAULT_SONNET_MODEL=anthropic/claude-sonnet-4.6
export ANTHROPIC_DEFAULT_HAIKU_MODEL=anthropic/claude-haiku-4.5

If you're using .claude/settings.json, drop these into the same env object. Browse the full list of model IDs in the model catalog, or fetch them from /v1/models.

Troubleshooting

SymptomWhat to check
"Model not found"Make sure the model ID appears in the /v1/models response, and note the vendor/short_name format.
Auth failure (401)Confirm ANTHROPIC_API_KEY is empty and ANTHROPIC_AUTH_TOKEN holds a valid cm- key.
Requests still hit AnthropicCheck that you ran /logout, and that the env vars are active in the current shell (reopen the terminal or source your profile).
Insufficient balance (402)Top up in the Console.