Azure OpenAI
Streaming chat completions from OpenAI models deployed on Azure, with AzureLLMService.
Overview
AzureLLMService: OpenAI chat models deployed in Azure AI Foundry (Azure OpenAI). It extendsOpenAILLMService, so streaming, function calling, token usage metrics andrunInferencework the same way; only the client differs.
The shape of endpoint picks the API surface:
- An endpoint ending in
/openai/v1uses Azure's v1 API, which tracks new features and needs noapi-version. This is the one to use. - Any other endpoint (for example
https://my-resource.openai.azure.com) goes through the dated API, withapi-version=2025-04-01-preview, the last dated version Azure issued.
Both surfaces accept an API key or a Microsoft Entra ID token.
Upstream page
Pipecat's documentation for the same service.
Source
packages/azure/src/llm.ts.
Azure docs
The v1 API and the dated API versions.
Installation
bun add @pipedog/azureimport { AzureLLMService } from "@pipedog/azure/llm";@pipedog/azure depends on @pipedog/openai and the openai SDK, which it installs for you.
Prerequisites
- An Azure OpenAI (or Azure AI Foundry) resource with a chat model deployed. The deployment
name is what you pass as
model. - The resource's endpoint, and either its API key or a Microsoft Entra ID identity with access
to it. The examples read the key from
AZURE_OPENAI_API_KEY.
AzureLLMService
Configuration
Prop
Type
The other options (serviceTier, retryOnTimeout, retryTimeoutSecs, and the frame processor
options) are the same as OpenAILLMService.
baseUrl is ignored: the endpoint sets it.
Settings
AzureLLMService.Settings (AzureLLMSettings) has the same fields and defaults as
OpenAILLMSettings. model defaults to "gpt-4.1"; on
Azure it must be your deployment's name.
Usage
import { AzureLLMService } from "@pipedog/azure/llm";
const llm = new AzureLLMService({
apiKey: process.env.AZURE_OPENAI_API_KEY ?? "",
// Ending the endpoint in /openai/v1 selects Azure's v1 API surface.
endpoint: "https://my-resource.openai.azure.com/openai/v1",
settings: new AzureLLMService.Settings({
// On Azure the model is the deployment name.
model: "my-gpt-4.1-deployment",
systemInstruction: "You are a helpful assistant in a voice conversation.",
temperature: 0.7,
}),
});With Microsoft Entra ID instead of a key. The token provider is called for every request:
// Any async function that returns a Microsoft Entra ID bearer token for the
// https://ai.azure.com/.default scope, for example
// getBearerTokenProvider(new DefaultAzureCredential(), "https://ai.azure.com/.default")
// from @azure/identity.
declare const tokenProvider: () => Promise<string>;
const withEntra = new AzureLLMService({
tokenProvider,
endpoint: "https://my-resource.openai.azure.com/openai/v1",
settings: new AzureLLMService.Settings({ model: "my-gpt-4.1-deployment" }),
});Through the dated API:
// Any other endpoint shape goes through the dated API (api-version 2025-04-01-preview).
const dated = new AzureLLMService({
apiKey: process.env.AZURE_OPENAI_API_KEY ?? "",
endpoint: "https://my-resource.openai.azure.com",
settings: new AzureLLMService.Settings({ model: "my-gpt-4.1-deployment" }),
});Notes
- On the v1 surface the client is the plain
OpenAIclient pointed at the endpoint, with the key (or the token provider) as its API key. On the dated surface it is the SDK'sAzureOpenAIclient, which sends the key in theapi-keyheader, addsapi-version, and routes to/openai/deployments/<model>/.... apiKeyortokenProvideris required; the constructor throws without either. With both, the token provider is used.- Event handlers, frames and metrics are those of
OpenAILLMService.
Runtime notes
| Runtime | Works | What it needs |
|---|---|---|
| Bun | ✅ yes | Nothing. |
| Node.js | ✅ yes | Nothing. |
| Deno | ✅ yes | Nothing. |
| Cloudflare Workers | ✅ yes | Nothing. |
Generated from pipecat.runtimes and pipecat.compat in packages/azure/package.json: ✅ means the compat smoke test passes on that runtime.
- The client is the official
openaiJS SDK overfetch, so the service works on Bun, Node, Deno and Cloudflare Workers. AzureTokenProvideris any() => Promise<string>.getBearerTokenProvider()from@azure/identityreturns one; on Workers, where@azure/identity's credentials don't run, fetch the token yourself (for example through a client-credentials request to Entra ID).- The deprecated
modelandapiVersionconstructor options are not ported. Usesettingsfor the model, and an/openai/v1endpoint instead of a dated version.
pipedog is an unofficial community TypeScript port of Pipecat. It is not affiliated with or endorsed by Daily or the Pipecat project.
Portions adapted from the Pipecat documentation, Copyright (c) 2024–2025 Daily, BSD-2-Clause (see apps/docs/LICENSE-pipecat-docs).