Skip to main content

Azure OpenAI STT integration guide

How to use the Azure OpenAI STT plugin for LiveKit Agents.

Overview

Azure OpenAI provides OpenAI services hosted on Azure. With LiveKit's Azure OpenAI STT integration and the Agents framework, you can build voice AI applications with fast, accurate transcription.

Quick reference

This section includes a basic usage example and some reference material. For links to more detailed documentation, see Additional resources.

Installation

Support for Azure OpenAI STT is available in the openai plugin.

Install the plugin from PyPI:

pip install "livekit-agents[openai]~=1.0"

Authentication

The Azure OpenAI TTS requires authentication using an API key or a managed identity.

Set the following environment variables in your .env file:

AZURE_OPENAI_API_KEY=<azure-openai-api-key>
AZURE_OPENAI_AD_TOKEN=<azure-openai-ad-token>
AZURE_OPENAI_ENDPOINT=<azure-openai-endpoint>

Usage

Use Azure OpenAI STT within an AgentSession or as a standalone transcription service. For example, you can use this STT in the Voice AI quickstart.

from livekit.plugins import openai
session = AgentSession(
stt = openai.STT.with_azure(
model="gpt-4o-transcribe",
),
# ... llm, tts, etc.
)

Parameters

This section describes some of the available parameters. For a complete reference of all available parameters, see the plugin reference.

languagestringOptionalDefault: en

Language code for the transcription.

modelSTTModels | stringOptionalDefault: gpt-4o-mini-transcribe

ID of the model to use for speech-to-text.

promptstringOptional

Initial prompt to guide the transcription.

azure_endpointstringOptionalEnv: AZURE_OPENAI_ENDPOINT

Azure OpenAI endpoint in the following format: https://{your-resource-name}.openai.azure.com.

azure_deploymentstringOptional

Name of your model deployment.

api_versionstringOptionalEnv: OPENAI_API_VERSION

OpenAI REST API version used for the request.

api_keystringOptionalEnv: AZURE_OPENAI_API_KEY

Azure OpenAI API key.

azure_ad_tokenstringOptionalEnv: AZURE_OPENAI_AD_TOKEN

Azure Active Directory token.

organizationstringOptionalEnv: OPENAI_ORG_ID

OpenAI organization ID.

projectstringOptionalEnv: OPENAI_PROJECT_ID

OpenAI project ID.

Additional resources

The following resources provide more information about using Azure OpenAI with LiveKit Agents.