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

# Summarization

<AccordionGroup>
  <Accordion title="Supported regions">
    US & EU <br />
  </Accordion>
</AccordionGroup>

Generate summaries of your audio transcripts using [LLM Gateway](/llm-gateway/quickstart). This approach gives you full control over the summary format, length, and style by customizing your prompt.

<Note>
  The `summarization`, `summary_model`, and `summary_type` parameters on the transcription API are deprecated. Use LLM Gateway as shown below for more flexible and powerful summaries.
</Note>

## Quickstart

<Tabs groupId="language">
  <Tab language="python" title="Python" default>
    ```python expandable theme={null}
    import requests
    import time

    base_url = "https://api.assemblyai.com"
    headers = {"authorization": "<YOUR_API_KEY>"}

    # Step 1: Transcribe your audio file
    audio_url = "https://assembly.ai/wildfires.mp3"

    data = {
        "audio_url": audio_url,
        "speech_models": ["universal-3-pro", "universal-2"],
        "language_detection": True
    }

    response = requests.post(base_url + "/v2/transcript", json=data, headers=headers)
    transcript_id = response.json()['id']
    polling_endpoint = base_url + "/v2/transcript/" + transcript_id

    while True:
        transcription_result = requests.get(polling_endpoint, headers=headers).json()
        if transcription_result['status'] == 'completed':
            break
        elif transcription_result['status'] == 'error':
            raise RuntimeError(f"Transcription failed: {transcription_result['error']}")
        else:
            time.sleep(3)

    # Step 2: Generate a summary using LLM Gateway
    prompt = "Provide a brief summary of the transcript in bullet point format."

    llm_gateway_data = {
        "model": "claude-sonnet-4-6",
        "messages": [
            {"role": "user", "content": f"{prompt}\n\nTranscript: {transcription_result['text']}"}
        ],
        "max_tokens": 1000
    }

    response = requests.post(
        "https://llm-gateway.assemblyai.com/v1/chat/completions",
        headers=headers,
        json=llm_gateway_data
    )

    result = response.json()["choices"][0]["message"]["content"]
    print(result)
    ```
  </Tab>

  <Tab language="javascript" title="JavaScript">
    ```javascript expandable theme={null}
    const baseUrl = "https://api.assemblyai.com";

    const headers = {
      authorization: "<YOUR_API_KEY>",
      "content-type": "application/json",
    };

    // Step 1: Transcribe your audio file
    const audioUrl = "https://assembly.ai/wildfires.mp3";

    const data = {
      audio_url: audioUrl,
      speech_models: ["universal-3-pro", "universal-2"],
      language_detection: true,
    };

    const response = await fetch(`${baseUrl}/v2/transcript`, {
      method: "POST",
      headers,
      body: JSON.stringify(data),
    });

    const { id: transcriptId } = await response.json();
    const pollingEndpoint = `${baseUrl}/v2/transcript/${transcriptId}`;

    let transcriptionResult;
    while (true) {
      const pollingResponse = await fetch(pollingEndpoint, { headers });
      transcriptionResult = await pollingResponse.json();

      if (transcriptionResult.status === "completed") {
        break;
      } else if (transcriptionResult.status === "error") {
        throw new Error(`Transcription failed: ${transcriptionResult.error}`);
      } else {
        await new Promise((resolve) => setTimeout(resolve, 3000));
      }
    }

    // Step 2: Generate a summary using LLM Gateway
    const prompt =
      "Provide a brief summary of the transcript in bullet point format.";

    const llmGatewayData = {
      model: "claude-sonnet-4-6",
      messages: [
        {
          role: "user",
          content: `${prompt}\n\nTranscript: ${transcriptionResult.text}`,
        },
      ],
      max_tokens: 1000,
    };

    const result = await fetch(
      "https://llm-gateway.assemblyai.com/v1/chat/completions",
      {
        method: "POST",
        headers,
        body: JSON.stringify(llmGatewayData),
      }
    );

    const resultData = await result.json();
    console.log(resultData.choices[0].message.content);
    ```
  </Tab>
</Tabs>

### Example output

```plain theme={null}
- Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US, with skylines from Maine to Maryland to Minnesota appearing gray and smoggy.
- Air pollution levels in Baltimore are considered unhealthy, with exposure to high levels leading to various health problems.
- With climate change driving more wildfires, experts warn that wide-ranging air quality consequences may become more frequent.
```

## Customize your summary

You can control the summary output by adjusting the prompt. Here are some examples:

### Bullet point summary

```python theme={null}
prompt = """Provide a brief summary of the transcript in bullet point format.
Focus on the key points and main takeaways."""
```

### Paragraph summary

```python theme={null}
prompt = """Provide a concise paragraph summary of the transcript.
Capture the main topics and conclusions."""
```

### Headline summary

```python theme={null}
prompt = """Provide a single sentence headline that captures the main topic
of the transcript."""
```

### Conversational summary

```python theme={null}
prompt = """Summarize this conversation between multiple speakers.
Include who said what and the key points each speaker made."""
```

### Custom format

You can define any format you need:

```python theme={null}
prompt = """Summarize the transcript using the following format:
- Topic: [main topic]
- Key Points: [list of 3-5 key points]
- Action Items: [any action items mentioned]
- Conclusion: [one sentence conclusion]"""
```

## API reference

### Step 1: Transcribe audio

```bash theme={null}
curl https://api.assemblyai.com/v2/transcript \
--header "Authorization: <YOUR_API_KEY>" \
--header "Content-Type: application/json" \
--data '{
  "audio_url": "YOUR_AUDIO_URL"
}'
```

Poll for the transcript result until the status is `completed`, then extract the transcript text.

### Step 2: Generate summary with LLM Gateway

```bash theme={null}
curl https://llm-gateway.assemblyai.com/v1/chat/completions \
--header "Authorization: <YOUR_API_KEY>" \
--header "Content-Type: application/json" \
--data '{
  "model": "claude-sonnet-4-6",
  "messages": [
    {"role": "user", "content": "Provide a brief summary of the transcript.\n\nTranscript: YOUR_TRANSCRIPT_TEXT"}
  ],
  "max_tokens": 1000
}'
```

| Key          | Type   | Description                                                                                 |
| ------------ | ------ | ------------------------------------------------------------------------------------------- |
| `model`      | string | The LLM model to use. See [available models](/llm-gateway/quickstart#available-models).     |
| `messages`   | array  | The messages to send to the model, including your summarization prompt and transcript text. |
| `max_tokens` | number | Maximum number of tokens in the response. Adjust based on desired summary length.           |

### Response

```json theme={null}
{
  "choices": [
    {
      "message": {
        "content": "Your generated summary text..."
      }
    }
  ]
}
```

## Next steps

* [LLM Gateway Overview](/llm-gateway/quickstart) - Learn more about available models and features
* [Apply LLM Gateway to pre-recorded audio](/llm-gateway/apply-llms-to-audio-files) - General guide for using LLM Gateway with transcripts
* [Basic Chat Completions](/llm-gateway/chat-completions) - Learn more about the chat completions API
* [Structured Outputs](/llm-gateway/structured-outputs) - Constrain responses to a specific JSON schema
