Bias context and vocabulary
Context biasing steers transcription toward the names, terms, and acronyms you expect, so they come out spelled the way you write them. You send it as a list of entries, each one a keyphrase or a description of the recording, in file and realtime transcription alike.
For why names come out wrong and when each kind of context fits, see Custom vocabulary.
Bias with keyphrases
To fix specific terms, send each one as an entry of context_bias. An entry can hold several words, such as a company name.
import os
from mistralai.client import Mistral
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
def transcribe(context_bias=None):
with open("customer_call.wav", "rb") as audio:
return client.audio.transcriptions.complete(
model="voxtral-mini-transcribe-3",
file={"file_name": "customer_call.wav", "content": audio},
context_bias=context_bias,
).text
print("Without bias:", transcribe())
print("With bias: ", transcribe(["Northwind", "Quillara", "Alder Creek Design", "Rotterdam"]))The example transcribes the same call twice, without and with context. The product name and the company name change:
Without bias: Thanks for calling Northwind Support. [...] I ordered two Quilliera headsets last week. [...] I also need an invoice for my company, Older Creek Design. [...]
With bias: Thanks for calling Northwind Support. [...] I ordered two Quillara headsets last week, [...] I also need an invoice for my company, Alder Creek Design. [...]Describe the recording
An entry can also be a sentence or a paragraph that describes the recording: what it's about, who speaks, and which names come up. Send it the same way as a keyphrase.
curl https://api.mistral.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $MISTRAL_API_KEY" \
-F model=voxtral-mini-transcribe-3 \
-F file=@customer_call.wav \
-F "context_bias=Support call for Northwind about an order of Quillara headsets shipped from the Rotterdam warehouse and invoiced to Alder Creek Design."List every term that must come out right as its own keyphrase. When the recording has a clear subject, add a description to the same list. In realtime sessions, a description alone might not fix a term that a keyphrase fixes.
Use it in realtime sessions
In a realtime session, send context_bias as a JSON array of strings in session.update, before the first audio chunk.
{
"type": "session.update",
"session": {
"audio_format": { "encoding": "pcm_s16le", "sample_rate": 24000 },
"context_bias": ["Northwind", "Quillara", "Alder Creek Design", "Rotterdam"]
}
}The context applies to the whole session. After the first audio chunk, the session rejects any change to its fields with an error event.
The Python SDK sends context_bias, language, and turn_detection in the stt config of client.audio.sessions.init(). See the Voice Agents SDK configuration. Realtime transcription has a complete script. In voice agents, set context_bias in the speech-to-text options: see Agent options.
Entry format
Both modes take the same entries, sent in a different way:
| File transcription | Realtime session | |
|---|---|---|
| How to send it | Repeat the context_bias form field once per entry. In Python, pass a list of strings. | Set context_bias to an array of strings in session.update. |
| One entry | A term, a name of several words, or a description of the recording | Same |
| Characters | Spaces, commas, and other punctuation are accepted | Same |
| Default | No context | No context (an empty array) |
| Scope | The request | The whole session, set before the first audio chunk |
| Models | voxtral-mini-transcribe-3, voxtral-small-transcribe-3 | voxtral-mini-transcribe-realtime-3 |
Limits and errors
Context has no budget of its own: its entries count toward the model's context window, together with the audio. A long recording leaves less room for context, so keep the list to the terms and descriptions that matter.
When the audio and the context together go over the window, the request fails and the API doesn't shorten your list:
| Situation | Mode | What you get |
|---|---|---|
| The audio and the context exceed the context window | File transcription | A 400 error of type invalid_request_prompt_too_long, whose message gives the size of the request and the maximum |
session.update sent after the first audio chunk | Realtime session | An error event: Session fields cannot be changed after audio has started. |