APIMaster.ai

Claude Code API Key — Environment Variable Configuration

How to configure Claude Code CLI with a custom API key using environment variables. Set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN to point Claude Code at APIMaster.ai for discounted Claude access.

Claude Code

Claude Code can use a custom API endpoint.

Full walkthrough (Windows / macOS, settings.json): CLI setup → Claude Code.

Environment variables

export ANTHROPIC_BASE_URL="https://apimaster.ai"
export ANTHROPIC_API_KEY="YOUR_APMASTER_API_KEY"

Start claude in that shell and pick a model, e.g.:

/model claude-sonnet-4-6

Variable names follow the Claude Code version you run (ANTHROPIC_AUTH_TOKEN vs ANTHROPIC_API_KEY — use one).

Troubleshooting

Issue What to try
401 Key from APIMaster console, not expired
Model missing Check supported models
Truncated output Raise max_tokens for thinking models
SSL errors Use https:// and the correct host

You can also route via the OpenAI-compatible path if your plugin expects Chat Completions.