Claude Code
Configure Claude Code to call models through TokenHub.
Claude Code can call TokenHub models through the Anthropic Claude Messages interface. Keep the official installation flow, then replace only the API key, Base URL, and model ID.
The TokenHub endpoint used by this guide is https://us-api.tokenhub.com/v1/messages.
When to use it
Start in a small repository or test project. First ask the tool to read files, explain code, or produce a plan; only then enable edits, terminal commands, or agent automation.
Install or open the tool
Follow the official Claude Code documentation to install or open the tool. If menus or command names differ, prefer the current official documentation.
For CLI tools, confirm the executable works before adding TokenHub credentials:
claude --versionPrepare TokenHub credentials
Create a TokenHub API key and choose a model from the TokenHub model list that fits this tool.
export TOKENHUB_API_KEY="sk-..."Keep the key in your local shell, IDE secret storage, or the secure API key field of the tool. Do not commit it to the repository.
Configure TokenHub persistently
Use the tool configuration file or settings page first. This avoids the common problem where a terminal sees the environment variable but the IDE, plugin, or new window does not.
Provider values
| Field | Value |
|---|---|
| Provider | Anthropic Claude Messages |
| Base URL | https://us-api.tokenhub.com |
| API Key | The value of TOKENHUB_API_KEY |
| Model | claude-sonnet-4 or another TokenHub model ID |
Settings file locations
| Field | Value |
|---|---|
| CLI settings | ~/.claude/settings.json |
| Optional onboarding state | ~/.claude.json |
| Optional VS Code plugin | User settings.json, field claudeCode.environmentVariables |
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"model": "claude-sonnet-4",
"env": {
"ANTHROPIC_BASE_URL": "__API_BASE_URL__",
"ANTHROPIC_AUTH_TOKEN": "sk-...",
"ANTHROPIC_MODEL": "claude-sonnet-4",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-sonnet-4",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-3-5-haiku-latest"
}
}{
"hasCompletedOnboarding": true
}{
"claudeCode.selectedModel": "claude-sonnet-4",
"claudeCode.environmentVariables": [
{
"name": "ANTHROPIC_BASE_URL",
"value": "__API_BASE_URL__"
},
{
"name": "ANTHROPIC_AUTH_TOKEN",
"value": "sk-..."
},
{
"name": "ANTHROPIC_DEFAULT_SONNET_MODEL",
"value": "claude-sonnet-4"
},
{
"name": "ANTHROPIC_DEFAULT_OPUS_MODEL",
"value": "claude-sonnet-4"
},
{
"name": "ANTHROPIC_DEFAULT_HAIKU_MODEL",
"value": "claude-3-5-haiku-latest"
}
]
}If the tool separates chat, edit, apply, and fast models, use the same TokenHub model for the first test. Split models later by cost, latency, and reasoning strength.
Temporary environment variables for debugging
Use temporary variables only to confirm the key, network, and model name. After validation, move the same values into the persistent configuration above.
export TOKENHUB_API_KEY="sk-..."
export ANTHROPIC_BASE_URL="__API_BASE_URL__"
export ANTHROPIC_AUTH_TOKEN="$TOKENHUB_API_KEY"
export ANTHROPIC_MODEL="claude-sonnet-4"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4"
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-sonnet-4"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-3-5-haiku-latest"Verify the connection
Test with a read-only prompt first, confirming that the model can read context without changing files. Then test edits, Apply, or agent tasks.
Read the project README and summarize it in three sentences. Do not modify any files.After a successful prompt, check TokenHub request logs for model name, endpoint, token usage, and billing group.
Troubleshooting
| Symptom | Fix |
|---|---|
| 401 or authentication failure | Confirm TOKENHUB_API_KEY is valid and saved in the same terminal, IDE, or client profile. |
| 404 or model not found | Use a model ID that exists in your TokenHub workspace and matches the selected protocol. |
| Wrong endpoint | Keep the Base URL exactly as shown. OpenAI-compatible tools usually need /v1; Claude-compatible tools usually do not. |
| Request timeout | Check network access to https://us-api.tokenhub.com, proxy settings, and workspace allowlists. |
| Tool uses another model | Recheck every chat, edit, apply, fast, and autocomplete model slot. |
Last updated on