
Claude Code has two variables for the key. Our API accepts both, so the choice does not change what you pay. It changes the header the key travels in and how Claude Code treats it.
The difference
| Variable | How the key is sent | What the Claude Code documentation says |
| ANTHROPIC_AUTH_TOKEN | In the Authorization: Bearer ... header | A custom value for the Authorization header. Claude Code adds Bearer in front. |
| ANTHROPIC_API_KEY | In the x-api-key header | When set, it is used instead of your Claude subscription, even if you are signed in. In interactive mode, Claude Code asks you once to approve the key. |
Which one we recommend
ANTHROPIC_AUTH_TOKEN, as in the docs examples. Set only one of the two: that way you always know which key Claude Code sends.
export ANTHROPIC_AUTH_TOKEN="$MOZOUT_API_KEY"
$MOZOUT_API_KEY copies the key from the variable where you already keep it. In settings.json it works differently: there, the key is written exactly as it is. See saving the setup in settings.json.
If you use ANTHROPIC_API_KEY
|
|
|
Neither one works for the MCP server
In the header of a remote MCP server, Claude Code reads ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY as empty, so that a project file cannot send your credentials to another server. In .mcp.json, use ${MOZOUT_API_KEY}, even if it holds the same key. See sharing the MCP setup in .mcp.json.
| A 401 means the key did not arrive or is wrong. Check that the variable exists in the terminal where you opened Claude Code, without showing it on screen: |
test -n "$ANTHROPIC_AUTH_TOKEN" && echo OK || echo missing
If it says "missing", set the variable and open Claude Code again.
|
Want to code with AI in Claude Code? Visit the Coding with AI page. See Coding with AI |
RECOMMENDED PRODUCT Web hosting with cPanel Domain and SSL included, daily backups and the panel you already know. from $6.60/mo (3-year plan, with coupon) See plans |











