Generate Action Items with LLM Gateway

This tutorial will demonstrate how to use AssemblyAI’s LLM Gateway framework to create action items from a transcript.

Quickstart

1import requests
2import time
3
4API_KEY = "YOUR_API_KEY"
5audio_url = "https://storage.googleapis.com/aai-web-samples/meeting.mp4"
6
7# Step 1: Upload or provide audio URL and start transcription
8transcript_request = requests.post(
9 "https://api.assemblyai.com/v2/transcript",
10 headers={"authorization": API_KEY, "content-type": "application/json"},
11 json={"audio_url": audio_url},
12)
13
14transcript_id = transcript_request.json()["id"]
15
16# Step 2: Poll until transcription completes
17while True:
18 polling_response = requests.get(
19 f"https://api.assemblyai.com/v2/transcript/{transcript_id}",
20 headers={"authorization": API_KEY},
21 )
22 status = polling_response.json()["status"]
23
24 if status == "completed":
25 transcript_text = polling_response.json()["text"]
26 break
27 elif status == "error":
28 raise RuntimeError(f"Transcription failed: {polling_response.json()['error']}")
29 else:
30 print(f"Transcription status: {status}")
31 time.sleep(3)
32
33# Step 3: Build the prompt
34prompt = """
35Here are guidelines to follow:
36- You are an expert at understanding transcripts of conversations, calls and meetings.
37- You are an expert at coming up with ideal action items based on the contents of the transcripts.
38- Action items are things that the transcript implies should get done.
39- Your action item ideas do not make stuff up that isn't relevant to the transcript.
40- You do not needlessly make up action items - you stick to important tasks.
41- You are useful, true and concise, and write in perfect English.
42- Your action items can be tied back to direct quotes in the transcript.
43- You do not cite the quotes the action items relate to.
44- The action items are written succinctly.
45- Please give useful action items based on the transcript.
46"""
47
48answer_format = "Bullet Points"
49if answer_format:
50 prompt += f"\nYour response should have the following format: {answer_format}"
51
52# Step 4: Send transcript text to LLM Gateway
53headers = {"authorization": API_KEY}
54
55response = requests.post(
56 "https://llm-gateway.assemblyai.com/v1/chat/completions",
57 headers=headers,
58 json={
59 "model": "claude-sonnet-4-5-20250929",
60 "messages": [
61 {
62 "role": "user",
63 "content": f"{prompt}\n\nTranscript:\n{transcript_text}",
64 }
65 ],
66 "max_tokens": 1000,
67 },
68)
69
70# Step 5: Print the LLM-generated action items
71response_json = response.json()
72print(response_json["choices"][0]["message"]["content"])

Getting Started

Before we begin, make sure you have an AssemblyAI account and an API key. You can sign up for an AssemblyAI account and get your API key from your dashboard.

Find more details on the current LLM Gateway pricing in the AssemblyAI pricing page.

Step-by-Step Instructions

In this guide, we will prompt LLM Gateway to generate action items from our transcript.

First, we’ll import the necessary libraries and set our AssemblyAI API key.

1import requests
2import time
3
4API_KEY = "YOUR_API_KEY"

Use AssemblyAI to transcribe a file and save the transcript.

1# Step 1: Upload or provide audio URL and start transcription
2audio_url = "https://storage.googleapis.com/aai-web-samples/meeting.mp4"
3
4transcript_request = requests.post(
5 "https://api.assemblyai.com/v2/transcript",
6 headers={"authorization": API_KEY, "content-type": "application/json"},
7 json={"audio_url": audio_url},
8)
9
10transcript_id = transcript_request.json()["id"]
11
12# Step 2: Poll until transcription completes
13while True:
14 polling_response = requests.get(
15 f"https://api.assemblyai.com/v2/transcript/{transcript_id}",
16 headers={"authorization": API_KEY},
17 )
18 status = polling_response.json()["status"]
19
20 if status == "completed":
21 transcript_text = polling_response.json()["text"]
22 break
23 elif status == "error":
24 raise RuntimeError(f"Transcription failed: {polling_response.json()['error']}")
25 else:
26 print(f"Transcription status: {status}")
27 time.sleep(3)

Provide detailed instructions to prompt LLM Gateway to create action items from the transcript.

1prompt = f"""
2 Here are guidelines to follow:
3 - You are an expert at understanding transcripts of conversations, calls and meetings.
4 - You are an expert at coming up with ideal action items based on the contents of the transcripts.
5 - Action items are things that the transcript implies should get done.
6 - Your action item ideas do not make stuff up that isn't relevant to the transcript.
7 - You do not needlessly make up action items - you stick to important tasks.
8 - You are useful, true and concise, and write in perfect English.
9 - Your action items can be tied back to direct quotes in the transcript.
10 - You do not cite the quotes the action items relate to.
11 - The action items are written succinctly.
12 - Please give useful action items based on the transcript.
13 - Your response should be formatted in bullet points.
14 """

Generate the custom action items using LLM Gateway.

1answer_format = "Bullet Points"
2if answer_format:
3 prompt += f"\nYour response should have the following format: {answer_format}"

Prompt LLM Gateway using the transcript results and return the response.

1# Step 4: Send transcript text to LLM Gateway
2headers = {"authorization": API_KEY}
3
4response = requests.post(
5 "https://llm-gateway.assemblyai.com/v1/chat/completions",
6 headers=headers,
7 json={
8 "model": "claude-sonnet-4-5-20250929",
9 "messages": [
10 {
11 "role": "user",
12 "content": f"{prompt}\n\nTranscript:\n{transcript_text}",
13 }
14 ],
15 "max_tokens": 1000,
16 },
17)
18
19# Step 5: Print the LLM-generated action items
20response_json = response.json()
21print(response_json["choices"][0]["message"]["content"])