Skip to main content
IntroductionBuild AgentsAgent FrontendsTelephonyWebRTC TransportManage & DeployReferences

Azure OpenAI TTS plugin guide

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

Available inPython

Overview

This plugin allows you to use Azure OpenAI  as a TTS provider for your voice agents.

Installation

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

Install the plugin from PyPI:

uv add "livekit-agents[openai]~=1.5"

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 openai
session = 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.

modelstringDefault: gpt-4o-mini-tts

ID of the model to use for TTS. To learn more, see Text to speech models .

voicestringDefault: ash

OpenAI text-to-speech voice. To learn more, see the list of supported voices for voice in the Azure documentation .

instructionsstring

Instructions to control tone, style, and other characteristics of the speech.

azure_endpointstringEnv: AZURE_OPENAI_ENDPOINT

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

azure_deploymentstring

Name of your model deployment.

api_versionstringEnv: OPENAI_API_VERSION

OpenAI REST API version used for the request.

api_keystringEnv: AZURE_OPENAI_API_KEY

Azure OpenAI API key.

azure_ad_tokenstringEnv: AZURE_OPENAI_AD_TOKEN

Azure Active Directory token.

organizationstringEnv: OPENAI_ORG_ID

OpenAI organization ID.

projectstringEnv: OPENAI_PROJECT_ID

OpenAI project ID.

Additional resources

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