Skip to main content

Overview

The Azure OpenAI provider connects core-ai to Azure OpenAI deployments through the official OpenAI SDK. Azure v1 uses the Responses API for chatModel() and exposes strict Chat Completions through azure.chat.chatModel(). Pass Azure OpenAI deployment names as model IDs.

Installation

createAzureOpenAI()

Create an Azure OpenAI provider instance.

Options

string
Your Azure OpenAI API key.
string
Your Azure OpenAI resource endpoint, for example https://my-resource.openai.azure.com. You can also pass a full v1 base URL such as https://my-resource.openai.azure.com/openai/v1.
'v1' | 'classic'
API surface to use. Defaults to v1. Set classic to use Azure’s classic API surface.
string
Required when api is classic. Azure OpenAI API version, for example 2025-04-01-preview.
string
Classic mode only. Default Azure OpenAI deployment for the underlying SDK client.
() => Promise<string>
Classic mode only. Token provider for Microsoft Entra ID authentication.
OpenAI | OpenAIChatClient
Provide your own configured client. Azure v1 clients must expose Responses and Chat Completions. Classic clients only need Chat Completions.

Returns

AzureOpenAIProvider with chatModel() and chat.chatModel().

API selection

With Azure v1, the root provider uses Responses:
Use the nested provider for strict Chat Completions:
Classic Azure supports Chat Completions only. In classic mode, both azure.chatModel() and azure.chat.chatModel() create Chat Completions models.

Authentication

Use an API key with the v1 API:
Use the classic API by setting api: 'classic' and passing an API version:
Classic mode can use Microsoft Entra ID by passing a token provider:

Model IDs

Use your Azure OpenAI deployment name as the model id:
If your deployment name is different from the base model name, pass the deployment name.

Model capabilities

Azure models expose the shared OpenAI capability shape through model.capabilities:
Capability lookup uses the model ID passed to chatModel(). Prefer a known OpenAI model ID when that matches your Azure deployment name, so reasoning and image-input flags reflect the underlying model. If the value is a custom deployment name that is not in the OpenAI registry, the provider cannot infer the model family and returns the generic OpenAI fallback. Treat that data as a default rather than an exact description of the deployment. The fallback includes 'image' and 'file' in modalities.input, so multimodal requests are forwarded to the deployment rather than rejected locally. For recognized OpenAI model IDs, see OpenAI model capabilities for the reasoning, image input, and Chat Completions fields.

Reasoning metadata

On Azure v1 Responses, encrypted reasoning is stored under the azure-openai provider key — not openai. Use that key when reading metadata, and keep escape-hatch request options under providerOptions.openai (shared Responses field shapes).

Examples

Basic chat

Streaming

Provider-specific options

Root Azure v1 models use the OpenAI Responses options:
Nested and classic models use Chat Completions options:
See the OpenAI provider for the fields supported by each API.
Azure Responses availability depends on the model and Azure region. Use azure.chat.chatModel() when your deployment only supports Chat Completions.