# AzureAIAnthropicChatModel

> **Class** in `langchain_azure_ai`

📖 [View in docs](https://reference.langchain.com/python/langchain-azure-ai/chat_models/anthropic/AzureAIAnthropicChatModel)

Azure AI chat model using the Anthropic Messages API.

Wraps :class:`langchain_anthropic.ChatAnthropic` so that Anthropic
Claude models hosted by Azure AI Foundry can be accessed through the
``/anthropic`` endpoint with native Microsoft Entra ID authentication.

Authentication uses :class:`anthropic.AnthropicFoundry` (and
:class:`anthropic.AsyncAnthropicFoundry`) under the hood, which accepts
an ``azure_ad_token_provider`` callable that is invoked on every
request – so bearer tokens are refreshed automatically and the model
can be used in long-running services without manual token rotation.

**Microsoft Entra ID authentication (recommended):**

```python
from langchain_azure_ai.chat_models import AzureAIAnthropicChatModel
from azure.identity import DefaultAzureCredential

model = AzureAIAnthropicChatModel(
    endpoint="https://<resource>.services.ai.azure.com",
    credential=DefaultAzureCredential(),
    model="claude-sonnet-4-20250514",
)
```

The ``endpoint`` is the Azure AI Foundry resource root; the
``/anthropic`` path is appended automatically.  You may also pass a URL
that already ends in ``/anthropic`` – the result is the same.

Alternatively, supply a Foundry *project* endpoint and the resource
root is derived automatically:

```python
model = AzureAIAnthropicChatModel(
    project_endpoint=(
        "https://<resource>.services.ai.azure.com/api/projects/my-project"
    ),
    credential=DefaultAzureCredential(),
    model="claude-sonnet-4-20250514",
)
```

``project_endpoint`` and ``endpoint`` are mutually exclusive.

**API-key authentication:**

```python
model = AzureAIAnthropicChatModel(
    endpoint="https://<resource>.services.ai.azure.com",
    credential="your-api-key",
    model="claude-sonnet-4-20250514",
)
```

**Environment variables:**

The following environment variables are checked when the corresponding
constructor parameters are not provided:

* ``AZURE_AI_PROJECT_ENDPOINT`` or ``FOUNDRY_PROJECT_ENDPOINT`` – resolved
  as ``project_endpoint``.  ``AZURE_AI_PROJECT_ENDPOINT`` takes precedence
  when both are set.
* ``ANTHROPIC_FOUNDRY_RESOURCE`` – resolved as ``endpoint`` when neither
  ``endpoint`` nor ``project_endpoint`` is set (directly or via env var).
  May be a bare resource name (e.g. ``my-resource``) or a full URL.  When
  a bare name is provided the endpoint is synthesized as
  ``https://<ANTHROPIC_FOUNDRY_RESOURCE>.services.ai.azure.com``.
  This is the same variable used by **Claude Code** when connected to
  Azure AI Foundry, so models configured that way will work here without
  any additional configuration.

**Resolution priority** (highest to lowest):

1. Constructor parameters (``project_endpoint``, ``endpoint``).
2. ``AZURE_AI_PROJECT_ENDPOINT`` environment variable (or
   ``FOUNDRY_PROJECT_ENDPOINT`` if the former is not set).
3. ``ANTHROPIC_FOUNDRY_RESOURCE`` environment variable.

All other keyword arguments accepted by
:class:`langchain_anthropic.ChatAnthropic` are forwarded as-is.

## Signature

```python
AzureAIAnthropicChatModel()
```

## Extends

- `ChatAnthropic`

## Properties

- `model_config`
- `project_endpoint`
- `endpoint`
- `credential`

---

[View source on GitHub](https://github.com/langchain-ai/langchain-azure/blob/7a6a664d617264df8dcb12fcfb1bacc09f21d504/libs/azure-ai/langchain_azure_ai/chat_models/anthropic.py#L70)