Summarization

US & EU

Generate summaries of your audio transcripts using LLM Gateway. This approach gives you full control over the summary format, length, and style by customizing your prompt.

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.

Quickstart

1import requests
2import time
3
4base_url = "https://api.assemblyai.com"
5headers = {"authorization": "<YOUR_API_KEY>"}
6
7# Step 1: Transcribe your audio file
8audio_url = "https://assembly.ai/wildfires.mp3"
9
10data = {
11 "audio_url": audio_url,
12 "speech_models": ["universal-3-pro", "universal-2"],
13 "language_detection": True
14}
15
16response = requests.post(base_url + "/v2/transcript", json=data, headers=headers)
17transcript_id = response.json()['id']
18polling_endpoint = base_url + "/v2/transcript/" + transcript_id
19
20while True:
21 transcription_result = requests.get(polling_endpoint, headers=headers).json()
22 if transcription_result['status'] == 'completed':
23 break
24 elif transcription_result['status'] == 'error':
25 raise RuntimeError(f"Transcription failed: {transcription_result['error']}")
26 else:
27 time.sleep(3)
28
29# Step 2: Generate a summary using LLM Gateway
30prompt = "Provide a brief summary of the transcript in bullet point format."
31
32llm_gateway_data = {
33 "model": "claude-sonnet-4-6",
34 "messages": [
35 {"role": "user", "content": f"{prompt}\n\nTranscript: {transcription_result['text']}"}
36 ],
37 "max_tokens": 1000
38}
39
40response = requests.post(
41 "https://llm-gateway.assemblyai.com/v1/chat/completions",
42 headers=headers,
43 json=llm_gateway_data
44)
45
46result = response.json()["choices"][0]["message"]["content"]
47print(result)

Example output

1- 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.
2- Air pollution levels in Baltimore are considered unhealthy, with exposure to high levels leading to various health problems.
3- 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

1prompt = """Provide a brief summary of the transcript in bullet point format.
2Focus on the key points and main takeaways."""

Paragraph summary

1prompt = """Provide a concise paragraph summary of the transcript.
2Capture the main topics and conclusions."""

Headline summary

1prompt = """Provide a single sentence headline that captures the main topic
2of the transcript."""

Conversational summary

1prompt = """Summarize this conversation between multiple speakers.
2Include who said what and the key points each speaker made."""

Custom format

You can define any format you need:

1prompt = """Summarize the transcript using the following format:
2- Topic: [main topic]
3- Key Points: [list of 3-5 key points]
4- Action Items: [any action items mentioned]
5- Conclusion: [one sentence conclusion]"""

API reference

Step 1: Transcribe audio

$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

$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
>}'
KeyTypeDescription
modelstringThe LLM model to use. See available models.
messagesarrayThe messages to send to the model, including your summarization prompt and transcript text.
max_tokensnumberMaximum number of tokens in the response. Adjust based on desired summary length.

Response

1{
2 "choices": [
3 {
4 "message": {
5 "content": "Your generated summary text..."
6 }
7 }
8 ]
9}

Next steps