# How do I point Claude Code at a custom base URL?

Claude Code reads its API address from one setting. Change two values and it works with any Anthropic-compatible API, Outrun included.

Published November 13, 2026 by Outrun.

**Short answer:** set `ANTHROPIC_BASE_URL` to the API address and `ANTHROPIC_AUTH_TOKEN` to your key, then open a new terminal. For Outrun the address is `https://api.outrun.to`, with no `/v1` on the end.

## Fastest way: one setup prompt

Copy this prompt into an AI assistant that can edit files on your computer. It tells the assistant to back up your settings, add the lines for your operating system and leave a `KEY` placeholder that you fill in yourself.

```
Set up Claude Code on this computer to use Outrun (Anthropic Messages API).

First detect my operating system (Windows, macOS or Linux) and my shell, and follow only the matching steps. Back up every file before changing it, and merge into existing settings instead of overwriting unrelated ones.

1. If Claude Code is not installed, install it: npm install -g @anthropic-ai/claude-code.
2. The base URL is the bare host https://api.outrun.to with no /v1 at the end. Set up every Outrun Claude model: claude-opus-5-5 (default), claude-opus-5, claude-sonnet-5-5, claude-sonnet-5, claude-fable-5-1 and claude-fable-5.
3. Windows: merge this into %USERPROFILE%\.claude\settings.json and remove any ANTHROPIC_API_KEY entry:
{"model": "claude-opus-5-5", "env": {"ANTHROPIC_BASE_URL": "https://api.outrun.to", "ANTHROPIC_AUTH_TOKEN": "KEY", "ANTHROPIC_MODEL": "claude-opus-5-5", "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5", "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-5", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5"}}
   Then give me PowerShell commands to set ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_MODEL=claude-opus-5-5, ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5, ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5-5 and ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-5-5 as User environment variables and to delete the User variable ANTHROPIC_API_KEY.
4. macOS / Linux: add these lines to both ~/.zshrc and ~/.bashrc, replacing older ANTHROPIC_* lines for other providers:
export ANTHROPIC_BASE_URL="https://api.outrun.to"
export ANTHROPIC_AUTH_TOKEN="KEY"
export ANTHROPIC_MODEL="claude-opus-5-5"
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-5-5"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-5-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-5-5"
5. Tell me that every Claude model is ready and that I switch inside Claude Code with /model  (claude-opus-5, claude-sonnet-5-5, claude-sonnet-5, claude-fable-5-1, claude-fable-5).
6. Tell me to run /logout in Claude Code if I was signed in with an Anthropic account, and to accept the custom API key when Claude Code asks.

API key rule: never ask me to paste my Outrun API key into this chat, and never print, log or commit it. Wherever the key is needed, write the literal placeholder KEY, then tell me exactly which file or command to open so I can replace KEY with my own key myself (I get it from @outrunAPI_Bot -> My API key; it starts with sk-rs-).

When everything is in place, tell me to restart the app or open a new terminal, then give me one short test I can run myself. The test uses a tiny amount of Outrun Credit. Do not create, edit or delete any project files as part of the test.
```

You can read the prompt first in the [setup guide](https://outrun.to/docs/setup/claude#setup-helper). To do it by hand, follow the steps below.

## Set the values by hand

macOS or Linux: add these lines to `~/.zshrc` and `~/.bashrc`.

```
export ANTHROPIC_BASE_URL="https://api.outrun.to"
export ANTHROPIC_AUTH_TOKEN="KEY"
export ANTHROPIC_MODEL="claude-opus-5-5"
```

Windows: run these in PowerShell.

```
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.outrun.to", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "KEY", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "claude-opus-5-5", "User")
```

- Replace `KEY` with your own key. Keep it out of AI chats and screenshots.

- Remove any `ANTHROPIC_API_KEY` setting. Having both set causes an authentication conflict.

- Close every terminal and editor window, then open a new one.

## Check it worked

- Run `claude`. If you are signed in with an Anthropic account, run `/logout` first.

- Run `/status`. It shows the base URL in use and the current model.

- Send "Reply with OK only." A short reply with no connection error means it works. The test uses a little credit.

## Set a model for each slot

Claude Code has an Opus, a Sonnet and a Haiku slot. Point each one at a model your API serves. On Windows, set the same three names in PowerShell.

```
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-5-5"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-5-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-5-5"
```

Switch during a session with `/model` and the model ID. [Prices for every model](https://outrun.to/pricing). To estimate a day of your own usage, use the [Claude Code cost calculator](https://outrun.to/claude-code-cost).

## Usual errors

- **401 or invalid key:** the key is mistyped, or `ANTHROPIC_API_KEY` is still set.

- **404 or 400:** the base URL has `/v1` or `/messages` added, or the model ID is wrong.

- **402:** check your balance and the key's spending cap.

## Go back to your Anthropic account

Remove the lines you added and open a new terminal. If Claude Code does not pick up your saved login, run `/login`.

Step-by-step version for Windows, macOS and Linux: [Claude Code setup guide](https://outrun.to/docs/setup/claude). No key yet? [Get an API key](https://outrun.to/key).
