Quickstart: transcribe speech in realtime
Stream live audio to the realtime transcription API and get a transcript with low latency. For offline transcription of prerecorded files, see Transcribe an audio file.
Get an API key
First, you'll need a Mistral API key. If you don't have one, then go to Studio. Navigate to the API keys section and create a new API key.
Store your API key in the MISTRAL_API_KEY environment variable:
export MISTRAL_API_KEY="your-api-key"Install the SDK
The realtime transcription client requires the realtime extra.
pip install "mistralai[realtime]"Connect and stream
The realtime API uses a WebSocket connection. The SDK opens the connection, streams audio chunks to the server, and yields transcription events as they arrive. The example below reads a WAV file in 100 ms chunks and streams them at real-time pace, simulating a live microphone. For a real microphone input, replace read_chunks with your audio source.
To follow along without a file of your own, download the sample recording:
curl -O https://docs.mistral.ai/audio/chat.wavimport asyncio
import os
import wave
from mistralai.client import Mistral
from mistralai.client.models import (
AudioFormat,
RealtimeTranscriptionError,
TranscriptionStreamDone,
TranscriptionStreamTextDelta,
)
AUDIO_FILE = "chat.wav" # 16-bit mono PCM WAV
async def read_chunks(path):
with wave.open(path, "rb") as wav:
while chunk := wav.readframes(wav.getframerate() // 10):
yield chunk
await asyncio.sleep(0.1) # send 100 ms of audio every 100 ms, like a live source
async def main():
with wave.open(AUDIO_FILE, "rb") as wav:
sample_rate = wav.getframerate()
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
async for event in client.audio.realtime.transcribe_stream(
read_chunks(AUDIO_FILE),
model="voxtral-mini-transcribe-realtime-3",
audio_format=AudioFormat(encoding="pcm_s16le", sample_rate=sample_rate),
):
if isinstance(event, TranscriptionStreamTextDelta):
print(event.text, end="", flush=True)
elif isinstance(event, TranscriptionStreamDone):
print(f"\n\nFinal transcript: {event.text}")
elif isinstance(event, RealtimeTranscriptionError):
print(f"\nError: {event.error.message}")
asyncio.run(main())You should see
The script prints the transcript as it arrives, then the final transcript:
Transcribe what I'm about to say. Today, on July 15th, 2025, Mistral AI is announcing the new Voxtral models. Okay, and the transcription there and then write code to give the first n digits of the Fibonacci sequence.
Final transcript: Transcribe what I'm about to say. Today, on July 15th, 2025, Mistral AI is announcing the new Voxtral models. Okay, and the transcription there and then write code to give the first n digits of the Fibonacci sequence.