BLACK FRIDAYUntil Dec 8 (Tue) 23:59 JSTUntil Dec 8

DocsClaude Code

Claude Code (use Claude, DeepSeek, GPT and Gemini)

Settings for connecting Claude Code to Echo Token Station and using Claude models as well as models from other companies such as DeepSeek, GPT and Gemini. Covers the environment variables, how to check that it works, 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. With Echo as the base URL, you can use Claude models and also models from other companies that Echo offers, such as DeepSeek, GPT and Gemini, by changing the model ID.

Tested: Claude Code 2.1.278 (2026-09-27, Echo's test environment). Models other than Claude were checked with Echo's API on 2026-11-23 (Use models other than Claude)

Before you start

  • Have your Echo API key and the ID of the model you want to use ready. The models we offer and their IDs are in the model list
  • While an Echo key is set, your claude.ai subscription is not used. Charges are deducted from your Echo balance

1. Set the base URL, key and models

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 you start Claude Code with claude --model <model ID> or choose a model with /model during a session, that choice takes precedence over ANTHROPIC_MODEL
  • 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

2. Check the base URL and key

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": "Hello"}]}'

If something other than 200 is shown, find the cause from the HTTP status and the error body in Errors and fixes.

3. Check that it works

In the same terminal, start Claude Code and run /status.

bash
claude
  1. 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

Use models other than Claude

Change the model IDs in the settings above to the IDs of models other than Claude. 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.

The table below shows what we checked on 2026-11-23 with Echo's API (/v1/messages in the Anthropic format, the same endpoint that Claude Code calls). Tool calls are how Claude Code reads and writes files and runs commands.

Model IDAnswerTool callsTool calls while streaming
deepseek-v4.1-flashWorkedWorkedWorked
gpt-6-solWorkedWorkedWorked
gemini-3.8-flashWorkedWorkedWorked
kimi-k3WorkedWorkedWorked
glm-5.3WorkedWorkedWorked
qwen3-32bWorkedWorkedWorked

The IDs of other models are in the model list. We have not checked models that are not in the table.

1. Change the model IDs

Change the four model variables from "1. Set the base URL, key and models" to the ID of the model you want to use. This example uses a DeepSeek model.

bash
export ANTHROPIC_BASE_URL="https://token.echohub.io"
export ANTHROPIC_AUTH_TOKEN="sk-..."
export ANTHROPIC_MODEL="deepseek-v4.1-flash"
export ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-v4.1-flash"
export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4.1-flash"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4.1-flash"

If you do not change ANTHROPIC_DEFAULT_HAIKU_MODEL, background tasks (such as naming sessions) are still sent to a Claude model, and you are charged for them.

2. Check that it works

Check that the model can be called with curl, using the new model ID. If the last line shows 200, the model can be called.

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": "deepseek-v4.1-flash", "max_tokens": 256, "messages": [{"role": "user", "content": "Hello"}]}'

Then start claude, ask something and check that an answer comes back.

  • Claude Code does not know the model ID, so at startup it shows a warning containing isn't recognized and assumes a provisional context length (the number of tokens the model can handle at once). If the model's context length is shorter than the assumed value, the upstream API may return an error once the conversation gets long (Input too long). Set the environment variable CLAUDE_CODE_MAX_CONTEXT_TOKENS to the context length on the model page, in tokens
  • With models that reason (think before answering), the answer can be empty when max_tokens is small (Empty or cut-off answers)

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.
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 (401 Invalid API key)
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 insufficient_quota)
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 temporarily unavailable appearThe model ID is wrong, or Echo does not offer the modelCheck the model IDs in ANTHROPIC_MODEL and the other variables (503 model_not_found)
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.