Using with Claude Code
Claude Code is Anthropic's agentic coding tool for the terminal. It understands your project context and turns natural-language requests into real code changes, debugging, test runs and maintenance work. It works directly in your project directory and fits into an existing command-line workflow.
Before you start
- Create a usable token on the API keys page.
- Make sure the token's group can call the Claude models you want.
- Never commit a real token into a repository, a screenshot or a chat log.
The path is: create a token → configure Claude Code → send one short test message → check the request in the usage logs.
Install Claude Code
On macOS, Linux or WSL the official native installer is recommended:
curl -fsSL https://claude.ai/install.sh | bashWindows PowerShell:
irm https://claude.ai/install.ps1 | iexHomebrew and WinGet also work:
brew install --cask claude-codewinget install Anthropic.ClaudeCodeTemporary configuration
Set the environment variables in your current terminal:
export ANTHROPIC_BASE_URL="https://api.tokendns.net"
export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY"
export ANTHROPIC_MODEL="claude-sonnet-4-6"Then enter your project directory and run:
claudeDo not append /v1 to ANTHROPIC_BASE_URL; Claude Code requests /v1/messages itself. ANTHROPIC_AUTH_TOKEN is sent as Authorization: Bearer ..., which is what gateways like TokenDNS expect.
Persistent configuration
Non-sensitive settings can live in ~/.claude/settings.json, with the token injected from your shell environment:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.tokendns.net",
"ANTHROPIC_MODEL": "claude-sonnet-4-6",
"CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1"
}
}CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 makes recent versions of Claude Code fetch the available models from the gateway's /v1/models. Whether a particular model shows up still depends on the token's group and the platform's current catalogue.
Verify and troubleshoot
After starting, run /status and /model to confirm that requests go to the TokenDNS endpoint with the model you expect. Common issues:
401: check thatANTHROPIC_AUTH_TOKENis set in the same terminal that launched Claude Code.404or a duplicated path segment: make sure the base URL ishttps://api.tokendns.netwith no/v1.- Model unavailable: check the model ID and token group on the model list, or enable gateway model discovery.
- Still routed through the gateway after signing in to an official subscription: this is expected.
ANTHROPIC_AUTH_TOKENtakes precedence over subscription OAuth; unset the corresponding environment variables to stop using the gateway.
Tip: you can also import the configuration from the API keys page through CC-Switch. Either way, verify the effective authentication method and model with
/status.
Quick Start
Welcome to TokenDNS. This guide is written for anyone new to API keys, the command line and AI tools. Finish sign-up, sign-in, token creation and top-up in order, and you are ready to configure the tool you use most.
Using with CC Switch
CC Switch is a helper for configuring and managing model routing. This page covers installing it, adding TokenDNS as a provider, and verifying the setup in Claude Code.
