---
title: "Claude Code setup: custom base URL and API key | MYUSAPI"
description: "Connect Claude Code to MYUSAPI: set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, then pick Claude Opus 5.5 or Sonnet 5.5. Windows and settings.json steps included."
url: https://myusapi.com/en/docs/claude-code
---

# 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.

## 1 Sign 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](https://myusapi.com/en/signup)

## 2 Set 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

```
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

```
$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_URL: Where requests go: https://myusapi.com. Leave /v1 off; Claude Code adds it.
- ANTHROPIC_AUTH_TOKEN: Your MYUSAPI API key (it starts with sk-).
- ANTHROPIC_MODEL: The main model’s ID, for example claude-opus-5-5 or claude-sonnet-5-5.
- ANTHROPIC_DEFAULT_HAIKU_MODEL: The model Claude Code uses for small background tasks: claude-haiku-5-5.

## 3 Check 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](https://myusapi.com/en/workspace?tab=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.

```
{
  "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.

| Model | Input / 1M | Output / 1M | Cache read / 1M |
| --- | --- | --- | --- |
| [Claude Opus 5.5](https://myusapi.com/en/models/claude-opus-5-5) claude-opus-5-5 | Official $4.00, our price $1.00 | Official $20.00, our price $5.00 | $0.05 |
| [Claude Opus 4.8](https://myusapi.com/en/models/claude-opus-4-8) claude-opus-4-8 | Official $5.00, our price $1.00 | Official $25.00, our price $5.00 | $0.05 |
| [Claude Fable 5.2](https://myusapi.com/en/models/claude-fable-5-2) claude-fable-5-2 | Official $8.00, our price $2.64 | Official $40.00, our price $13.20 | $0.066 |
| [Claude Fable 5.1](https://myusapi.com/en/models/claude-fable-5-1) claude-fable-5-1 | Official $10.00, our price $3.30 | Official $50.00, our price $16.50 | $0.0825 |
| [Claude Sonnet 5.5](https://myusapi.com/en/models/claude-sonnet-5-5) claude-sonnet-5-5 | Official $2.00, our price $0.50 | Official $10.00, our price $2.50 | $0.025 |
| [Claude Haiku 5.5](https://myusapi.com/en/models/claude-haiku-5-5) claude-haiku-5-5 | Official $0.10, our price $0.025 | Official $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](https://myusapi.com/en/models)

## 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](https://myusapi.com/en/docs/tools)

## 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

- [Claude Opus 5.5 API: pricing and how to call it](https://myusapi.com/en/models/claude-opus-5-5)
- [Set up Codex CLI with MYUSAPI: a custom provider in config.toml](https://myusapi.com/en/docs/codex-cli)
- [Error codes and retries](https://myusapi.com/en/docs/errors)
