pipedog is an unofficial community port of Pipecat, not affiliated with Daily.
pipedog
LLM

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 extends OpenAILLMService, so streaming, function calling, token usage metrics and runInference work the same way; only the client differs.

The shape of endpoint picks the API surface:

  • An endpoint ending in /openai/v1 uses Azure's v1 API, which tracks new features and needs no api-version. This is the one to use.
  • Any other endpoint (for example https://my-resource.openai.azure.com) goes through the dated API, with api-version=2025-04-01-preview, the last dated version Azure issued.

Both surfaces accept an API key or a Microsoft Entra ID token.

Installation

bun add @pipedog/azure
import { 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

llm.ts
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 OpenAI client pointed at the endpoint, with the key (or the token provider) as its API key. On the dated surface it is the SDK's AzureOpenAI client, which sends the key in the api-key header, adds api-version, and routes to /openai/deployments/<model>/....
  • apiKey or tokenProvider is required; the constructor throws without either. With both, the token provider is used.
  • Event handlers, frames and metrics are those of OpenAILLMService.

Runtime notes

RuntimeWorksWhat it needs
Bun✅ yesNothing.
Node.js✅ yesNothing.
Deno✅ yesNothing.
Cloudflare Workers✅ yesNothing.

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 openai JS SDK over fetch, so the service works on Bun, Node, Deno and Cloudflare Workers.
  • AzureTokenProvider is any () => Promise<string>. getBearerTokenProvider() from @azure/identity returns 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 model and apiVersion constructor options are not ported. Use settings for the model, and an /openai/v1 endpoint 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).

On this page