Skip to content

[BUG] Unable to use Anthropic via Foundry #9467

@BouquetAntoine

Description

@BouquetAntoine

Problem (one or two sentences)

Problem

It’s currently impossible to use an Anthropic model hosted on Azure Foundry in Roo Code with the OpenAI Compatible provider. Requests fail with a 401 error.

Two issues cause the failure:

  1. The _isAzureAiInference heuristic triggers because the Azure Anthropic endpoint follows the pattern
    https://{resource}-resource.services.ai.azure.com/anthropic/v1/messages.
    When this detection activates, Roo Code appends OPENAI_AZURE_AI_INFERENCE_PATH (models/chat/completions) to the URL.
    This results in a final request path like:
    /anthropic/v1/messages/models/chat/completions, which is invalid for Azure Anthropic.

  2. The API key is sent using the Authorization: Bearer header, but Azure Anthropic requires the key in the x-api-key header.
    This also triggers a 401.

Expected behavior

Roo Code should:

  • Avoid applying _isAzureAiInference logic to Anthropic endpoints on Azure.
  • Use x-api-key for authentication when targeting Azure Anthropic.
  • Keep the correct path /anthropic/v1/messages without appending OpenAI-style routes.

Proposed solution

  • Add an exception in _isAzureAiInference so Anthropic URLs are not modified.
  • Detect Azure Anthropic endpoints and automatically switch to x-api-key instead of the Authorization header.
  • Avoid appending models/chat/completions when the path already contains a valid Anthropic route.

Context (who is affected and when)

Impact

Any attempt to use Anthropic models deployed through Azure Foundry with the OpenAI Compatible provider fails.
This blocks the ability to use the newly announced Microsoft × Anthropic integration.

Reproduction steps

Steps to reproduce

  1. Create an Anthropic resource on Azure Foundry.
  2. Use its endpoint in Roo Code under the OpenAI Compatible provider:
    https://{resource}-resource.services.ai.azure.com/anthropic/v1/messages
  3. Trigger a request.
  4. Observe the 401 error.

Expected result

The model starts working

Actual result

401 error

Variations tried (optional)

No response

App Version

last

API Provider (optional)

OpenAI Compatible

Model Used (optional)

claude-sonnet-4-5

Roo Code Task Links (optional)

No response

Relevant logs or errors (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue/PR - TriageNew issue. Needs quick review to confirm validity and assign labels.bugSomething isn't working

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions