> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://murf.ai/api/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://murf.ai/api/docs/_mcp/server.

# LiveKit & Murf

Murf is available as a plugin for [LiveKit Agents](https://docs.livekit.io/agents/), a framework for building voice and multimodal conversational AI applications. Install the `livekit-murf` plugin to use Murf for both ends of the agent loop: Finch for speech-to-text and Falcon 2.1 for text-to-speech, with real-time streaming on each. [Build voice agents](/api/docs/voice-agents) covers the full agent loop and where latency comes from.

## Murf AI plugin

The Murf plugin integrates Murf's [speech-to-text](/api/docs/speech-to-text) and text-to-speech capabilities with [LiveKit Agents](https://docs.livekit.io/agents/). Use `murf.STT` and `murf.TTS` inside an `AgentSession` to transcribe the caller and reply in a natural-sounding voice, both on one Murf API key.

#### [livekit-murf](https://pypi.org/project/livekit-murf/)

Python package on PyPI, with TTS and STT

#### [murf-ai/livekit-murf](https://github.com/murf-ai/livekit-murf)

Source and parameter reference, maintained by Murf

#### [LiveKit Murf AI plugin](https://docs.livekit.io/agents/models/tts/murf/)

LiveKit's TTS-only plugin guide (STT coming soon)

## Installation

Install the Murf plugin from PyPI:

### Using pip

```bash
pip install livekit-murf
```

### Using uv

```bash
uv add livekit-murf
```

This pulls in a compatible `livekit-agents` release (1.5.2 or later).

> **Warning**
>
> Don't install `livekit-murf` and `livekit-plugins-murf` in the same environment. Both provide `livekit.plugins.murf`, and the one installed later replaces the other. `livekit-plugins-murf` is TTS-only, so use `livekit-murf` when you want Murf speech-to-text.

## For Existing LiveKit Projects

If you already have a LiveKit project, you can quickly integrate Murf by initializing the `murf.STT()` and `murf.TTS()` classes in your existing `AgentSession`. Both read the same Murf API key from your environment variables. You can get your Murf API key from the [Murf API Dashboard](https://murf.ai/api/dashboard):

```python
from livekit.plugins import murf

# Add Murf STT and TTS to your existing session
session = AgentSession(
    stt=murf.STT(model="finch_indic_1.0", language="hi,en_IN"),
    llm="your-llm-provider",  # e.g., "openai/gpt-4o"
    tts=murf.TTS(voice="Pooja", style="Conversational", model="falcon-2.1", locale="hi-IN")
    # ... your existing configuration
)
```

[View all configuration parameters →](#configuration)

## Guide to Building Voice Agents with Murf and LiveKit

This guide provides setup instructions and examples for building your first LiveKit Agent with Murf STT and TTS.

## Setup & Requirements

Before running the examples above, ensure you have everything configured properly:

### Requirements

* Python >= 3.10
* livekit-murf >= 0.2.1 (livekit-agents >= 1.5.2)

### Required Packages

The examples in this guide use Murf for speech-to-text and text-to-speech, along with LiveKit plugins for language models (OpenAI) and voice activity detection (Silero). Install all packages used in the examples:

```bash
pip install livekit-murf "livekit-agents[openai,silero]~=1.5" python-dotenv
```

### API Keys

You'll need API keys for the services used in your LiveKit Agent:

* **Murf API Key**: Sign up at the [Murf API Dashboard](https://murf.ai/api/dashboard) and generate your API key. The same key covers both STT and TTS.
* **LiveKit API Credentials**: Get your LiveKit server URL, API key, and secret from [LiveKit Cloud](https://cloud.livekit.io/).
* **Additional Services**: Depending on your setup, you may need an API key for your LLM (e.g., OpenAI) service

### Environment Variables

To keep your API keys secure, it's recommended to use environment variables. Create a `.env` file in your project root:

```env
LIVEKIT_URL=wss://your-livekit-server.livekit.cloud  # Your LiveKit server URL
LIVEKIT_API_KEY=your_livekit_api_key_here           # Your LiveKit API key
LIVEKIT_API_SECRET=your_livekit_api_secret_here     # Your LiveKit API secret
MURF_API_KEY=your_murf_api_key_here                 # Used by both Murf STT and TTS
OPENAI_API_KEY=your_openai_api_key_here             # Required for LLM
```

Then load these variables in your Python code using `python-dotenv`:

```python
from dotenv import load_dotenv
load_dotenv()
```

### Quick Start Example

Here's a simple example of how to create a LiveKit Agent Worker with Murf STT and TTS. It uses Finch-Indic to transcribe a caller speaking Hindi or English (India), and the Pooja voice to reply:

```python
import logging
import os
from dotenv import load_dotenv

load_dotenv()

from livekit.agents import (
    Agent,
    AgentServer,
    AgentSession,
    JobContext,
    JobProcess,
    MetricsCollectedEvent,
    cli,
    metrics,
    room_io,
)
from livekit.plugins import silero, murf
from livekit.plugins import openai as openai_plugin

logger = logging.getLogger("murf-agent")

class MyAgent(Agent):
    def __init__(self) -> None:
        super().__init__(
            instructions=(
                "You are a voice agent built using Murf. The caller speaks Hindi or Indian English, "
                "often mixing the two. Reply in the language they used. Keep responses short and natural."
            )
        )

    async def on_enter(self):
        await self.session.say(
            "Namaste! Main Murf se bani voice agent hoon. Aaj main aapki kya madad kar sakti hoon?"
        )

server = AgentServer()

def prewarm(proc: JobProcess):
    proc.userdata["vad"] = silero.VAD.load()

server.setup_fnc = prewarm

@server.rtc_session()
async def entrypoint(ctx: JobContext):
    ctx.log_context_fields = {"room": ctx.room.name}

    session = AgentSession(
        stt=murf.STT(model="finch_indic_1.0", language="hi,en_IN"),
        llm="openai/gpt-4o",
        tts=murf.TTS(voice="Pooja", style="Conversational", locale="hi-IN"),
        vad=ctx.proc.userdata["vad"],
        preemptive_generation=True,
        resume_false_interruption=True,
        false_interruption_timeout=1.0,
    )

    usage_collector = metrics.UsageCollector()

    @session.on("metrics_collected")
    def on_metrics(ev: MetricsCollectedEvent):
        metrics.log_metrics(ev.metrics)
        usage_collector.collect(ev.metrics)

    async def log_usage():
        logger.info(f"Usage: {usage_collector.get_summary()}")

    ctx.add_shutdown_callback(log_usage)

    await session.start(
        agent=MyAgent(),
        room=ctx.room,
        room_options=room_io.RoomOptions(
            audio_input=room_io.AudioInputOptions()
        ),
    )

if __name__ == "__main__":
    cli.run_app(server)
```

Save this code as `agent.py` and run it with:

```bash
python agent.py console
```

This will start the agent in console where you can directly speak with the agent in the terminal and hear responses in Murf's natural voice.

![Livekit terminal Session](/api/docs/_fern-files/_img/6dac2ab25d723a1c209f1495f61a81c094d130a55e1dfea7f736cb46a89d31a5.webp)

## Configuration

The `murf.STT` and `murf.TTS` classes provide extensive configuration options to customize transcription and voice output according to your needs.

### TTS Parameters Reference

| Parameter | Type  | Default            | Range/Options                    | Description                                       |
| --------- | ----- | ------------------ | -------------------------------- | ------------------------------------------------- |
| `voice`   | `str` | `"Gordon"`         | Any valid Murf voice ID          | Voice identifier for speech generation            |
| `style`   | `str` | `"Conversational"` | Voice-specific styles            | Voice style (e.g., "Conversational", "Narration") |
| `speed`   | `int` | `0`                | `-50` to `50`                    | Speech rate adjustment                            |
| `pitch`   | `int` | `0`                | `-50` to `50`                    | Pitch adjustment                                  |
| `model`   | `str` | `"falcon-2.1"`     | `"falcon-2.1"`                   | The model to use for audio output                 |
| `locale`  | `str` | `None`             | Language codes (e.g., `"en-US"`) | Locale for language-specific speech generation    |

### STT Parameters Reference

`murf.STT` streams the caller's audio to Murf's [Speech to Text WebSocket](/api/docs/speech-to-text/streaming). Partials arrive while the caller is still speaking, and a final transcript arrives when they pause.

| Parameter         | Type            | Default              | Range/Options                                                | Description                                                                            |
| ----------------- | --------------- | -------------------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
| `model`           | `str`           | `"finch_global_1.0"` | `"finch_indic_1.0"`, `"finch_global_1.0"`                    | Finch version to transcribe with                                                       |
| `language`        | `str` \| `list` | `"auto"`             | Murf language codes, or `"auto"`                             | A single code, or several as `"hi,en_IN"` or `["hi", "en_IN"]` to detect from that set |
| `sample_rate`     | `int`           | `16000`              | `8000`, `12000`, `16000`, `24000`, `32000`, `44100`, `48000` | Rate audio is resampled to before it is sent to Murf                                   |
| `keywords`        | `list[str]`     | `None`               | Words or phrases                                             | Terms to boost, such as product names and jargon                                       |
| `alpha`           | `float`         | `0.5`                | `0.0` to `1.0`                                               | How strongly to favour `keywords`                                                      |
| `text_formatting` | `bool`          | `False`              | `True`, `False`                                              | Format numbers and similar terms. Hindi and English (India) only                       |
| `bvc`             | `bool`          | `False`              | `True`, `False`                                              | Remove background voices before transcription                                          |
| `api_key`         | `str`           | `MURF_API_KEY`       | Your Murf API key                                            | Falls back to the `MURF_API_KEY` environment variable                                  |

> **Note**
>
> Each Finch version is served on its own host and transcribes only its own languages. `finch_indic_1.0` runs on `in.api.murf.ai` and covers 11 Indian languages plus English (India); `finch_global_1.0` runs on `us-east.api.murf.ai` and covers English and six European languages. The [Speech to Text overview](/api/docs/speech-to-text) lists both language sets.

### Complete Example with Custom Configuration

Here's a more advanced example showing how to customize the Murf STT and TTS configuration with metrics and error handling. It boosts the terms a support caller is likely to use, and formats numbers in the transcript:

```python
import logging
import os
from dotenv import load_dotenv

load_dotenv()

from livekit.agents import (
    Agent,
    AgentServer,
    AgentSession,
    JobContext,
    JobProcess,
    MetricsCollectedEvent,
    cli,
    metrics,
    room_io,
)
from livekit.plugins import silero, murf
from livekit.plugins import openai as openai_plugin

logger = logging.getLogger("murf-agent")

class CustomAgent(Agent):
    def __init__(self) -> None:
        super().__init__(
            instructions=(
                "You are a billing support assistant for callers in India. They speak Hindi or Indian "
                "English and often mix the two. Reply in the language they used, with a natural speaking "
                "style and concise answers."
            )
        )

    async def on_enter(self):
        await self.session.say(
            "Namaste! Main aapki billing se judi queries mein madad kar sakti hoon. Bataiye, kya help chahiye?"
        )

server = AgentServer()

def prewarm(proc: JobProcess):
    proc.userdata["vad"] = silero.VAD.load()

server.setup_fnc = prewarm

@server.rtc_session()
async def entrypoint(ctx: JobContext):
    ctx.log_context_fields = {"room": ctx.room.name}

    session = AgentSession(
        stt=murf.STT(
            model="finch_indic_1.0",
            language="hi,en_IN",
            sample_rate=16000,
            keywords=["EMI", "NACH", "autopay", "Murf Finance"],
            alpha=0.6,
            text_formatting=True,
        ),
        llm="openai/gpt-4o",
        tts=murf.TTS(
            voice="Pooja",
            style="Conversational",
            speed=5,
            pitch=0,
            model="falcon-2.1",
            sample_rate=24000,
            locale="hi-IN",
        ),
        vad=ctx.proc.userdata["vad"],
        preemptive_generation=True,
        resume_false_interruption=True,
        false_interruption_timeout=1.0,
    )

    usage_collector = metrics.UsageCollector()

    @session.on("metrics_collected")
    def on_metrics(ev: MetricsCollectedEvent):
        metrics.log_metrics(ev.metrics)
        usage_collector.collect(ev.metrics)

    async def log_usage():
        summary = usage_collector.get_summary()
        logger.info(f"Session usage: {summary}")

    ctx.add_shutdown_callback(log_usage)

    await session.start(
        agent=CustomAgent(),
        room=ctx.room,
        room_options=room_io.RoomOptions(
            audio_input=room_io.AudioInputOptions()
        ),
    )

if __name__ == "__main__":
    cli.run_app(server)
```

> 💡 **Try it out**: For complete working examples and deployment guides, see the [`livekit-murf` repository](https://github.com/murf-ai/livekit-murf).

## Features

The Murf integration for LiveKit Agents provides a comprehensive set of features for building voice applications:

* **High-Quality Voice Generation**: Leverage Murf's advanced TTS technology with access to over 150 voices across 35+ languages
* **Real-time Transcription**: Stream the caller's audio to [Finch](/api/docs/models/finch) for interim and final transcripts, with word-level timestamps and keyword boosting
* **Real-time Streaming**: WebSocket-based streaming for low-latency audio generation, perfect for interactive conversations
* **Voice Customization**: Control voice style, rate and  pitch to match your application's needs
* **Multi-Language Support**: Multiple languages and locales with native speaker quality
* **Agent Framework Integration**: Seamless integration with LiveKit's Agent framework for building conversational AI
* **Flexible Configuration**: Comprehensive audio format and quality options including sample rate, channel type, and output formats

## Available Voices

#### [Find your Perfect Voice](https://murf.ai/api/products/text-to-speech/Falcon?utm_source=murf_api_docs)

Explore, preview, and select from 150+ voices in 20+ expressive styles

## Support

If you encounter any issues or have questions:

* **Murf API**: [Documentation](https://murf.ai/api/docs) · [support@murf.ai](mailto:support@murf.ai)
* **Murf plugin**: [Source and parameter reference](https://github.com/murf-ai/livekit-murf) · [Issues](https://github.com/murf-ai/livekit-murf/issues) · [PyPI](https://pypi.org/project/livekit-murf/)
* **LiveKit TTS-only plugin**: [Plugin guide](https://docs.livekit.io/agents/models/tts/murf/) · [Plugin reference](https://docs.livekit.io/reference/python/livekit/plugins/murf/index.html) · [Source](https://github.com/livekit/agents)