DocsClaude Code setup

Set up Claude Code with MYUSAPI: base URL and API key

Set four environment variables and Claude Code calls Claude Opus 5.5 and Sonnet 5.5 through MYUSAPI. Models are never swapped or downgraded, and you are billed by the usage the upstream reports.

Tested 2026-11-12: macOS, Claude Code 2.1.322, not signed in to claude.ai. claude-opus-5-5 and claude-sonnet-5-5 each completed a file-read tool call, and the settings.json method worked. The Windows commands and CC Switch were not rerun.

1Sign up and get an API key

Sign up with email or Google. Once you add credit, your workspace creates your key (it starts with sk-).

Sign up and get an API key

2Set the variables and start

Run these lines in your terminal, replacing sk-your-key with your key. The last line starts Claude Code.

macOS / Linux

Terminal
export ANTHROPIC_BASE_URL="https://myusapi.com"
export ANTHROPIC_AUTH_TOKEN="sk-your-key"
export ANTHROPIC_MODEL="claude-opus-5-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-5-5"
claude

Windows PowerShell

PowerShell
$env:ANTHROPIC_BASE_URL = "https://myusapi.com"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-key"
$env:ANTHROPIC_MODEL = "claude-opus-5-5"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "claude-haiku-5-5"
claude
ANTHROPIC_BASE_URLWhere requests go: https://myusapi.com. Leave /v1 off; Claude Code adds it.
ANTHROPIC_AUTH_TOKENYour MYUSAPI API key (it starts with sk-).
ANTHROPIC_MODELThe main model’s ID, for example claude-opus-5-5 or claude-sonnet-5-5.
ANTHROPIC_DEFAULT_HAIKU_MODELThe model Claude Code uses for small background tasks: claude-haiku-5-5.

3Check that it works

Ask Claude Code anything; a reply means you are connected. Then open Usage in your workspace to see the model, tokens and charge for that call.

Open usage

Make it permanent: settings.json

Environment variables last only for the current terminal window. Put the same four in the "env" block of ~/.claude/settings.json and plain claude works from then on. If the file already has content, merge in only the "env" block.

~/.claude/settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://myusapi.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-your-key",
    "ANTHROPIC_MODEL": "claude-opus-5-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5"
  }
}

Switch models

Change ANTHROPIC_MODEL to a model ID from this table, or type /model inside Claude Code.

ModelInput / 1MOutput / 1MCache read / 1M
Claude Opus 5.5claude-opus-5-5Official$4.00, our price$1.00Official$20.00, our price$5.00$0.05
Claude Opus 4.8claude-opus-4-8Official$5.00, our price$1.00Official$25.00, our price$5.00$0.05
Claude Fable 5.2claude-fable-5-2Official$8.00, our price$2.64Official$40.00, our price$13.20$0.066
Claude Fable 5.1claude-fable-5-1Official$10.00, our price$3.30Official$50.00, our price$16.50$0.0825
Claude Sonnet 5.5claude-sonnet-5-5Official$2.00, our price$0.50Official$10.00, our price$2.50$0.025
Claude Haiku 5.5claude-haiku-5-5Official$0.10, our price$0.025Official$0.50, our price$0.125$0.0025

USD per 1M tokens. The struck figure is the official standard list price; bold is ours. All models and prices

Prefer no terminal: CC Switch

CC Switch is an open-source desktop switcher: enter the endpoint and key once in its window and Claude Code uses them. Leave /v1 off the endpoint here too, and keep the default ANTHROPIC_AUTH_TOKEN auth field. The connection guide can import your key in one click.

Open the connection guide

Common questions

Do I need a Claude subscription or a claude.ai sign-in?

No. With these variables set, Claude Code calls with your API key and usage is charged to your prepaid MYUSAPI credit.

What if I get a 401 or 403?

A 401 usually means the key is wrong or disabled; a 403 usually means this key cannot call the model you chose. GET /v1/models shows what the key can call now, and the error page lists what each code means and how to fix it.

Next