Keep your API Key secure
Use environment variables — never hardcode. Writing your API Key directly into source code or config files risks accidental exposure in version control. Recommended approach:env field in settings.json rather than exposing them in your shell config:
Set a generous timeout
AI model responses can take time, especially for complex reasoning tasks. Set the timeout high enough to avoid premature disconnects:3000000 ms = 50 minutes. This is appropriate for deep reasoning or long agentic tasks.
Clear conflicting environment variables
If you’ve previously used the official Anthropic or OpenAI APIs — or another relay service — stale environment variables may override your BetterToken config and silently send requests to the wrong endpoint. Before configuring BetterToken, check and clear these:Claude Code: don’t set model variables
When connecting to BetterToken, do not setANTHROPIC_MODEL, ANTHROPIC_SMALL_FAST_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, or any other model-specific variables. Claude Code manages model selection internally; BetterToken routes automatically.
Extra model variables don’t help — they can actually cause routing to the wrong model.
Disable non-essential traffic. Setting CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 reduces background requests from Claude Code, reserving your API quota for actual coding tasks.
Use one API Key across multiple tools
The same API Key works simultaneously in Claude Code, Codex CLI, Cursor, and any other tool. Quota is shared, making it easy to manage centrally. If you need to track usage separately per project or team, create multiple API Keys in the dashboard and assign one to each tool or project.Troubleshooting checklist
- Confirm the API Key is correct — check the dashboard, paste carefully with no extra spaces
- Confirm the base_url — must be
https://www.bettertoken.com/v1(note:.com, not.ai) - Check for conflicting env vars — run
echo $ANTHROPIC_AUTH_TOKENto verify nothing is overriding - Check your balance — requests are rejected when the balance is depleted
- Contact support — if the above steps don’t resolve the issue