Skip to content
BENIBIX Learn

ANTHROPIC_API_KEY vs ANTHROPIC_AUTH_TOKEN

People think ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN are two names for one key. They send different headers to different checkers. The API key is a Console key. It goes out as X-Api-Key, and Anthropic checks it. The token goes out as a Bearer header, and a gateway checks it. When both are set, the token wins. Use the key to reach Anthropic, and the token to reach your gateway.

AI⌨️ Claude Code

ANTHROPIC_API_KEY

It gives Claude Code an API key to sign in and pay with.

ANTHROPIC_API_KEY gives Claude Code a key from the Claude Console. Claude Code sends it in the X-Api-Key header and bills that account. When it is set, it is used in place of your Pro or Max plan, even if you are logged in. In a chat you are asked once to allow it. With -p it is always used.

Example
Jack's CI job sets ANTHROPIC_API_KEY from a secret. Each run then signs in with the team's key, with no browser and no login.
Why it matters
It is the plain way to run Claude Code in a script, and it decides who pays.
Full entry
AI⌨️ Claude Code

ANTHROPIC_AUTH_TOKEN

It sends a token that a gateway can check.

ANTHROPIC_AUTH_TOKEN sets a token for Claude Code to send in the Authorization header. Claude Code puts Bearer in front of it. It is for a gateway or proxy that checks tokens, not Anthropic keys. When both are set, it wins over the API key.

Example
Emma's company sends all its AI traffic through one gateway. She sets this to her own gateway token. Then the gateway adds the real key.
Why it matters
Staff never hold the real key. The gateway holds it and checks who is asking.
Full entry

In one line

ANTHROPIC_API_KEY
It gives Claude Code an API key to sign in and pay with.
ANTHROPIC_AUTH_TOKEN
It sends a token that a gateway can check.