SwiftRelay

← All sprint notes

Claude Code Base URL: Your First-Run Checklist

Agent quick startsEN

Your first lap: understand ANTHROPIC_BASE_URL

Connecting Claude Code to a relay should not require rebuilding your terminal setup. The safest approach is to test one setting first, then save it only after you know it works.

ANTHROPIC_BASE_URL tells Claude Code where to send its API requests. It changes the destination, not your credentials or account balance. You still need credentials accepted by that destination.

For SwiftRelay, use https://api.fastapirelay.com. Claude Code takes this bare host: do not add /v1. That suffix belongs to SwiftRelay configurations for OpenAI-compatible SDKs, not this Claude Code setting.

Test the relay address without editing a file

Start with a command that applies the address to just one Claude Code launch:

ANTHROPIC_BASE_URL=https://api.fastapirelay.com claude

This syntax works in bash and zsh. It leaves your shell profile untouched and does not change the address for later commands. Exit Claude Code when you finish testing.

You must also configure authentication using the instructions supplied by your relay. Do not assume an existing direct-provider login will authenticate against a different destination. Avoid setting several competing authentication variables while troubleshooting; follow the relay's documented method.

SwiftRelay is a pay-as-you-go option with per-token billing, and new accounts receive a small gift credit. Sign up for SwiftRelay, obtain your API credentials, and follow its Claude Code authentication instructions before testing a small request. Treat those credentials like passwords.

Find the profile your shell actually reads

A shell profile is a startup file containing commands your shell runs when it opens. Putting a setting in the wrong file can make it appear to disappear between terminals.

Run ps -p $$ -o comm= in a normal terminal session to identify the running shell. Then choose the appropriate startup file:

  • zsh: ~/.zshrc is normally the right place for settings used in interactive terminals.
  • bash: ~/.bashrc is read by interactive non-login shells. Login shells read the first available file among ~/.bash_profile, ~/.bash_login, and ~/.profile.
  • fish or PowerShell: stop before pasting these examples. Their environment-setting syntax and startup files differ.

With bash, inspect your existing setup before changing anything. A login profile may already load ~/.bashrc. Do not create a new login profile blindly: it can prevent another existing profile from being read.

Back up the profile and add one export

Open the chosen file in a text editor and inspect it first. If it exists, make a backup with a distinct filename. For example, cp ~/.zshrc ~/.zshrc.before-swiftrelay copies a zsh profile; choose another backup name if that destination already exists.

Search for ANTHROPIC_BASE_URL. Update an existing assignment instead of adding another one. Multiple assignments make troubleshooting confusing because a later assignment can replace an earlier value.

Add this as its own line, outside any existing conditional block or function:

export ANTHROPIC_BASE_URL="https://api.fastapirelay.com"

Use straight quotation marks, and leave no spaces around the equals sign. Do not replace the whole file with this line or paste instructions into an unfinished command.

Keep credentials out of screenshots and shared profile files. The base URL is not a secret, but an API key is.

Check the saved address in a new terminal

Save the file and open a new terminal window. This tests your normal startup process without manually re-running every command in the profile.

Run printenv ANTHROPIC_BASE_URL. It should print https://api.fastapirelay.com. Then launch claude and try a small request.

If the variable is empty, check the startup file selection. If the address is correct but authentication fails, check credentials separately. A correct destination does not prove that authentication is configured correctly.

Undo the base URL without resetting your profile

To remove the setting from your current shell, run unset ANTHROPIC_BASE_URL. To remove it permanently, delete its export line from the startup file and open a new terminal. Restart Claude Code too: running processes keep the environment they inherited at launch.

Keep reading

Back for another lap?Log in