Overview
This plugin allows you to use Azure OpenAI as a TTS provider for your voice agents.
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 TTS is available in the openai plugin.
Install the plugin from PyPI:
uv add "livekit-agents[openai]~=1.3"
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 TTS within an AgentSession or as a standalone speech generator. For example, you can use this TTS in the Voice AI quickstart.
from livekit.plugins import openaisession = AgentSession(tts=openai.TTS.with_azure(model="gpt-4o-mini-tts",voice="coral",)# ... llm, stt, etc.)
Parameters
This section describes some of the available parameters. For a complete reference of all available parameters, see the plugin reference.
stringOptionalDefault: gpt-4o-mini-ttsID of the model to use for TTS. To learn more, see Text to speech models.
stringOptionalDefault: ashOpenAI text-to-speech voice. To learn more, see the list of supported voices for voice in the Azure documentation.
stringOptionalInstructions to control tone, style, and other characteristics of the speech.
stringOptionalEnv: AZURE_OPENAI_ENDPOINTAzure OpenAI endpoint in the following format: https://{your-resource-name}.openai.azure.com.
stringOptionalName of your model deployment.
stringOptionalEnv: OPENAI_API_VERSIONOpenAI REST API version used for the request.
stringOptionalEnv: AZURE_OPENAI_API_KEYAzure OpenAI API key.
stringOptionalEnv: AZURE_OPENAI_AD_TOKENAzure Active Directory token.
stringOptionalEnv: OPENAI_ORG_IDOpenAI organization ID.
stringOptionalEnv: OPENAI_PROJECT_IDOpenAI project ID.
Additional resources
The following resources provide more information about using Azure OpenAI with LiveKit Agents.
Python package
The livekit-plugins-openai package on PyPI.
Plugin reference
Reference for the Azure OpenAI TTS plugin.
GitHub repo
View the source or contribute to the LiveKit Azure OpenAI plugin.
Azure OpenAI
Azure OpenAI documentation.
Voice AI quickstart
Get started with LiveKit Agents and Azure OpenAI.
Azure ecosystem guide
Overview of the entire Azure AI and LiveKit Agents integration.