Claude Code
Connect Claude Code to RealRelay.ai through the Anthropic Messages endpoint: install it, point ANTHROPIC_BASE_URL at RealRelay.ai, check the connection and choose models.
- Protocol
- Anthropic Messages
- Base URL
https://www.realrelay.ai- Official docs
- code.claude.com
- Checked against the tool’s docs
- 2026-10
Overview
Claude Code is Anthropic's coding agent for the terminal. It reads your project, edits files and runs commands after you approve them. It speaks the Anthropic Messages protocol, so it connects to RealRelay.ai's /v1/messages endpoint.
An API key from the API keys page of the console.
The base URL is the site address without
/v1. Claude Code appends/v1/messagesitself, so adding it yourself gives a 404.A model ID exactly as
GET /v1/modelslists it, for exampleanthropic/claude-sonnet-4-6.
Anthropic supports Claude Code with Claude models only. Other models in the catalog are reachable through protocol translation, but tool use and extended thinking on them are best effort.
Install
Use Anthropic's installer. It needs no Node.js and updates itself in the background. On Windows, Claude Code also needs Git for Windows; see Anthropic's setup guide if the installer asks for it.
curl -fsSL https://claude.ai/install.sh | bashclaude --versionirm https://claude.ai/install.ps1 | iexclaude --versionnpm install -g @anthropic-ai/claude-codeIf claude --version prints a version number, the install worked. If the command is not found, open a new terminal so it picks up the updated PATH.
Configure
Put the settings in ~/.claude/settings.json. Claude Code reads that file on every start, whichever terminal or IDE launches it, and its values win over variables exported in your shell. Replace sk-*** with your key.
1{2 "env": {3 "ANTHROPIC_BASE_URL": "https://www.realrelay.ai",4 "ANTHROPIC_AUTH_TOKEN": "sk-***",5 "ANTHROPIC_API_KEY": "",6 "ANTHROPIC_MODEL": "anthropic/claude-sonnet-4-6",7 "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1"8 }9}1export ANTHROPIC_BASE_URL="https://www.realrelay.ai"2export ANTHROPIC_AUTH_TOKEN="sk-***"3export ANTHROPIC_API_KEY=""4export ANTHROPIC_MODEL="anthropic/claude-sonnet-4-6"5export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1Run source ~/.zshrc, or open a new terminal, before starting Claude Code.
1[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://www.realrelay.ai", "User")2[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk-***", "User")3[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "anthropic/claude-sonnet-4-6", "User")4[Environment]::SetEnvironmentVariable("CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY", "1", "User")These are saved for your user account. Close and reopen the terminal before starting Claude Code.
ANTHROPIC_AUTH_TOKENsends the key as a bearer token.ANTHROPIC_API_KEYis set to an empty string on purpose, so a key left over from an Anthropic account cannot take priority.CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERYfills the/modelpicker from RealRelay.ai's model list.Keep the key out of a project's
.claude/settings.json, which is usually committed. For one project only, use.claude/settings.local.json.
Verify
- 1
Call the endpoint directly
Run this with your key before opening Claude Code. A JSON reply whose
idstarts withmsg_means the address, key and model work.Terminal 1curl -sS "https://www.realrelay.ai/v1/messages" \2 -H "Authorization: Bearer sk-***" \3 -H "anthropic-version: 2023-06-01" \4 -H "content-type: application/json" \5 -d '{"model": "anthropic/claude-sonnet-4-6", "max_tokens": 16, "messages": [{"role": "user", "content": "Reply with OK"}]}' - 2
Start Claude Code in a project
If you were signed in with an Anthropic account, run
/logoutonce first. Then startclaudeand run/status.Claude Code cd /path/to/your/projectclaude/status - 3
Check the status screen
The Anthropic base URL line should show RealRelay.ai, and the credential should come from
ANTHROPIC_AUTH_TOKEN. Send a short message; the reply confirms the whole path. Requests then appear in the console's usage logs.
Models
Switch models in a session with /model, or start with claude --model followed by a model ID. Claude Code does not check the name before the first request, so a typo shows up as an error on your first message.
Claude Code also sends background work, such as titles and summaries, to its Haiku slot, and its built-in name for that slot is not an ID RealRelay.ai lists. Point each alias at a model your key can call:
"ANTHROPIC_DEFAULT_OPUS_MODEL": "anthropic/claude-sonnet-4-6","ANTHROPIC_DEFAULT_SONNET_MODEL": "anthropic/claude-sonnet-4-6","ANTHROPIC_DEFAULT_HAIKU_MODEL": "anthropic/claude-sonnet-4-6"Claude models served natively on /v1/messages are listed under Choosing a model.
Troubleshooting
401 or "Invalid token". The key is not reaching RealRelay.ai. Check
/statusfor where the credential comes from. A token exported as"$OTHER_VAR"is empty if that variable is defined later in your profile.A warning about two credential sources. You are still signed in to an Anthropic account. Run
/logout.404. The base URL ends in
/v1. Remove it.400 naming unknown fields such as
context_management: turn off Claude Code's experimental request fields.~/.claude/settings.json → env "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"Context errors, or no automatic compaction on a model with a smaller window than Claude Code assumes. Run
/compact, then set the window to the model's limit (minimum 100,000).~/.claude/settings.json → env "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "200000"Settings seem ignored. Values in
settings.jsonwin over shell variables, and Claude Code installed with the native installer does not read a project's.envfile.Errors for
/v1/messages/count_tokensin debug output. RealRelay.ai does not serve that endpoint. Messages themselves are not sent through it.
