This is from 2026-01. Your mileage may vary.
This guide explains how to configure Claude Code CLI to use Azure AI Foundry as the model provider for Anthropic Claude models.
- Claude Code CLI installed (
npm install -g @anthropic-ai/claude-code) - An Azure AI Foundry resource with Anthropic Claude models deployed
- Your Azure AI Foundry API key
Set the following environment variables:
# Required: Enable Foundry mode
export CLAUDE_CODE_USE_FOUNDRY=1
# Required: Your Foundry API key
export ANTHROPIC_FOUNDRY_API_KEY="your-api-key-here"
# Required: Your Azure AI Foundry endpoint
export ANTHROPIC_FOUNDRY_BASE_URL="https://YOUR-RESOURCE-NAME.openai.azure.com/anthropic"
# Optional: Specify model names (defaults shown)
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5"
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4-5"
# Make sure Vertex is disabled
export CLAUDE_CODE_USE_VERTEX=0Add these to your shell profile (~/.zshrc, ~/.bashrc, etc.) for persistence.
Create a wrapper script claude-foundry in your PATH:
#!/bin/bash
ANTHROPIC_FOUNDRY_API_KEY="your-api-key-here" \
CLAUDE_CODE_USE_VERTEX=0 \
CLAUDE_CODE_USE_FOUNDRY=1 \
ANTHROPIC_FOUNDRY_BASE_URL="https://YOUR-RESOURCE-NAME.openai.azure.com/anthropic" \
ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4-5" \
ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5" \
ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4-5" \
claude "$@"Make it executable: chmod +x claude-foundry
| Environment Variable | Description |
|---|---|
CLAUDE_CODE_USE_FOUNDRY |
Must be 1 to enable Azure AI Foundry mode |
CLAUDE_CODE_USE_VERTEX |
Set to 0 to disable Google Vertex AI |
ANTHROPIC_FOUNDRY_API_KEY |
Your Azure AI Foundry API key |
ANTHROPIC_FOUNDRY_BASE_URL |
Your Azure endpoint with /anthropic suffix |
ANTHROPIC_DEFAULT_SONNET_MODEL |
Claude Sonnet model deployment name |
ANTHROPIC_DEFAULT_HAIKU_MODEL |
Claude Haiku model deployment name |
ANTHROPIC_DEFAULT_OPUS_MODEL |
Claude Opus model deployment name |
- Go to Azure AI Foundry or Azure Portal
- Navigate to your Azure AI Foundry resource
- Find the endpoint URL (looks like
https://YOUR-RESOURCE-NAME.openai.azure.com/) - Append
/anthropicto get the base URL for Claude models
Run a simple test:
claude -p "hello"You should see a response from Claude without being prompted to log in.
- Verify
ANTHROPIC_FOUNDRY_API_KEYis set correctly - Check that your API key has access to the Claude model deployments
- Ensure the model names in
ANTHROPIC_DEFAULT_*_MODELmatch your Azure deployment names - Verify Claude models are deployed in your Azure AI Foundry resource
- Make sure
CLAUDE_CODE_USE_FOUNDRY=1is set - Verify
CLAUDE_CODE_USE_VERTEX=0to avoid conflicts