Overview
Send an audio file in a single call, get a transcript back in milliseconds. No polling, no session management. The SDKs wrap the whole round trip in one method:- Python SDK
- JavaScript SDK
When to use Sync STTSync STT is ideal for pre-recorded audio clips under 2 minutes where you need
an immediate response without polling — for example, voice message transcription,
short call recordings, or voice agent pipelines that handle turn detection
externally and submit completed utterances for transcription. For audio longer
than 120 seconds, use Pre-recorded STT.
For live microphone audio, use Real-time STT.
Before you begin
To complete this guide, you need:-
An API key — browse to API Keys in your dashboard and copy your key. Every example below reads it from an environment variable, so set it once:
- An audio file in WAV format (or raw PCM S16LE), between 80 milliseconds and 120 seconds long.
- Python 3.8+ for the Python SDK, or Node.js 18+ for the JavaScript SDK. The HTTP examples at the bottom of this page need Python 3.8+, Node.js 18+, or cURL.
Transcribe your first file
Step 1: Install the SDK
- Python SDK
- JavaScript SDK
Step 2: Run your first transcription
Save this astranscribe.py (Python) or transcribe.mjs (JavaScript), next to a sample.wav file:
- Python SDK
- JavaScript SDK
python transcribe.py or node transcribe.mjs. You’ll see the transcript printed:
transcribe() accepts a local file path or raw audio bytes — an open binary file object in Python, or a Uint8Array, Blob, or readable stream in JavaScript — but not a URL. The Sync API has no URL ingestion; for remote files, download them first or use Pre-recorded STT.
Customize your request
The call above works with no extra configuration. Pass a config to change how the audio is transcribed — in Python aSyncTranscriptionConfig, either as the transcriber’s default (SyncTranscriber(config=...)) or per call (transcribe(data, config=...)); in JavaScript, a plain object as the second argument to transcribe().
Select a model
model selects the sync speech model and defaults to universal-3-5-pro. Set it explicitly to pin the model:
- Python SDK
- JavaScript SDK
Choose a language
Passlanguage_codes as a list of ISO 639-1 codes — one code for monolingual audio, several for multilingual audio:
- Python SDK
- JavaScript SDK
Get word timestamps
Per-word timings are opt-in. Settimestamps=True to compute start/end for every word, at a small latency cost. Without it, words carry text and confidence only:
- Python SDK
- JavaScript SDK
Transcribe raw PCM audio
WAV files carry their sample rate and channel count in the file header. Raw PCM (S16LE little-endian) doesn’t, so setsample_rate and channels on the config — both are required, and setting either one routes the audio as raw PCM:
- Python SDK
- JavaScript SDK
Complete example
Here’s the complete, runnable script — the call above plus options and error handling:- Python SDK
- JavaScript SDK
Calling the Sync API repeatedly?
warm() opens the connection ahead of time
so your next transcribe() doesn’t pay the DNS, TCP, and TLS handshake on the
critical path. See Connection pre-warming.What you get back
transcribe() returns a SyncTranscriptResponse with the transcript and word-level details:
Failed requests raise
SyncTranscriptError, which carries the HTTP status, a machine-readable error code (for example bad_audio, audio_too_large, capacity_exceeded, inference_timeout), and a retry-after value in seconds for 429/503 responses — named status_code/error_code/retry_after in the Python SDK and status/errorCode/retryAfter in the JavaScript SDK. See Error handling for status codes and retry guidance.
Using the HTTP API directly
If you prefer to call the Sync API over HTTP without an SDK, post the audio toPOST https://sync.assemblyai.com/transcribe and read the transcript out of the JSON response.
The Sync API accepts multipart/form-data with an audio part. For WAV files, set the part’s Content-Type to audio/wav. Authenticate with your key in the Authorization header (no Bearer prefix), and send the X-AAI-Model: universal-3-5-pro header — it is required on every request.
- cURL
- Python
- JavaScript
Replace The response JSON is printed to stdout. Pipe to
<YOUR_API_KEY> in the request header:jq to extract fields:Response shape
A successful request returns a JSON object with the transcript and word-level details:Sending raw PCM audio
When your audio is raw PCM (S16LE little-endian), set theaudio part Content-Type to audio/pcm and include sample_rate and channels in the config part:
- cURL
- Python
- JavaScript
Next steps
- Prompting and keyterms — improve accuracy with contextual prompts and keyterm biasing
- Conversation context — pass prior dialogue for multi-turn continuity
- Language selection — transcribe in any of the 19 supported languages
- Word timestamps — get per-word
start/endtimings - Audio requirements — duration, size, and format constraints
- Connection pre-warming — cut the handshake off the critical path
- Error handling — status codes and retry guidance
- Cloud endpoints & data residency — use the EU endpoint for data residency
- API reference — full endpoint documentation
Need help?
If you get stuck, contact our support team at support@assemblyai.com or create a support ticket. Include thesession_id from the response to help us look up your request.