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.
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"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.
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" }
]
}| 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_, ANTHROPIC_ | The IDs of the models used when you choose "opus" or "sonnet" in Claude Code |
ANTHROPIC_ | 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 you start Claude Code with
claude --model <model ID>or choose a model with/modelduring a session, that choice takes precedence overANTHROPIC_MODEL - 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
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.
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.
claude- Check that the base URL is
https://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
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 ID | Answer | Tool calls | Tool calls while streaming |
|---|---|---|---|
deepseek-v4. | Worked | Worked | Worked |
gpt-6-sol | Worked | Worked | Worked |
gemini-3.8-flash | Worked | Worked | Worked |
kimi-k3 | Worked | Worked | Worked |
glm-5.3 | Worked | Worked | Worked |
qwen3-32b | Worked | Worked | Worked |
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.
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.
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 recognizedand 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 variableCLAUDE_CODE_MAX_CONTEXT_TOKENSto the context length on the model page, in tokens - With models that reason (think before answering), the answer can be empty when
max_tokensis small (Empty or cut-off answers)
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. 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. |
When Claude Code uses the token counting API (/) | 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 ~/ |
| 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 (401 Invalid API key) |
404 and Invalid URL (POST / | ANTHROPIC_BASE_URL includes /v1 | Change it to https:/ |
Failed to authenticate. | Insufficient balance | Top up (403 insufficient_quota) |
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 temporarily unavailable appear | The model ID is wrong, or Echo does not offer the model | Check the model IDs in ANTHROPIC_MODEL and the other variables (503 model_not_found) |
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_ |
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.