# ANTHROPIC_FOUNDRY_API_KEY

> It gives Claude Code a key to sign in to Microsoft Foundry.

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** ANTHROPIC_FOUNDRY_AUTH_TOKEN

## Think of it like

It is like the key to your shop, or a pass from the head office.

## Definition

ANTHROPIC_FOUNDRY_API_KEY gives Claude Code a key to sign in to Foundry. Its twin with AUTH_TOKEN in the name takes a token, such as one from Entra. The token wins over the key. With neither, Claude Code uses the Azure sign-in on the machine. The token needs version 2.1.203 or later.

## Example

Jack's CI cannot use his own Azure sign-in. He stores a Foundry key as a secret and sets it here, and the job signs in by itself.

## Example code

```bash
export CLAUDE_CODE_USE_FOUNDRY=1
export ANTHROPIC_FOUNDRY_RESOURCE=my-resource
export ANTHROPIC_FOUNDRY_API_KEY=your-foundry-key
claude
```

Sign in to Foundry with a key.

## Why it matters

Scripts and CI need a sign-in that does not depend on a person being logged in.

## Common mistake

Setting both and expecting the key to be used. The token wins when both are set.

## Three principles

- **Key.** A Foundry API key.
- **Token wins.** Entra bearer token.
- **Neither.** Azure sign-in.

## Related terms

- [ANTHROPIC_FOUNDRY_RESOURCE](https://learn.benibix.com/term/ai/anthropic-foundry-resource-variable)
- [Microsoft Foundry](https://learn.benibix.com/term/ai/microsoft-foundry)
- [API Key](https://learn.benibix.com/term/development/api-key)

---

Source: https://learn.benibix.com/term/ai/anthropic-foundry-api-key-variable
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
