> ## Documentation Index
> Fetch the complete documentation index at: https://assemblyai.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Transcribe a short audio file

> Learn how to transcribe an audio file synchronously with the Sync API.

## 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:

> [tab] Python SDK
>
> ```python theme={null}
> import os
>
> from assemblyai.sync.v1 import SyncTranscriber, SyncTranscriptionConfig
>
> config = SyncTranscriptionConfig(model="universal-3-6-pro")
> transcriber = SyncTranscriber(api_key=os.environ["ASSEMBLYAI_API_KEY"], config=config)
> transcriber.warm()  # open the connection ahead of the request
> result = transcriber.transcribe("./sample.wav")
> print(result.text)
> ```

> [tab] JavaScript SDK
>
> ```javascript theme={null}
> import { AssemblyAI } from "assemblyai";
>
> const client = new AssemblyAI({ apiKey: process.env.ASSEMBLYAI_API_KEY });
>
> await client.sync.warm(); // open the connection ahead of the request
> const result = await client.sync.transcribe("./sample.wav", {
>   model: "universal-3-6-pro",
> });
> console.log(result.text);
> ```

`warm()` opens the HTTPS connection ahead of the request. Call it as soon as you know audio is coming, so the handshake is done by the time you have the clip; [Connection pre-warming](https://assemblyai.com/docs/sync-stt/connection-pre-warming.md) explains what it saves.

The Sync API uses our flagship Universal-3.6 Pro model. The SDKs' `transcribe()` accepts WAV or raw PCM audio up to 120 seconds. To send up to 20 minutes, or a compressed format such as MP3, post the file to `POST /v1/transcribe` [over HTTP](#using-the-http-api-directly). It transcribes with state-of-the-art accuracy in [32 languages](https://assemblyai.com/docs/sync-stt/language-selection.md#supported-languages).

Not using an SDK? The same flow works over plain HTTP — see [Using the HTTP API directly](#using-the-http-api-directly).

> [!NOTE]
>
> **When to use Sync STT**
>
> Sync STT is ideal for pre-recorded audio up to 20 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 20 minutes, use [Pre-recorded STT](https://assemblyai.com/docs/pre-recorded-audio/getting-started/transcribe-an-audio-file.md).
> For audio still being recorded, upload it as you capture it with
> [live audio](https://assemblyai.com/docs/sync-stt/getting-started/transcribe-live-audio.md), which accepts up to
> 120 seconds; for words returned
> *while* the speaker is still talking, use
> [Real-time STT](https://assemblyai.com/docs/streaming/getting-started/transcribe-streaming-audio.md).

## Before you begin

To complete this guide, you need:

* **An API key** — browse to API Keys (`https://www.assemblyai.com/dashboard/signup?utm_source=docs_md&utm_medium=ai_agent&utm_campaign=agent_docs`) in your dashboard and copy your key. Every example below reads it from an environment variable, so set it once:

  ```bash theme={null}
  export ASSEMBLYAI_API_KEY=<your-key>
  ```

* **An audio file** in WAV format (or raw PCM S16LE), up to 120 seconds long for the SDKs, or up to 20 minutes [over HTTP](#using-the-http-api-directly).

* **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

> [tab] Python SDK
>
> ```bash theme={null}
> pip install -U assemblyai
> ```

> [tab] JavaScript SDK
>
> ```bash theme={null}
> npm install assemblyai
> ```

### Step 2: Run your first transcription

No WAV file? Download one under 120 seconds from [Sample audio files](https://assemblyai.com/docs/samples).

Save this as `transcribe.py` (Python) or `transcribe.mjs` (JavaScript), next to a `sample.wav` file:

> [tab] Python SDK
>
> ```python theme={null}
> import os
>
> from assemblyai.sync.v1 import SyncTranscriber, SyncTranscriptionConfig
>
> config = SyncTranscriptionConfig(model="universal-3-6-pro")
> transcriber = SyncTranscriber(api_key=os.environ["ASSEMBLYAI_API_KEY"], config=config)
> transcriber.warm()  # open the connection ahead of the request
> result = transcriber.transcribe("./sample.wav")
> print(result.text)
> ```

> [tab] JavaScript SDK
>
> ```javascript theme={null}
> import { AssemblyAI } from "assemblyai";
>
> const client = new AssemblyAI({ apiKey: process.env.ASSEMBLYAI_API_KEY });
>
> await client.sync.warm(); // open the connection ahead of the request
> const result = await client.sync.transcribe("./sample.wav", {
>   model: "universal-3-6-pro",
> });
> console.log(result.text);
> ```

Then run it — `python transcribe.py` or `node transcribe.mjs`. You'll see the transcript printed:

```text theme={null}
Hi, I'm calling about my Best Buy order...
```

`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](https://assemblyai.com/docs/pre-recorded-audio/getting-started/transcribe-an-audio-file.md).

## Customize your request

Beyond the model, the call above needs no extra configuration. Pass a config to change how the audio is transcribed — in Python a `SyncTranscriptionConfig`, 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. Set it to `universal-3-6-pro`. The SDKs currently default to `universal-3-5-pro`, which is retired, so requests that use it are routed to `universal-3-6-pro`. See [Speech model versions and deprecations](https://assemblyai.com/docs/getting-started/model-versions-and-deprecations.md).

> [tab] Python SDK
>
> ```python theme={null}
> from assemblyai.sync.v1 import SyncTranscriptionConfig
>
> config = SyncTranscriptionConfig(model="universal-3-6-pro")
> transcriber.warm()  # open the connection ahead of the request
> result = transcriber.transcribe("./sample.wav", config=config)
> ```

> [tab] JavaScript SDK
>
> ```javascript theme={null}
> await client.sync.warm(); // open the connection ahead of the request
> const result = await client.sync.transcribe("./sample.wav", {
>   model: "universal-3-6-pro",
> });
> ```

### Choose a language

Pass [`language_codes`](https://assemblyai.com/docs/sync-stt/language-selection) as a list of ISO 639-1 codes — one code for monolingual audio, several for multilingual audio:

> [tab] Python SDK
>
> ```python theme={null}
> from assemblyai.sync.v1 import SyncTranscriptionConfig
>
> config = SyncTranscriptionConfig(model="universal-3-6-pro", language_codes=["es"])
> transcriber.warm()  # open the connection ahead of the request
> result = transcriber.transcribe("./sample.wav", config=config)
> ```

> [tab] JavaScript SDK
>
> ```javascript theme={null}
> await client.sync.warm(); // open the connection ahead of the request
> const result = await client.sync.transcribe("./sample.wav", {
>   model: "universal-3-6-pro",
>   language_codes: ["es"],
> });
> ```

### Get word timestamps

Per-word timings are opt-in. Set [`timestamps=True`](https://assemblyai.com/docs/sync-stt/word-timestamps) to compute `start`/`end` for every word, at a small latency cost. Without it, words carry `text` and `confidence` only:

> [tab] Python SDK
>
> ```python theme={null}
> from assemblyai.sync.v1 import SyncTranscriptionConfig
>
> config = SyncTranscriptionConfig(model="universal-3-6-pro", timestamps=True)
> transcriber.warm()  # open the connection ahead of the request
> result = transcriber.transcribe("./sample.wav", config=config)
>
> for word in result.words:
>     print(word.text, word.start, word.end)  # milliseconds
> ```

> [tab] JavaScript SDK
>
> ```javascript theme={null}
> await client.sync.warm(); // open the connection ahead of the request
> const result = await client.sync.transcribe("./sample.wav", {
>   model: "universal-3-6-pro",
>   timestamps: true,
> });
>
> for (const word of result.words) {
>   console.log(word.text, word.start, word.end); // milliseconds
> }
> ```

### 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 set `sample_rate` and `channels` on the config — both are required, and setting either one routes the audio as raw PCM:

> [tab] Python SDK
>
> ```python theme={null}
> from assemblyai.sync.v1 import SyncTranscriptionConfig
>
> config = SyncTranscriptionConfig(
>     model="universal-3-6-pro", sample_rate=16000, channels=1
> )
>
> transcriber.warm()  # open the connection ahead of the request
> with open("./sample.pcm", "rb") as f:
>     result = transcriber.transcribe(f.read(), config=config)
>
> print(result.text)
> ```

> [tab] JavaScript SDK
>
> ```javascript theme={null}
> import { readFileSync } from "fs";
>
> const audio = readFileSync("./sample.pcm");
>
> await client.sync.warm(); // open the connection ahead of the request
> const result = await client.sync.transcribe(audio, {
>   model: "universal-3-6-pro",
>   sample_rate: 16000,
>   channels: 1,
> });
>
> console.log(result.text);
> ```

## Complete example

Here's the complete, runnable script — the call above plus options and error handling:

> [tab] Python SDK
>
> ```python expandable theme={null}
> import os
>
> from assemblyai.sync.v1 import (
>     SyncTranscriber,
>     SyncTranscriptError,
>     SyncTranscriptionConfig,
> )
>
> config = SyncTranscriptionConfig(
>     model="universal-3-6-pro",
>     language_codes=["en"],
>     timestamps=True,
> )
>
> with SyncTranscriber(api_key=os.environ["ASSEMBLYAI_API_KEY"]) as transcriber:
>     try:
>         transcriber.warm()  # open the connection ahead of the request
>         result = transcriber.transcribe("./sample.wav", config=config)
>     except SyncTranscriptError as error:
>         # error_code is machine-readable (bad_audio, audio_too_large,
>         # capacity_exceeded, inference_timeout, ...); retry_after is set on
>         # 429/503 responses. See /sync-stt/error-handling
>         raise RuntimeError(
>             f"Transcription failed ({error.status_code}/{error.error_code}): {error}"
>         ) from error
>
>     # Record session_id for every request, not just errors — it's the first
>     # thing support@assemblyai.com asks for.
>     print(f"session_id: {result.session_id}")
>     print(f"\nFull Transcript:\n\n{result.text}")
>
>     for word in result.words:
>         print(f"{word.text} ({word.confidence:.2f}) {word.start}-{word.end}ms")
> ```

> [tab] JavaScript SDK
>
> ```javascript expandable theme={null}
> import { AssemblyAI, SyncTranscriptError } from "assemblyai";
>
> const client = new AssemblyAI({ apiKey: process.env.ASSEMBLYAI_API_KEY });
>
> try {
>   await client.sync.warm(); // open the connection ahead of the request
>   const result = await client.sync.transcribe("./sample.wav", {
>     model: "universal-3-6-pro",
>     language_codes: ["en"],
>     timestamps: true,
>   });
>
>   // Record session_id for every request, not just errors — it's the first
>   // thing support@assemblyai.com asks for.
>   console.log(`session_id: ${result.session_id}`);
>   console.log(`\nFull Transcript:\n\n${result.text}`);
>
>   for (const word of result.words) {
>     console.log(
>       `${word.text} (${word.confidence.toFixed(2)}) ${word.start}-${word.end}ms`
>     );
>   }
> } catch (error) {
>   if (error instanceof SyncTranscriptError) {
>     // errorCode is machine-readable (bad_audio, audio_too_large,
>     // capacity_exceeded, inference_timeout, ...); retryAfter is set on
>     // 429/503 responses. See /sync-stt/error-handling
>     throw new Error(
>       `Transcription failed (${error.status}/${error.errorCode}): ${error.message}`
>     );
>   }
>   throw error;
> }
> ```

> [!NOTE]
>
> `warm()` only pays off while the connection is still fresh. Clients evict
> idle connections after seconds to minutes. See
> [Connection pre-warming](https://assemblyai.com/docs/sync-stt/connection-pre-warming.md) for how the
> handshake works, pool-expiry tuning, and when to re-warm.

## What you get back

`transcribe()` returns a `SyncTranscriptResponse` with the transcript and word-level details:

| Attribute | Description |
| - | - |
| `result.text` | Full transcript of the audio. |
| `result.words` | Per-word `text` and `confidence`, plus `start`/`end` timestamps (in milliseconds) when the request sets [`timestamps=True`](https://assemblyai.com/docs/sync-stt/word-timestamps). Otherwise `start`/`end` are `None`. |
| `result.confidence` | Overall transcript confidence score (0–1). |
| `result.audio_duration_ms` | Duration of the submitted audio in milliseconds. |
| `result.session_id` | Server-generated UUID. Include this when contacting support. |
| `result.request_time_ms` | End-to-end server-side processing time for the request, in milliseconds. |

## Errors

Every error returns an RFC 9457 problem-details body,
`{"status", "title", "detail"}`, with Content-Type `application/problem+json`.
`title` is the stable identity of the error, such as `Audio Too Large` or
`Capacity Exceeded`; `detail` is a human-readable explanation.

The SDKs raise `SyncTranscriptError` for every failed request. It carries the
HTTP status, an error code (the `title` in snake case, such as
`audio_too_large`), and the `Retry-After` value in seconds when the response
sets one: `status_code`/`error_code`/`retry_after` in Python and
`status`/`errorCode`/`retryAfter` in JavaScript.

The SDKs send every request, `transcribe()` included, through
`/v1/transcribe/live`, which caps audio at 120 seconds. Over HTTP,
`POST /v1/transcribe` accepts up to 20 minutes and returns `504`
(`Inference Timeout`) if the request passes its 30-second server deadline.

See [Error handling](https://assemblyai.com/docs/sync-stt/error-handling.md) for the full status code table
and retry guidance.

## Using the HTTP API directly

If you prefer to call the Sync API over HTTP without an SDK, post the audio to `POST https://sync.assemblyai.com/v1/transcribe` and read the transcript out of the JSON response. This endpoint accepts audio up to 20 minutes long and 256 MB, in WAV, raw PCM, or a compressed format (AAC, MP3, M4A, Ogg/Opus, FLAC, or WebM); see [Audio requirements](https://assemblyai.com/docs/sync-stt/audio-requirements.md).

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 (a `Bearer ` prefix is optional), and send the `X-AAI-Model: universal-3-6-pro` header — it is required on every request.

For the lowest latency, send an unauthenticated `GET /v1/warm` request (with the same `X-AAI-Model` header) through the same HTTP client as soon as you know audio is coming. The `/transcribe` request then reuses the already-open connection instead of paying for DNS, TCP, and TLS setup first.

> [tab] cURL
>
> Replace `<YOUR_API_KEY>` in the request header:
>
> ```bash theme={null}
> # Each curl process opens its own connection, so chain the warm-up and the
> # transcription in one invocation with --next to share the connection:
> curl https://sync.assemblyai.com/v1/warm \
>   -H 'X-AAI-Model: universal-3-6-pro' \
>   --next \
>   -X POST https://sync.assemblyai.com/v1/transcribe \
>   -H 'Authorization: <YOUR_API_KEY>' \
>   -H 'X-AAI-Model: universal-3-6-pro' \
>   -F 'audio=@sample.wav;type=audio/wav'
> ```
>
> The response JSON is printed to stdout. Pipe to `jq` to extract fields:
>
> ```bash theme={null}
> curl -X POST https://sync.assemblyai.com/v1/transcribe \
>   -H 'Authorization: <YOUR_API_KEY>' \
>   -H 'X-AAI-Model: universal-3-6-pro' \
>   -F 'audio=@sample.wav;type=audio/wav' \
>   | jq '.text'
> ```

> [tab] Python
>
> Install the `requests` library if you haven't already:
>
> ```bash theme={null}
> pip install requests
> ```
>
> Send the audio file and parse the response:
>
> ```python expandable theme={null}
> import requests
>
> # Create the Session once and reuse it. The warmed connection lives
> # in its connection pool.
> session = requests.Session()
>
> # Call as soon as you know audio is coming (e.g. recording starts),
> # not right before transcribe.
> session.get(
>     "https://sync.assemblyai.com/v1/warm",
>     headers={"X-AAI-Model": "universal-3-6-pro"},
>     timeout=10,
> )
>
> with open("sample.wav", "rb") as f:
>     audio = f.read()
>
> # Same session -> reuses the warmed connection; no handshake here.
> response = session.post(
>     "https://sync.assemblyai.com/v1/transcribe",
>     headers={
>         "Authorization": "<YOUR_API_KEY>",
>         "X-AAI-Model": "universal-3-6-pro",
>     },
>     files={
>         "audio": ("sample.wav", audio, "audio/wav"),
>     },
>     timeout=60,
> )
> response.raise_for_status()
> result = response.json()
> print(result["text"])
> print(result["session_id"])
> ```

> [tab] JavaScript
>
> ```javascript expandable theme={null}
> import { readFileSync } from "fs";
>
> // Call as soon as you know audio is coming (e.g. recording starts),
> // not right before transcribe. Node's fetch pools the connection by default.
> await fetch("https://sync.assemblyai.com/v1/warm", {
>   headers: { "X-AAI-Model": "universal-3-6-pro" },
> });
>
> const audio = readFileSync("sample.wav");
> const form = new FormData();
> form.append("audio", new Blob([audio], { type: "audio/wav" }), "sample.wav");
>
> // Same process -> reuses the warmed connection; no handshake here.
> const response = await fetch("https://sync.assemblyai.com/v1/transcribe", {
>   method: "POST",
>   headers: {
>     Authorization: "<YOUR_API_KEY>",
>     "X-AAI-Model": "universal-3-6-pro",
>   },
>   body: form,
> });
>
> if (!response.ok) {
>   const error = await response.json();
>   throw new Error(`${error.title}: ${error.detail}`);
> }
>
> const result = await response.json();
> console.log(result.text);
> console.log(result.session_id);
> ```

### Response shape

A successful request returns a JSON object with the transcript and word-level details:

```json theme={null}
{
  "text": "Hi, I'm calling about my Best Buy order...",
  "words": [
    { "text": "Hi",  "confidence": 0.91 },
    { "text": "I'm", "confidence": 0.88 }
  ],
  "confidence": 0.87,
  "audio_duration_ms": 101567,
  "session_id": "eb92c4ff-4bbb-429f-9b99-7279d7fe738f",
  "request_time_ms": 243.7
}
```

| Field | Description |
| - | - |
| `text` | Full transcript of the audio. |
| `words` | Per-word `confidence`, plus `start`/`end` timestamps (in milliseconds) when the request enables [word timestamps](https://assemblyai.com/docs/sync-stt/word-timestamps.md). |
| `confidence` | Overall transcript confidence score (0–1). |
| `audio_duration_ms` | Duration of the submitted audio in milliseconds. |
| `session_id` | Server-generated UUID. Include this when contacting support. |
| `request_time_ms` | End-to-end server-side processing time for the request, in milliseconds. |

### Sending raw PCM audio

When your audio is raw PCM (S16LE little-endian), set the `audio` part Content-Type to `audio/pcm` and include `sample_rate` and `channels` in the `config` part:

> [tab] cURL
>
> ```bash theme={null}
> curl -X POST https://sync.assemblyai.com/v1/transcribe \
>   -H 'Authorization: <YOUR_API_KEY>' \
>   -H 'X-AAI-Model: universal-3-6-pro' \
>   -F 'audio=@sample.pcm;type=audio/pcm' \
>   -F 'config={"sample_rate":16000,"channels":1};type=application/json'
> ```

> [tab] Python
>
> ```python theme={null}
> import json
> import requests
>
> with open("sample.pcm", "rb") as f:
>     audio = f.read()
>
> response = requests.post(
>     "https://sync.assemblyai.com/v1/transcribe",
>     headers={
>         "Authorization": "<YOUR_API_KEY>",
>         "X-AAI-Model": "universal-3-6-pro",
>     },
>     files={
>         "audio": ("sample.pcm", audio, "audio/pcm"),
>         "config": (
>             None,
>             json.dumps({"sample_rate": 16000, "channels": 1}),
>             "application/json",
>         ),
>     },
>     timeout=60,
> )
> response.raise_for_status()
> print(response.json()["text"])
> ```

> [tab] JavaScript
>
> ```javascript theme={null}
> import { readFileSync } from "fs";
>
> const audio = readFileSync("sample.pcm");
> const form = new FormData();
> form.append("audio", new Blob([audio], { type: "audio/pcm" }), "sample.pcm");
> form.append(
>   "config",
>   new Blob(
>     [JSON.stringify({ sample_rate: 16000, channels: 1 })],
>     { type: "application/json" }
>   )
> );
>
> const response = await fetch("https://sync.assemblyai.com/v1/transcribe", {
>   method: "POST",
>   headers: {
>     Authorization: "<YOUR_API_KEY>",
>     "X-AAI-Model": "universal-3-6-pro",
>   },
>   body: form,
> });
>
> const result = await response.json();
> console.log(result.text);
> ```

## Next steps

* [Prompting and keyterms](https://assemblyai.com/docs/sync-stt/prompting-and-keyterms.md) — improve accuracy with contextual prompts and keyterm biasing
* [Conversation context](https://assemblyai.com/docs/sync-stt/conversation-context.md) — pass prior dialogue for multi-turn continuity
* [Language selection](https://assemblyai.com/docs/sync-stt/language-selection.md) — transcribe in any of the 32 supported languages
* [Word timestamps](https://assemblyai.com/docs/sync-stt/word-timestamps.md) — get per-word `start`/`end` timings
* [Audio requirements](https://assemblyai.com/docs/sync-stt/audio-requirements.md) — duration, size, and format constraints
* [Connection pre-warming](https://assemblyai.com/docs/sync-stt/connection-pre-warming.md) — cut the handshake off the critical path
* [Error handling](https://assemblyai.com/docs/sync-stt/error-handling.md) — status codes and retry guidance
* [Cloud endpoints & data residency](https://assemblyai.com/docs/sync-stt/endpoints-and-data-zones.md) — use the EU endpoint for data residency
* [API reference](https://assemblyai.com/docs/api-reference/sync-api/transcribe.md) — full endpoint documentation

## Need help?

If you get stuck, contact our support team at [support@assemblyai.com](mailto:support@assemblyai.com) or create a [support ticket](https://www.assemblyai.com/contact/support). Include the `session_id` from the response to help us look up your request.
