Model selection

The speech_models parameter lets you specify which model to use for transcription. You can provide multiple models in priority order, and our system will automatically route to the best available model based on your request.

Model routing behavior: The system attempts to use the models in priority order falling back to the next model when needed. For example, with ["universal-3-pro", "universal-2"], the system will try to use universal-3-pro for languages it supports (English, Spanish, Portuguese, French, German, and Italian), and automatically fall back to Universal for all other languages. This ensures you get the best performing transcription where available while maintaining the widest language coverage.

Identifying the Model Used in Your Request

The API returns a field called speech_model_used that tells you which specific model was actually used to process your request.

NameParameterDescription
Universal-3-Prospeech_models=['universal-3-pro']Our highest accuracy model with fine-tuning support and customization via prompting.
Universal-2speech_models=['universal-2']Our highly accurate, fastest performing model with support across 99 languages.

Quickstart

You can change the model by setting speech_models in the transcription config:

1import assemblyai as aai
2
3aai.settings.api_key = "<YOUR_API_KEY>"
4
5audio_file = "https://assembly.ai/wildfires.mp3"
6
7config = aai.TranscriptionConfig(
8 speech_models=["universal-3-pro", "universal-2"],
9 language_detection=True
10)
11transcript = aai.Transcriber(config=config).transcribe(audio_file)
12
13if transcript.status == aai.TranscriptStatus.error:
14 raise RuntimeError(f"Transcription failed: {transcript.error}")
15
16print(transcript.text)

Identify the model used

After transcription completes, you can check which model was actually used to process your request by reading the speech_model_used field. This is useful when you provide multiple models in the speech_models array, as the system may fall back to a different model depending on language support.

1import assemblyai as aai
2
3aai.settings.api_key = "<YOUR_API_KEY>"
4
5audio_file = "https://assembly.ai/wildfires.mp3"
6
7config = aai.TranscriptionConfig(
8 speech_models=["universal-3-pro", "universal-2"],
9 language_detection=True
10)
11transcript = aai.Transcriber(config=config).transcribe(audio_file)
12
13if transcript.status == aai.TranscriptStatus.error:
14 raise RuntimeError(f"Transcription failed: {transcript.error}")
15
16print(f"Model used: {transcript.json_response['speech_model_used']}")
17print(transcript.text)

Complete example

Here is the full working code that demonstrates model selection with error handling:

1import assemblyai as aai
2
3aai.settings.api_key = "<YOUR_API_KEY>"
4
5audio_file = "https://assembly.ai/wildfires.mp3"
6
7config = aai.TranscriptionConfig(
8 speech_models=["universal-3-pro", "universal-2"],
9 language_detection=True,
10)
11
12transcript = aai.Transcriber(config=config).transcribe(audio_file)
13
14if transcript.status == aai.TranscriptStatus.error:
15 raise RuntimeError(f"Transcription failed: {transcript.error}")
16
17print(f"Model used: {transcript.json_response['speech_model_used']}")
18print(f"\nTranscript:\n\n{transcript.text}")