- Studio
- Voice
- Speech to Text
Context bias: keyphrases and free-form text
Context bias: keyphrases and free-form text
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 free-form text that gives context about 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.
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=Northwind \
-F context_bias=Quillara \
-F "context_bias=Alder Creek Design" \
-F context_bias=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. [...]
Add free-form text
An entry can also be a sentence or a paragraph that provides additional context to the recording. Send it the same way as a keyphrase. The model uses this text to improve its transcription.
For example, if the recording is a court case, the text can be excerpts from the legal documents of the case. If the recording is a user answering an agent's question, the text can be the question that the agent asked:
curl https://api.mistral.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $MISTRAL_API_KEY" \
-F model=voxtral-mini-transcribe-3 \
-F file=@customer_answer.wav \
-F "context_bias=Which Quillara headset model did you order, and to which Northwind warehouse was it shipped?"
Free-form text gives the model context for the words it transcribes. It isn't an instruction: don't use it to ask for things about the audio, such as transcribing background sounds or formatting the text of one speaker.
List every term that must come out right as its own keyphrase, and add free-form text to the same list when you have it. In realtime sessions, free-form text 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 free-form text about 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 the text 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. |
Going further
Custom vocabulary
Why names, drugs, and product terms come out wrong in transcription and in generated speech, and the hint that fixes each direction: context biasing for spelling, custom pronunciation for sound.
File transcription
Transcribe recorded audio: send a file, a URL, or an uploaded file, pin the language, get segment timestamps, and stream the response.
Languages
How each Voxtral 3 model handles languages for transcription, speech generation, and translation, and where to find its supported languages.
Troubleshooting
The errors that transcription requests and realtime sessions return, the usual causes of a poor or missing transcript, and the setting that fixes each one.