Bias Speech to Speech transcription with language_hint and keyterms
Bias Speech to Speech transcription with language_hint and keyterms
Set audio.input.transcription.language_hint and keyterms on session.update. Both can change mid-session. The model still auto-detects language when you omit the hint.
Language hint
Pass a BCP-47 code. Spanish and Portuguese need a regional variant — "es" and "pt" are rejected. Unknown codes are ignored and detection stays automatic.
import json
await ws.send(json.dumps({
"type": "session.update",
"session": {
"audio": {
"input": {
"transcription": {
"language_hint": "ja"
}
}
}
}
}))
| Language | Code |
|---|---|
| English | en |
| Japanese | ja |
| Spanish (Mexico) | es-MX |
| Spanish (Spain) | es-ES |
| Portuguese (Brazil) | pt-BR |
| Portuguese (Portugal) | pt-PT |
| Arabic (Egypt) | ar-EG |
| Arabic (Saudi Arabia) | ar-SA |
| Arabic (UAE) | ar-AE |
| Chinese (Simplified) | zh |
| French | fr |
| German | de |
| Hindi | hi |
| Indonesian | id |
| Italian | it |
| Korean | ko |
| Bengali | bn |
| Russian | ru |
| Turkish | tr |
| Vietnamese | vi |
The roster above is the documented native-quality set. You can still put a preferred language or accent in instructions for the spoken reply.
Keyterms
Bias ASR toward product names, proper nouns, and domain terms. Max 100 strings, each up to 50 characters.
await ws.send(json.dumps({
"type": "session.update",
"session": {
"audio": {
"input": {
"transcription": {
"language_hint": "en",
"keyterms": ["xAI", "Grok", "Understand The Universe"]
}
}
}
}
}))
Send another session.update when the caller switches language or when a new term list should apply.
Pitfalls
- Bare
"es"/"pt"fail; usees-MX,es-ES,pt-BR, orpt-PT. - A typo in
language_hintis silent — transcription falls back to auto-detect. - Keyterms over 50 characters or more than 100 entries are invalid; keep the list short and specific.
- Console API credits are separate from SuperGrok's weekly pool on grok.com.