LiveKit docs › Build Agents › Models › TTS › Additional models › Microsoft AI

---

# Microsoft AI TTS plugin guide

> How to use the Microsoft AI TTS plugin for LiveKit Agents.

Available in:
- [ ] Node.js
- [x] Python

## Overview

This plugin allows you to use [MAI voices](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/mai-voices) from Microsoft AI as a TTS provider for your voice agents. The plugin synthesizes speech with the Azure Speech REST API.

### Installation

Install the plugin from PyPI:

```shell
uv add "livekit-agents[microsoft-ai]~=1.8"

```

### Authentication

The plugin requires an [Azure Speech](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/overview) resource key and region. Set the following environment variables in your `.env` file:

```shell
MICROSOFT_AI_TTS_API_KEY=<your-speech-resource-key>
MICROSOFT_AI_TTS_REGION=<your-speech-region>

```

### Usage

Use Microsoft AI TTS in an `AgentSession` or as a standalone speech generator. For example, you can use this TTS in the [Voice AI quickstart](https://docs.livekit.io/agents/start/voice-ai.md).

```python
from livekit.agents import AgentSession
from livekit.plugins import microsoft_ai

session = AgentSession(
    tts=microsoft_ai.TTS(
        voice="en-US-Harper",
        model="MAI-Voice-2.1-Flash",
        sample_rate=24000,
    ),
    # ... llm, stt, etc.
)

```

> ℹ️ **Default values**
> 
> The plugin has no default model, voice, or sample rate. Set each one in the constructor or with its environment variable.

### Parameters

This section describes some of the available parameters. See the [plugin reference](https://docs.livekit.io/reference/python/livekit/plugins/microsoft_ai/index.html.md#livekit.plugins.microsoft_ai.TTS) for a complete list of all available parameters.

- **`voice`** _(string)_ - Environment: `MICROSOFT_AI_TTS_VOICE`: Voice name, for example `en-US-Harper`. The plugin appends `model` to form the voice ID. You can also pass a full voice ID such as `en-US-Harper:MAI-Voice-2.1-Flash`.

- **`model`** _(string)_ - Environment: `MICROSOFT_AI_TTS_MODEL`: MAI voice model, for example `MAI-Voice-2.1-Flash`. Optional when `voice` is a full voice ID. If you set both, the model must match the suffix of `voice` (case-insensitive).

- **`sample_rate`** _(integer)_ - Environment: `MICROSOFT_AI_TTS_SAMPLE_RATE`: Output sample rate in Hz. Valid values are `8000`, `22050`, `24000`, `44100`, and `48000`.

- **`language`** _(string)_ (optional) - Default: `en-US`: Language tag for the SSML request.

- **`region`** _(string)_ (optional) - Environment: `MICROSOFT_AI_TTS_REGION`: Azure Speech region, for example `eastus`. Required unless you set `url`.

- **`url`** _(string)_ (optional) - Environment: `MICROSOFT_AI_TTS_URL`: Full synthesis endpoint URL. Use this parameter for sovereign clouds or custom endpoints. This value overrides `region`.

## Additional resources

The following resources provide more information about using Microsoft AI with LiveKit Agents.

- **[Python package](https://pypi.org/project/livekit-plugins-microsoft-ai/)**: The `livekit-plugins-microsoft-ai` package on PyPI.

- **[Plugin reference](https://docs.livekit.io/reference/python/livekit/plugins/microsoft_ai/index.html.md#livekit.plugins.microsoft_ai.TTS)**: Reference for the Microsoft AI TTS plugin.

- **[GitHub repo](https://github.com/livekit/agents/tree/main/livekit-plugins/livekit-plugins-microsoft-ai)**: View the source or contribute to the LiveKit Microsoft AI plugin.

- **[Microsoft AI STT](https://docs.livekit.io/agents/models/stt/microsoft-ai.md)**: Guide to the Microsoft AI STT plugin with LiveKit Agents.

---

This document was rendered at 2026-11-14T14:45:02.971Z.
For the latest version of this document, see [https://docs.livekit.io/agents/models/tts/microsoft-ai.md](https://docs.livekit.io/agents/models/tts/microsoft-ai.md).

To explore all LiveKit documentation, see [llms.txt](https://docs.livekit.io/llms.txt).