# Claude Code > Point Anthropic's CLI agent at the gateway with two environment variables — and avoid the one trap that silently bills the wrong key. _Source: https://aiprimetech.io/docs/guides/claude-code/ · Home > Docs > Integration guides_ Claude Code reads its endpoint from the environment, so no patching is needed. This is the most common setup on the gateway. ## Setup ```bash export ANTHROPIC_BASE_URL="https://aiprimetech.io" export ANTHROPIC_AUTH_TOKEN="sk-your-key" claude ``` That is the whole integration. Add both lines to `~/.zshrc` or `~/.bashrc` to make it permanent. > **The trap:** if `ANTHROPIC_API_KEY` is set in your shell, Claude Code may prefer it and bill that key, silently ignoring both your gateway key and any Pro/Max subscription. Run `echo $ANTHROPIC_API_KEY` — if it prints anything, `unset ANTHROPIC_API_KEY` before starting. ## Per-project configuration To scope the gateway to one repo rather than your whole shell, use a settings file: ```json { "env": { "ANTHROPIC_BASE_URL": "https://aiprimetech.io", "ANTHROPIC_AUTH_TOKEN": "sk-your-key" } } ``` Place it at `.claude/settings.json` in the project, or `~/.claude/settings.json` for a user-wide default. Add `.claude/settings.json` to `.gitignore` — it contains a key. ## Verifying it worked ```bash # 1. the gateway answers and the key is valid curl -s -o /dev/null -w "%{http_code}\n" https://aiprimetech.io/v1/models \ -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" # 2. start Claude Code and confirm usage appears in your dashboard claude ``` If requests do not appear in your dashboard, they are going somewhere else — almost always the `ANTHROPIC_API_KEY` trap above. ## Choosing a model ```bash claude --model claude-opus-4-8 ``` Any id from [Models](/docs/getting-started/models/) works. Opus for hard refactors, Sonnet for everyday work — see [Cost control](/docs/guides/cost-control/) for why that choice dominates your bill. ## Keeping the cost sane - Claude Code resends file contents and tool results every turn — long sessions grow expensive non-linearly. Use `/clear` between unrelated tasks. - Large tool outputs (a 500-row query, a whole build log) become permanent context. Pipe through `head` where you can. - Prompt caching helps most here because the system prompt and tool definitions are stable across turns. - [MCP servers](https://aiprimetech.io/docs/guides/mcp-servers/) — Give Claude Code real tools - [Cost control](https://aiprimetech.io/docs/guides/cost-control/) — Where agent tokens go - [Troubleshooting](https://aiprimetech.io/docs/guides/troubleshooting/) — When nothing happens --- _ClaudeAPIKey.dev is an independently operated, Anthropic-compatible API gateway. Not affiliated with Anthropic._