MediumMake Your Claude Code Relay Setup Stick on macOS (zshrc or settings.json) | by jliushi | Oct, 2026 | Medium
Sitemap

Make Your Claude Code Relay Setup Stick on macOS (zshrc or settings.json)

2 min readOct 11, 2026

--

You set ANTHROPIC_BASE_URL in Terminal, Claude Code worked, you closed the window, and the next day it was back to asking for your official login. That's because an export only lives in the current shell. Here are the two ways to make it permanent on a Mac.

First: get a key

Pick a relay from the list at jliushi.github.io/ai-relay. Most let you sign in with GitHub and give free sign-up credit ($70–$100 at the time of testing). In the dashboard, create a key under “Tokens / API Keys” and note the site’s Base URL. If your balance shows $0, log out and back in once.

Option 1: ~/.zshrc

macOS uses zsh by default. Open the file:

nano ~/.zshrc

Add:

export ANTHROPIC_BASE_URL="https://<relay base url>"
export ANTHROPIC_AUTH_TOKEN="<your key>"
export ANTHROPIC_MODEL="claude-opus-5" # only if the model list won't load

Save, then open a new Terminal window and run claude. Ask it "hello". A normal reply means you're done.

Get jliushi’s stories in your inbox

Join Medium for free to get updates from this writer.

Option 2: ~/.claude/settings.json

If you’d rather keep this inside Claude Code’s own config, put the same three values in the env block:

{
"env": {
"ANTHROPIC_BASE_URL": "https://<relay base url>",
"ANTHROPIC_AUTH_TOKEN": "<your key>"
}
}

Things to watch

  • Don’t add /v1 to the Base URL for Claude Code. It appends /v1/messages itself. A wrong path shows up as 404.
  • Copy the model name exactly as the relay lists it.
  • Never commit either file’s key into a repo.
  • Environment variables override your subscription login. To go back to official, delete those lines (not just unset them), then open a new terminal.
  • The relay sees everything you send. Keep work secrets and customer data off it.

Full config walkthrough: guide.

--

--