AssemblyAI Python SDK
AssemblyAI's Python SDK allows developers to transcribe and understand audio using AI models. It provides access to Speech-to-Text and Audio Intelligence features with a single API call. The library is actively maintained, with frequent releases, and the current version is 0.59.0.
Warnings
- gotcha The official Python SDK is primarily intended for testing and light usage. For high-scale or production traffic, it is recommended to call the AssemblyAI API directly via HTTP requests for best results.
- breaking The LeMUR API will be deprecated on March 31, 2026, and will no longer function after this date. Users must migrate to the LLM Gateway for continued access to language model capabilities.
- gotcha Always store your AssemblyAI API key securely as an environment variable (e.g., `ASSEMBLYAI_API_KEY`) and avoid hardcoding it directly into your code or committing it to version control.
- gotcha The default read operation timeout in the Python SDK is 15 seconds. Longer audio files or slow network conditions may lead to 'read operation timed out' errors.
- gotcha For optimal accuracy, specify current speech models. For asynchronous transcription, use `speech_models=["universal-3-pro", "universal-2"]`. For streaming, use `u3-rt-pro`. Older default models may have reduced performance.
- breaking As of December 2025, security controls were tightened for pre-recorded file transcription. API tokens must now belong to the same project that originally uploaded the file to transcribe it, preventing cross-project access.
Install
-
pip install -U assemblyai
Imports
- assemblyai
import assemblyai as aai
- Transcriber
transcriber = aai.Transcriber()
- TranscriptionConfig
config = aai.TranscriptionConfig(punctuate=True)
- StreamingClient
client = aai.StreamingClient()
Quickstart
import assemblyai as aai
import os
aai.settings.api_key = os.environ.get("ASSEMBLYAI_API_KEY", "")
if not aai.settings.api_key:
raise ValueError("ASSEMBLYAI_API_KEY environment variable not set.")
transcriber = aai.Transcriber()
audio_url = (
"https://storage.googleapis.com/aai-web-samples/5_9_2023_Microsoft_Build_Keynote.mp3"
)
print(f"Transcribing audio from URL: {audio_url}")
transcript = transcriber.transcribe(audio_url)
if transcript.status == aai.TranscriptStatus.error:
print(f"Error: {transcript.error}")
else:
print(f"Transcription status: {transcript.status}")
print(transcript.text)