# AzureAIOpenAIApiEmbeddingsModel

> **Class** in `langchain_azure_ai`

📖 [View in docs](https://reference.langchain.com/python/langchain-azure-ai/embeddings/openai/AzureAIOpenAIApiEmbeddingsModel)

Azure AI embeddings model using the OpenAI-compatible API.

This class wraps :class:`langchain_openai.OpenAIEmbeddings` and adds
support for the *project-endpoint pattern* available in Azure AI Foundry,
in addition to the classic *endpoint + API-key* style used by Azure OpenAI.

Use `AzureAIOpenAIApiEmbeddingsModel` with any Foundry model compatible with
OpenAI APIs (e.g. gpt-5, Mistral, Cohere.) to get the benefits of
unified authentication, single configuration, and seamless integration
with other Azure services.

**Project-endpoint pattern (recommended for Azure AI Foundry):**

```python
from langchain_azure_ai.embeddings import AzureAIOpenAIApiEmbeddingsModel
from azure.identity import DefaultAzureCredential

embed_model = AzureAIOpenAIApiEmbeddingsModel(
    project_endpoint=(
        "https://resource.services.ai.azure.com/api/projects/my-project"
    ),
    credential=DefaultAzureCredential(),
    model="text-embedding-3-small",
)
```

Parameter `model` refers to the model deployment name in Azure AI Foundry,
which may differ from the base model name depending on how the deployment
was configured.

If ``project_endpoint`` is omitted the value of the
``AZURE_AI_PROJECT_ENDPOINT`` environment variable is used.

**Direct endpoint + API-key pattern:**

```python
from langchain_azure_ai.embeddings import AzureAIEmbeddingsModel

embed_model = AzureAIOpenAIApiEmbeddingsModel(
    endpoint="https://resource.services.ai.azure.com/openai/v1",
    credential="your-api-key",
    model="text-embedding-3-small",
    api_version="2024-05-01-preview",
)
```

**Environment variables:**

The following environment variables are recognised as fallbacks when the
corresponding constructor parameters are not provided:

* ``AZURE_AI_PROJECT_ENDPOINT`` – used as ``project_endpoint``.
* ``AZURE_AI_OPENAI_ENDPOINT`` – direct OpenAI-compatible endpoint
  (e.g. ``https://<resource>.services.ai.azure.com/openai/v1``).
  Used as ``endpoint`` verbatim (no path is appended).
* ``AZURE_OPENAI_ENDPOINT`` – root Azure OpenAI endpoint (e.g.
  ``https://<resource>.services.ai.azure.com``).  ``/openai/v1`` is
  appended automatically and the result is treated as ``endpoint``.
* ``AZURE_OPENAI_DEPLOYMENT_NAME`` – model deployment name (``model``).
* ``AZURE_OPENAI_API_VERSION`` – API version passed as the
  ``api-version`` query parameter on every request.

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

1. Constructor parameters.
2. ``AZURE_AI_PROJECT_ENDPOINT`` environment variable.
3. ``AZURE_AI_OPENAI_ENDPOINT`` environment variable.
4. ``AZURE_OPENAI_ENDPOINT`` / ``AZURE_OPENAI_API_VERSION`` /
   ``AZURE_OPENAI_DEPLOYMENT_NAME`` environment variables.

``AZURE_AI_PROJECT_ENDPOINT``, ``AZURE_AI_OPENAI_ENDPOINT``, and
``AZURE_OPENAI_ENDPOINT`` may all be set at the same time; the project
endpoint takes precedence, then ``AZURE_AI_OPENAI_ENDPOINT``, then
``AZURE_OPENAI_ENDPOINT``.  However, passing both ``project_endpoint``
*and* ``endpoint`` as constructor parameters raises :class:`ValueError`.

All other keyword arguments accepted by
:class:`langchain_openai.AzureOpenAIEmbeddings` are forwarded as-is.

## Signature

```python
AzureAIOpenAIApiEmbeddingsModel()
```

## Extends

- `OpenAIEmbeddings`

## Properties

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

---

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