continue icon indicating copy to clipboard operation
continue copied to clipboard

Bug: Anthropic provider fails with Azure AI Foundry endpoints (incorrect auth header)

Open Cozmopolit opened this issue 11 months ago • 5 comments

Before submitting your bug report

Relevant environment info

- OS:
- Continue version:
- IDE version:
- Model:
- config:
  

  
  OR link to agent in Continue hub:

Description

Problem

Continue does not support Azure AI Foundry-hosted Anthropic models (Claude Opus 4.5, Haiku 4.5, etc.), even though these are now available in EU regions and represent an important deployment option for enterprise customers requiring GDPR compliance and data residency.

Current Behavior

When configuring an Azure-hosted Anthropic endpoint:

models:
  - provider: anthropic
    model: claude-opus-4-5
    apiBase: https://my-resource.services.ai.azure.com/anthropic
    apiKey: <AZURE_API_KEY>

Result:

  • ❌ 401 Unauthorized Error
  • Misleading error message: "forgot to add '/v1' to apiBase"

Root Cause

Azure AI Foundry uses the native Anthropic Messages API format but with a different authentication header:

Provider Auth Header Value
Anthropic Direct x-api-key Anthropic API Key
Azure-hosted Anthropic api-key Azure API Key

Continue's Anthropic provider always sends x-api-key, which Azure rejects.

Expected Behavior

Continue should automatically detect Azure endpoints and use the correct authentication header:

// Detection logic
const isAzureEndpoint = apiBase?.toLowerCase().includes('.services.ai.azure.com') || 
                        apiBase?.toLowerCase().includes('.cognitiveservices.azure.com');
const authHeader = isAzureEndpoint ? 'api-key' : 'x-api-key';

Proposed Solution

Extend the Anthropic provider to detect Azure endpoints and adjust the authentication header accordingly. This requires minimal changes:

  1. packages/openai-adapters/src/apis/AnthropicUtils.ts

    • Add Azure endpoint detection function
    • Modify getAnthropicHeaders() to accept apiBase parameter
    • Use conditional header name based on endpoint
  2. packages/openai-adapters/src/apis/Anthropic.ts

    • Pass apiBase to getAnthropicHeaders()
  3. core/llm/llms/Anthropic.ts

    • Pass apiBase to getAnthropicHeaders()

Why This Matters

  1. GDPR Compliance: EU customers can use Claude models while keeping data in EU regions
  2. Enterprise Requirements: Many organizations require Azure-based deployments
  3. Unified Billing: Anthropic usage through Azure subscription
  4. Data Residency: Regional deployments for compliance

Additional Context

  • Azure AI Foundry Anthropic API uses the same request/response format as standard Anthropic
  • Only the authentication header differs
  • All Anthropic features (streaming, caching, tools) work identically
  • Continue's existing retry logic handles Azure rate limits (HTTP 429 + Retry-After)

Workarounds

None available. Users cannot currently use Azure-hosted Anthropic models with Continue.

Environment

  • Continue Version: [latest]
  • IDE: VS Code / JetBrains
  • Azure AI Foundry: Claude Opus 4.5, Claude Haiku 4.5

References


I'm willing to contribute a PR for this if the approach is acceptable.

To reproduce

No response

Log output


Cozmopolit avatar Dec 04 '25 20:12 Cozmopolit

Related Issues

Found the following related issues:

Azure Foundry Issues:

  • #3938 - Cannot Provision DeepSeek R1 from Azure Foundry
  • #3902 - Cannot setup Deepseek model using Azure Foundry
  • #3735 - Azure Foundry models don't work (Mistral Codestral 2501 with Azure) [CLOSED]
  • #5188 - JSON error when trying to connect to Azure Foundry endpoint [CLOSED]

Authentication Header Issues:

  • #7047 - IntelliJ: duplicate authorization header sent for OpenAI models, causing authentication failure [CLOSED]
  • #4243 - HTTP 401 Unauthorized from https://api.anthropic.com/v1/messages (x-api-key header is required) [CLOSED]
  • #4661 - tabAutocompleteModel does not respect requestOptions.headers when using Mistral provider [CLOSED]

The most relevant appears to be #3735 which discusses the different URI structure for Azure Foundry vs Azure OpenAI endpoints.

continue avatar Dec 04 '25 20:12 continue

Clarification: This issue is NOT related to #3735

Thanks for the automated related issues list, but I want to clarify that this issue is fundamentally different from #3735 and the other Azure Foundry issues listed.

Issue Problem Provider API Format
#3735 (Codestral/Mistral) URL path structure (/openai/deployments/... vs /chat/completions) azure (OpenAI-compatible) OpenAI Chat API
#3902 (DeepSeek) URL path structure azure (OpenAI-compatible) OpenAI Chat API
#9009 (This issue) Authentication header (x-api-key vs api-key) anthropic Native Anthropic Messages API

Key Differences:

  1. Different Provider: This issue affects the anthropic provider, not the azure provider
  2. Different API: Azure-hosted Anthropic uses the native Anthropic Messages API (not OpenAI-compatible)
  3. Different Root Cause: The issue is the authentication header name, not URL path construction
  4. Different Fix Location: Changes needed in AnthropicUtils.ts / Anthropic.ts, not Azure/OpenAI adapters

Why #3735's solution doesn't apply here:

  • #3735 proposes adding apiType: 'foundry' for URL path handling in the Azure/OpenAI provider
  • This issue requires detecting Azure endpoints in the Anthropic provider and switching from x-api-key to api-key
  • The request/response format is identical to standard Anthropic - only the auth header differs

This is a new, distinct feature request for Azure-hosted Anthropic Claude models (not Mistral, DeepSeek, or other OpenAI-compatible models).

Cozmopolit avatar Dec 04 '25 20:12 Cozmopolit

:tada: This issue has been resolved in version 1.36.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sestinj avatar Dec 10 '25 23:12 sestinj

:tada: This issue has been resolved in version 1.38.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sestinj avatar Jan 13 '26 19:01 sestinj

:tada: This issue has been resolved in version 1.8.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sestinj avatar Jan 22 '26 23:01 sestinj