Use your key in Claude Code

Install the CLI, point ANTHROPIC_BASE_URL at OLETOKEN, and pick a model — plus the VS Code extension and troubleshooting.

Claude Code is Anthropic's coding agent (CLI plus the VS Code extension) and it speaks the Anthropic Messages protocol. Point it at OLETOKEN and it uses your OLETOKEN key and model quota — no Anthropic account needed.

Before you start

  1. You have created an API key and saved the full key.
  2. You picked a Claude model ID from the model marketplace (for example claude-sonnet-5).
  3. Node.js and npm are installed.

Configure

The config lives in the env block of ~/.claude/settings.json. The CLI and the VS Code extension share this file, so configuring it once covers both — and it is more reliable than shell exports, because VS Code does not always inherit your shell environment:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://<your-base-url>",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_MODEL": "claude-sonnet-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-sonnet-5"
  }
}
VariableMeaning
ANTHROPIC_BASE_URLHost only, no /v1 — the CLI appends /v1/messages itself, and including it returns 404
ANTHROPIC_AUTH_TOKENYour OLETOKEN key, sent as Authorization: Bearer
ANTHROPIC_MODELDefault model ID
ANTHROPIC_DEFAULT_HAIKU_MODELModel used for lightweight tasks (title generation, etc.); pointing it at the same model avoids 404s when the gateway has no haiku model

Install and launch:

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

The Quick start dialog on the API keys page offers a download of the same setup script with your key, model and Base URL already filled in.

Environment variables work too

If you would rather not touch settings.json, export the same variables from your shell profile (usually ~/.zshrc on macOS, ~/.bashrc on Linux) and reopen the terminal:

export ANTHROPIC_BASE_URL="https://<your-base-url>"
export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY"
export ANTHROPIC_MODEL="claude-sonnet-5"

When both are set, the env block in ~/.claude/settings.json wins.

Troubleshooting

SymptomCause and fix
401Wrong or disabled key; make sure it is an OLETOKEN key and that it is in ANTHROPIC_AUTH_TOKEN
404ANTHROPIC_BASE_URL includes /v1 (or a longer path) — keep the host only
Model not foundANTHROPIC_MODEL is not a model listed on this site; copy the ID from the model marketplace
Insufficient balanceTop up first
Switching model on the flyRun /model inside the session

Give each use case its own key (one for the CLI, one for the editor) with a spending limit, so a leak can only cost you that much.