Skip to main content
Claude Code can route Anthropic Messages requests through Yelu. The configuration uses the gateway root URL https://api.yelu.ai; Claude Code appends /v1/messages itself.
Use a model returned by GET /v1/models. The commands below use claude-sonnet-4-6, which is supported by the Yelu gateway but may need to be enabled for your key.

Configuration at a glance

Do not add /v1 to ANTHROPIC_BASE_URL. Doing so would produce an invalid /v1/v1/messages path.

macOS

1. Install Claude Code

The native installer is the recommended installation method:
macOS
Homebrew is also supported:
macOS

2. Configure the current terminal

Copy a key from the Yelu Console, then run:
macOS
This keeps the key out of shell history. These variables last until the terminal closes.

3. Persist non-secret settings

Add the following lines to ~/.zshrc:
~/.zshrc
Then reload the profile:
macOS
Load YELU_API_KEY from your secret manager at login and set ANTHROPIC_AUTH_TOKEN="$YELU_API_KEY". Do not commit keys to a repository or store them in a shared shell profile.

Windows

Native PowerShell

Install without opening PowerShell as Administrator:
Windows PowerShell
Configure the current PowerShell session without echoing the key:
Windows PowerShell
Persist the non-secret settings for future terminals:
Windows PowerShell
Open a new terminal after changing user-level variables. Load the key from your Windows credential manager or enter it at the start of each session. A user environment variable is convenient but is not a secret store. Git for Windows is optional. If installed but Claude Code cannot locate Git Bash, add this to %USERPROFILE%\.claude\settings.json:
Claude settings

WSL 2

Use WSL 2 when the repository and toolchain live in Linux or when you need Claude Code sandboxing. Install and configure Claude Code inside the WSL terminal, not in PowerShell:
WSL 2
For WSL, persistent shell settings belong in ~/.bashrc or ~/.zshrc inside the Linux distribution. Windows user environment variables are not a reliable substitute for WSL shell variables.

Optional settings file

Claude Code reads ~/.claude/settings.json on macOS and %USERPROFILE%\.claude\settings.json on Windows. This safe global configuration persists the URL and model discovery without storing a key:
Claude settings
Use .claude/settings.local.json for project-local secrets and ensure it is ignored by Git. Never put a key in the shared .claude/settings.json inside a repository.

Verify the gateway

Test the API before starting Claude Code:
Then start Claude Code from the same terminal:
Terminal
Run /status inside Claude Code. Anthropic base URL should show https://api.yelu.ai, and the credential source should be ANTHROPIC_AUTH_TOKEN. Run /model to select another model exposed by your Yelu account.

Update and diagnose

Terminal

Next step

Continue with the Claude Code examples for repository exploration, implementation, review, and automation workflows.

Official references

Last modified on July 13, 2026