> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipecat.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Mistral

> Speech-to-text service using Mistral's Voxtral Realtime transcription API

## Overview

`MistralSTTService` provides real-time speech recognition using Mistral's Voxtral Realtime API. It uses the Mistral SDK's `RealtimeConnection` to stream audio and receive transcription events over WebSocket.

Key features include:

* Streaming transcription with interim results
* Automatic language detection
* VAD-driven utterance lifecycle management
* Built-in metrics support

<CardGroup cols={2}>
  <Card title="Mistral STT API Reference" icon="code" href="https://reference-server.pipecat.ai/en/latest/api/pipecat.services.mistral.stt.html">
    Pipecat's API methods for Mistral STT
  </Card>

  <Card title="Example Implementation" icon="play" href="https://github.com/pipecat-ai/pipecat/blob/main/examples/voice/voice-mistral.py">
    Complete example with Mistral STT and TTS
  </Card>

  <Card title="Transcription Example" icon="play" href="https://github.com/pipecat-ai/pipecat/blob/main/examples/transcription/transcription-mistral.py">
    Transcription-only example
  </Card>

  <Card title="Mistral Documentation" icon="book" href="https://docs.mistral.ai/">
    Official Mistral API documentation
  </Card>
</CardGroup>

## Installation

To use Mistral STT service, install the required dependencies:

```bash theme={null}
uv add "pipecat-ai[mistral]"
```

## Prerequisites

Before using `MistralSTTService`, you need:

1. **Mistral Account**: Sign up at [Mistral AI](https://mistral.ai/)
2. **API Key**: Generate an API key from your account dashboard
3. **Model Access**: Ensure you have access to the Voxtral Realtime API

### Required Environment Variables

* `MISTRAL_API_KEY`: Your Mistral API key for authentication

## Configuration

<ParamField path="api_key" type="str">
  Mistral API key for authentication.
</ParamField>

<ParamField path="base_url" type="str" default="None">
  Custom API endpoint URL. Leave empty for the default Mistral endpoint.
</ParamField>

<ParamField path="sample_rate" type="int" default="None">
  Audio sample rate in Hz. When `None`, uses the pipeline's configured sample
  rate.
</ParamField>

<ParamField path="target_streaming_delay_ms" type="int" default="None">
  Streaming delay for accuracy/latency tradeoff. Higher values may improve
  accuracy at the cost of latency.
</ParamField>

<ParamField path="ttfs_p99_latency" type="float" default="MISTRAL_TTFS_P99">
  P99 latency from speech end to final transcript in seconds. Override for your
  deployment.
</ParamField>

<ParamField path="settings" type="MistralSTTService.Settings" default="None">
  Runtime-configurable settings for the STT service. See [Settings](#settings)
  below.
</ParamField>

### Settings

Runtime-configurable settings passed via the `settings` constructor argument using `MistralSTTService.Settings(...)`. These can be updated mid-conversation with `STTUpdateSettingsFrame`. See [Service Settings](/pipecat/fundamentals/service-settings) for details.

| Parameter  | Type              | Default                                   | Description                                                            |
| ---------- | ----------------- | ----------------------------------------- | ---------------------------------------------------------------------- |
| `model`    | `str`             | `"voxtral-mini-transcribe-realtime-2602"` | Mistral STT model to use. *(Inherited from base STT settings.)*        |
| `language` | `Language \| str` | `None`                                    | Language hint for transcription. *(Inherited from base STT settings.)* |

## Usage

### Basic Setup

```python theme={null}
import os
from pipecat.services.mistral import MistralSTTService

stt = MistralSTTService(
    api_key=os.getenv("MISTRAL_API_KEY"),
)
```

### With Custom Settings

```python theme={null}
import os
from pipecat.services.mistral import MistralSTTService

stt = MistralSTTService(
    api_key=os.getenv("MISTRAL_API_KEY"),
    target_streaming_delay_ms=1000,
    settings=MistralSTTService.Settings(
        model="voxtral-mini-transcribe-realtime-2602",
        language="en",
    ),
)
```

## Notes

* **SDK-managed WebSocket**: The service extends `STTService` directly (rather than `WebsocketSTTService`) because the Mistral SDK manages the WebSocket connection internally.
* **Language detection**: When `language` is not specified in settings, the service automatically detects the spoken language and includes it in the transcription frames.
* **VAD integration**: The service works with VAD (Voice Activity Detection) to manage utterance lifecycle. When the user starts speaking, it begins accumulating interim transcripts. When the user stops, it flushes remaining audio for final transcription.

## Event Handlers

Supports the standard [service connection events](/api-reference/server/events/service-events):

| Event                 | Description                   |
| --------------------- | ----------------------------- |
| `on_connected`        | Transcription session created |
| `on_disconnected`     | Connection closed             |
| `on_connection_error` | Transcription error occurred  |

```python theme={null}
@stt.event_handler("on_connected")
async def on_connected(stt):
    print("Mistral STT connected")

@stt.event_handler("on_connection_error")
async def on_connection_error(stt, error_msg):
    print(f"Connection error: {error_msg}")
```
