{"id":3404,"library":"assemblyai","title":"AssemblyAI Python SDK","description":"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.","status":"active","version":"0.59.0","language":"en","source_language":"en","source_url":"https://github.com/AssemblyAI/assemblyai-python-sdk","tags":["AI","speech-to-text","audio-processing","transcription","NLP","audio-intelligence"],"install":[{"cmd":"pip install -U assemblyai","lang":"bash","label":"Install the AssemblyAI SDK"}],"dependencies":[],"imports":[{"note":"Standard alias for the SDK.","symbol":"assemblyai","correct":"import assemblyai as aai"},{"note":"Initializes the transcription client.","symbol":"Transcriber","correct":"transcriber = aai.Transcriber()"},{"note":"Used to configure transcription options like punctuation, speaker labels, or model.","symbol":"TranscriptionConfig","correct":"config = aai.TranscriptionConfig(punctuate=True)"},{"note":"Used for real-time, streaming transcription from a microphone or other live audio source.","symbol":"StreamingClient","correct":"client = aai.StreamingClient()"}],"quickstart":{"code":"import assemblyai as aai\nimport os\n\naai.settings.api_key = os.environ.get(\"ASSEMBLYAI_API_KEY\", \"\")\n\nif not aai.settings.api_key:\n    raise ValueError(\"ASSEMBLYAI_API_KEY environment variable not set.\")\n\ntranscriber = aai.Transcriber()\n\naudio_url = (\n    \"https://storage.googleapis.com/aai-web-samples/5_9_2023_Microsoft_Build_Keynote.mp3\"\n)\n\nprint(f\"Transcribing audio from URL: {audio_url}\")\ntranscript = transcriber.transcribe(audio_url)\n\nif transcript.status == aai.TranscriptStatus.error:\n    print(f\"Error: {transcript.error}\")\nelse:\n    print(f\"Transcription status: {transcript.status}\")\n    print(transcript.text)\n","lang":"python","description":"This quickstart transcribes an audio file from a publicly accessible URL. It retrieves the API key from an environment variable `ASSEMBLYAI_API_KEY` for security. The `Transcriber` handles the transcription process, including polling for completion."},"warnings":[{"fix":"For production-level scaling, consider implementing direct HTTP calls to the AssemblyAI API, following their official documentation for HTTP code examples.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Migrate your LeMUR integrations to use AssemblyAI's LLM Gateway by March 31, 2026. Refer to the official migration guide for details.","message":"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.","severity":"breaking","affected_versions":"All versions using LeMUR after March 31, 2026"},{"fix":"Use `os.environ.get(\"ASSEMBLYAI_API_KEY\")` to retrieve your API key. Ensure your `.env` file is excluded from version control (e.g., via `.gitignore`).","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Increase the timeout value if experiencing timeouts, though the documentation for how to explicitly set this in the latest SDK version isn't immediately clear in search results. Check the latest SDK docs or consider direct API calls for fine-grained control.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pass `config=aai.TranscriptionConfig(speech_models=[\"universal-3-pro\"])` (or other desired models) to `Transcriber()` or the `.transcribe()` method. For streaming, ensure `u3-rt-pro` is used if applicable.","message":"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.","severity":"gotcha","affected_versions":"All versions (best practice)"},{"fix":"Ensure that the API token used for transcription belongs to the same AssemblyAI project where the audio file was uploaded.","message":"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.","severity":"breaking","affected_versions":"Versions after December 2025"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}