You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds first-class support for running Claude Code on Azure AI Foundry through the Headroom proxy, following the same pattern as the recently merged Vertex AI support (#1113) and the in-progress Bedrock support (#1104).
Azure AI Foundry is Microsoft's hosted Claude endpoint (surfaced via CLAUDE_CODE_USE_FOUNDRY=1 + ANTHROPIC_FOUNDRY_RESOURCE). When this mode is active, Claude Code routes requests to an Azure-hosted endpoint rather than api.anthropic.com, and ANTHROPIC_BASE_URL is ignored — making the standard proxy intercept path inoperative. As a result, all Headroom compression is silently bypassed for any Claude Code installation running on Azure AI Foundry.
This is the same class of problem that was fixed for Vertex AI in #1113, where ANTHROPIC_VERTEX_BASE_URL had to be set instead of ANTHROPIC_BASE_URL.
Use Case
Enterprise and Azure-hosted deployments of Claude Code commonly use Azure AI Foundry rather than the direct Anthropic API. This includes:
Avanade / Anthropic partner deployments provisioned through Azure Marketplace
Any shop using CLAUDE_CODE_USE_FOUNDRY=1 (the apiKeyHelper-based auth path Claude Code exposes for Azure)
CI/CD agents and self-hosted runners that authenticate via Entra managed identity rather than a personal Anthropic API key
These installations today receive zero Headroom compression benefit even after a correct proxy setup, with no error or warning to explain why.
Technical Details
When CLAUDE_CODE_USE_FOUNDRY=1 is set, Claude Code derives its endpoint from ANTHROPIC_FOUNDRY_RESOURCE and routes to:
Set ANTHROPIC_FOUNDRY_BASE_URL (or the equivalent env var Claude Code accepts in Foundry mode) to point at the local proxy, so Claude Code sends its Azure-format requests through Headroom
Forward auth headers (api-key or Authorization: Bearer) from the client to the Azure upstream — Headroom holds no credentials, same as the Vertex ADC passthrough pattern
Register an azure-foundry provider in providers/registry.py (or reuse the existing azure litellm provider with Foundry-specific host derivation)
Derive the upstream host per-request from ANTHROPIC_FOUNDRY_RESOURCE, handling both the .openai.azure.com and .services.ai.azure.com endpoint shapes
Description
Adds first-class support for running Claude Code on Azure AI Foundry through the Headroom proxy, following the same pattern as the recently merged Vertex AI support (#1113) and the in-progress Bedrock support (#1104).
Azure AI Foundry is Microsoft's hosted Claude endpoint (surfaced via
CLAUDE_CODE_USE_FOUNDRY=1+ANTHROPIC_FOUNDRY_RESOURCE). When this mode is active, Claude Code routes requests to an Azure-hosted endpoint rather thanapi.anthropic.com, andANTHROPIC_BASE_URLis ignored — making the standard proxy intercept path inoperative. As a result, all Headroom compression is silently bypassed for any Claude Code installation running on Azure AI Foundry.This is the same class of problem that was fixed for Vertex AI in #1113, where
ANTHROPIC_VERTEX_BASE_URLhad to be set instead ofANTHROPIC_BASE_URL.Use Case
Enterprise and Azure-hosted deployments of Claude Code commonly use Azure AI Foundry rather than the direct Anthropic API. This includes:
CLAUDE_CODE_USE_FOUNDRY=1(theapiKeyHelper-based auth path Claude Code exposes for Azure)These installations today receive zero Headroom compression benefit even after a correct proxy setup, with no error or warning to explain why.
Technical Details
When
CLAUDE_CODE_USE_FOUNDRY=1is set, Claude Code derives its endpoint fromANTHROPIC_FOUNDRY_RESOURCEand routes to:or (newer Foundry endpoint):
Authentication is either an
api-keyheader or an Entra Bearer token — not an Anthropic API key. The proxy needs to:CLAUDE_CODE_USE_FOUNDRY=1inwrap claude, analogous toCLAUDE_CODE_USE_VERTEX=1detection in feat(vertex): turnkey Claude Code + Vertex compression (+ fixes from the Vertex review) #1113ANTHROPIC_FOUNDRY_BASE_URL(or the equivalent env var Claude Code accepts in Foundry mode) to point at the local proxy, so Claude Code sends its Azure-format requests through Headroomapi-keyorAuthorization: Bearer) from the client to the Azure upstream — Headroom holds no credentials, same as the Vertex ADC passthrough patternazure-foundryprovider inproviders/registry.py(or reuse the existingazurelitellm provider with Foundry-specific host derivation)ANTHROPIC_FOUNDRY_RESOURCE, handling both the.openai.azure.comand.services.ai.azure.comendpoint shapesPrior Art in This Repo
CLAUDE_CODE_USE_VERTEX→ setANTHROPIC_VERTEX_BASE_URL--bedrock-client-hookfor pluggable credentialsThe Vertex PR is the closest model — the same
wrap claudedetection pattern and per-request host derivation apply directly.Environment Variables (reference)
CLAUDE_CODE_USE_FOUNDRY1by Claude Code when Azure AI Foundry is activeANTHROPIC_FOUNDRY_RESOURCEmy-org-claude)ANTHROPIC_FOUNDRY_BASE_URLwrap claudeshould set tohttp://127.0.0.1:8787Suggested Approach
Modelled on
feat(vertex)in #1113:cli/wrap.py: detectCLAUDE_CODE_USE_FOUNDRY=1and setANTHROPIC_FOUNDRY_BASE_URLto the proxy addressproviders/registry.py: addazure-foundryalias mapping to the litellmazureprovider with Foundry host derivationproviders/proxy_routes.py: derive Azure upstream URL per-request fromANTHROPIC_FOUNDRY_RESOURCE, handling both endpoint shapes and forwarding client auth headers unchangeddocs/: newclaude-code-azure-foundry.mdxguide (parity withclaude-code-vertex.mdx)tests/: newtest_azure_foundry_claude_compression.py(parity withtest_vertex_claude_compression.py)