Quickstart: transcribe an audio file

This tutorial will show you how to transcribe audio from a file. To transcribe prerecorded audio from other sources, see File transcription. To transcribe streaming audio in real time, see the realtime quickstart.

Get an API key

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

Install the SDK

To use Python or TypeScript, install the Mistral SDK. The curl example needs no install.

pip install mistralai
Transcribe your audio

Transcribe your audio

To follow along without a file of your own, download the sample recording, a 3-minute speech in English:

curl -O https://docs.mistral.ai/audio/obama.mp3

Use this code to transcribe speech from an audio file to text. The speech can be in multiple languages.

import os

from mistralai.client import Mistral

client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])

with open("obama.mp3", "rb") as audio:
    transcription = client.audio.transcriptions.complete(
        model="voxtral-mini-transcribe-3",
        file={"file_name": "obama.mp3", "content": audio},
    )

print(transcription.text)
You should see

You should see

The curl example returns the full JSON response, and the SDK examples print its text field. The transcript of the sample recording is shortened here with [...]:

This week, I traveled to Chicago to deliver my final farewell address to the nation, following in the tradition of presidents before me. It was an opportunity to say thank you. [...] Thanks, everybody. God bless you, and God bless the United States of America.
Going further

Going further