DocsClaude Code

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.

bash
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"
VariableMeaning
ANTHROPIC_BASE_URLThe base URL. Without /v1. Claude Code adds /v1/messages
ANTHROPIC_AUTH_TOKENYour Echo API key. Sent in the Authorization: Bearer header
ANTHROPIC_MODELThe ID of the model to use
ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODELThe IDs of the models used when you choose "opus" or "sonnet" in Claude Code
ANTHROPIC_DEFAULT_HAIKU_MODELThe 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_MODEL to 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_KEY holds another key (such as an Anthropic key), delete it before setting these. Claude Code sends the key in this variable in the x-api-key header

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).

JSON
{
  "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.

JSON
{
  "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

  1. In the terminal where you set the environment variables, run the following command. If the last line shows 200 and above it is JSON containing "type":"message", the base URL and the key are set correctly
bash
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": "こんにちは"}]}'
  1. In the same terminal, start claude and run /status. Check that the base URL is https://token.echohub.io and that ANTHROPIC_AUTH_TOKEN is shown as the credential
  2. 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.

CaseWhat you see in Claude CodeWhat to do
Insufficient balanceFailed to authenticate. API Error: 403 Insufficient balance is shown. It says "failed to authenticate", but the cause is the balance, not the keyTop 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 secondsTo 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 answerNo error is shown, and that answer may end partway or be emptySend 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 estimateNothing 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

SymptomCauseFix
A login screen appears when Claude Code startsClaude Code has not read the Echo keySet ANTHROPIC_AUTH_TOKEN in the shell or in env in ~/.claude/settings.json
A warning about two sets of credentials appears when Claude Code startsBoth the claude.ai login and the Echo key are activeRemove the claude.ai login with /logout
After a long wait with no answer, a 401 error appearsThe key is wrong, stopped or expired, or has used up its spending limitCheck the key's status and spending limit in the console
404 and Invalid URL (POST /v1/v1/messages)ANTHROPIC_BASE_URL includes /v1Change it to https://token.echohub.io
Failed to authenticate. API Error: 403 Insufficient balanceInsufficient balanceTop up
403 and This API key has reached its spending limitThe key's remaining spending limit is not enoughSee Limits and rate limits
After a long wait with no answer, 503 and The model … does not exist or is not available appearThe model ID is wrong, or Echo does not offer the modelCheck the model IDs in ANTHROPIC_MODEL and the other variables
400 with context_management, Extra inputs are not permitted or similarThe upstream API does not accept parameters for Claude Code's experimental featuresSet 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

WhatSourceChecked
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 addedMeasured 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 API2026-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 tablehttps://code.claude.com/docs/en/llm-gateway-connect2026-09-27
Models other than Claude are not supported; gateway products are not recommended, maintained or audited; the subscription is no longer usedhttps://code.claude.com/docs/en/llm-gateway2026-09-27
Without /v1/messages/count_tokens, token counts are estimated from the number of charactershttps://code.claude.com/docs/en/llm-gateway-protocol2026-09-27
Number of retries and CLAUDE_CODE_MAX_RETRIEShttps://code.claude.com/docs/en/errors2026-09-27