Claude Code
Settings for connecting Claude Code to Claude models through Echo Token Station, and known issues.
Claude Code is Anthropic's AI coding tool. It runs in the terminal and in VS Code. Claude Code connects to Echo in the Anthropic format.
Tested: Claude Code 2.1.278 (2026-09-27, Echo's test environment)
Before you start
- Claude Code uses Claude models. Anthropic does not support using models other than Claude through a relay service (gateway) such as Echo. Anthropic also does not recommend, maintain or audit gateway products
- While an Echo key is set, your claude.ai subscription is not used. Charges are deducted from your Echo balance
- Have your Echo API key and the ID of the Claude model you want to use ready. The Claude models we offer and their IDs are in the model list
Set up
Set it up in the terminal
Set the following environment variables (named values set on your computer). Replace sk-... with your Echo API key and the model IDs with the IDs of the models you want to use.
export ANTHROPIC_BASE_URL="https://token.echohub.io"
export ANTHROPIC_AUTH_TOKEN="sk-..."
export ANTHROPIC_MODEL="claude-sonnet-5"
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-5-5"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5"| Variable | Meaning |
|---|---|
ANTHROPIC_BASE_URL | The base URL. Without /v1. Claude Code adds /v1/messages |
ANTHROPIC_AUTH_TOKEN | Your Echo API key. Sent in the Authorization: Bearer header |
ANTHROPIC_MODEL | The ID of the model to use |
ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL | The IDs of the models used when you choose "opus" or "sonnet" in Claude Code |
ANTHROPIC_DEFAULT_HAIKU_MODEL | The ID of the model used when you choose "haiku" and for background tasks (such as naming sessions) |
- If you do not set a model ID, Claude Code calls its own default model ID. If Echo does not offer that ID, you get an error, and it takes more than a minute to appear (see "Known issues" below)
- Set the three variables such as
ANTHROPIC_DEFAULT_OPUS_MODELto IDs of models that Echo offers as well. If you set an ID that Echo does not offer, you get an error whenever that model is used - If
ANTHROPIC_API_KEYholds another key (such as an Anthropic key), delete it before setting these. Claude Code sends the key in this variable in thex-api-keyheader
Put it in the settings file
To avoid setting them every time, put them in env in ~/.claude/settings.json (%USERPROFILE%\.claude\settings.json on Windows).
{
"env": {
"ANTHROPIC_BASE_URL": "https://token.echohub.io",
"ANTHROPIC_AUTH_TOKEN": "sk-...",
"ANTHROPIC_MODEL": "claude-sonnet-5",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5"
}
}If the same variable is set both in the shell and in the settings file, the value in the settings file is used.
Note: Do not put your key in the project's .claude/settings.json. That file goes into the repository and is shared with others.
Use the VS Code extension
Put them in claudeCode.environmentVariables in your VS Code user settings (open them with the command "Preferences: Open User Settings (JSON)"). The extension checks the credentials in this setting before it starts.
{
"claudeCode.environmentVariables": [
{ "name": "ANTHROPIC_BASE_URL", "value": "https://token.echohub.io" },
{ "name": "ANTHROPIC_AUTH_TOKEN", "value": "sk-..." },
{ "name": "ANTHROPIC_MODEL", "value": "claude-sonnet-5" }
]
}Check that it works
- In the terminal where you set the environment variables, run the following command. If the last line shows
200and above it is JSON containing"type":"message", the base URL and the key are set correctly
curl -sS -w '\n%{http_code}\n' -X POST "$ANTHROPIC_BASE_URL/v1/messages" \
-H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model": "claude-sonnet-5", "max_tokens": 16, "messages": [{"role": "user", "content": "こんにちは"}]}'- In the same terminal, start
claudeand run/status. Check that the base URL ishttps://token.echohub.ioand thatANTHROPIC_AUTH_TOKENis shown as the credential - Ask something. If an answer comes back without errors, you are done. The call also appears in 「呼び出し履歴」 (Call history) in the console
Known issues
The following behavior was checked in Echo's test environment on 2026-09-27.
| Case | What you see in Claude Code | What to do |
|---|---|---|
| Insufficient balance | Failed to authenticate. API Error: 403 Insufficient balance is shown. It says "failed to authenticate", but the cause is the balance, not the key | Top up |
| Wrong key (401), wrong model ID (503), overload (429, 529) | Claude Code keeps retrying before it shows the error. In our test it sometimes showed nothing for more than 60 seconds | To find the cause quickly, check the HTTP status and error body with the curl command above. You can reduce the number of retries with the environment variable CLAUDE_CODE_MAX_RETRIES (10 by default) |
| The upstream API returns an error or the connection is cut in the middle of an answer | No error is shown, and that answer may end partway or be empty | Send the same instruction again. Planned fix: [ ] |
When Claude Code uses the token counting API (/v1/messages/count_tokens) | Echo does not support this API, so Claude Code switches to an estimate based on the number of characters. /context shows an estimate | Nothing to do. It does not affect how you are charged |
Cases where the upstream API returns an error, and the list of error bodies, are in Errors and fixes.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| A login screen appears when Claude Code starts | Claude Code has not read the Echo key | Set ANTHROPIC_AUTH_TOKEN in the shell or in env in ~/.claude/settings.json |
| A warning about two sets of credentials appears when Claude Code starts | Both the claude.ai login and the Echo key are active | Remove the claude.ai login with /logout |
| After a long wait with no answer, a 401 error appears | The key is wrong, stopped or expired, or has used up its spending limit | Check the key's status and spending limit in the console |
404 and Invalid URL (POST /v1/v1/messages) | ANTHROPIC_BASE_URL includes /v1 | Change it to https://token.echohub.io |
Failed to authenticate. API Error: 403 Insufficient balance | Insufficient balance | Top up |
403 and This API key has reached its spending limit | The key's remaining spending limit is not enough | See Limits and rate limits |
After a long wait with no answer, 503 and The model … does not exist or is not available appear | The model ID is wrong, or Echo does not offer the model | Check the model IDs in ANTHROPIC_MODEL and the other variables |
400 with context_management, Extra inputs are not permitted or similar | The upstream API does not accept parameters for Claude Code's experimental features | Set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 |
Claude Code attaches IDs that identify the device and the session to its requests. Echo passes this value unchanged to the upstream Anthropic API. Details are in Data handling.
Sources
| What | Source | Checked |
|---|---|---|
Connecting with the base URL and model environment variables; what you see with insufficient balance, retries and answers that stop partway; the 404 when /v1 is added | Measured in Echo's test environment (Claude Code 2.1.278), with the same relay settings as production and a server that returns test responses in place of the upstream API | 2026-09-27 |
The environment variables for the base URL and key, ANTHROPIC_API_KEY sent as x-api-key, the precedence of the settings file, the VS Code setting, the curl check and /status, the troubleshooting table | https://code.claude.com/docs/en/llm-gateway-connect | 2026-09-27 |
| Models other than Claude are not supported; gateway products are not recommended, maintained or audited; the subscription is no longer used | https://code.claude.com/docs/en/llm-gateway | 2026-09-27 |
Without /v1/messages/count_tokens, token counts are estimated from the number of characters | https://code.claude.com/docs/en/llm-gateway-protocol | 2026-09-27 |
Number of retries and CLAUDE_CODE_MAX_RETRIES | https://code.claude.com/docs/en/errors | 2026-09-27 |