Getting startedEnd-to-end examples

Content repurposing

Transcribe a podcast or webinar, extract key phrases, then use LLM Gateway to generate a blog post draft with highlights.

Products used: Pre-recorded STT + key phrases + LLM Gateway

Model selection: Uses universal-3-pro with universal-2 fallback for multilingual content. If your content is English-only, universal-3-pro alone gives the best results.

1import requests
2import time
3
4# ── Config ────────────────────────────────────────────────────
5base_url = "https://api.assemblyai.com"
6headers = {"authorization": "YOUR_API_KEY"}
7
8audio_url = "https://assembly.ai/wildfires.mp3"
9
10# ── Step 1: Transcribe with key phrases enabled ──
11data = {
12 "audio_url": audio_url,
13 "speech_models": ["universal-3-pro", "universal-2"],
14 "language_detection": True,
15 "auto_highlights": True,
16}
17
18response = requests.post(base_url + "/v2/transcript", headers=headers, json=data)
19response.raise_for_status()
20transcript_id = response.json()["id"]
21
22while True:
23 result = requests.get(f"{base_url}/v2/transcript/{transcript_id}", headers=headers).json()
24 if result["status"] == "completed":
25 break
26 elif result["status"] == "error":
27 raise RuntimeError(f"Transcription failed: {result['error']}")
28 time.sleep(3)
29
30# ── Step 2: Get paragraph-level content for structure ──
31paragraphs_response = requests.get(
32 f"{base_url}/v2/transcript/{transcript_id}/paragraphs", headers=headers
33)
34paragraphs = paragraphs_response.json()["paragraphs"]
35
36# ── Step 3: Extract top key phrases ──
37highlights = result.get("auto_highlights_result", {}).get("results", [])
38top_phrases = sorted(highlights, key=lambda x: x["rank"], reverse=True)[:10]
39phrases_list = ", ".join(p["text"] for p in top_phrases)
40
41# ── Step 4: Generate blog post via LLM Gateway ──
42transcript_text = result["text"]
43
44llm_response = requests.post(
45 "https://llm-gateway.assemblyai.com/v1/chat/completions",
46 headers=headers,
47 json={
48 "model": "claude-sonnet-4-5-20250929",
49 "messages": [
50 {
51 "role": "user",
52 "content": (
53 "You are a content writer. Transform this transcript into an engaging "
54 "blog post.\n\n"
55 "Requirements:\n"
56 "- Write a compelling title and subtitle\n"
57 "- Break the content into 3-5 sections with headers\n"
58 "- Weave in the key phrases naturally\n"
59 "- Add a TL;DR at the top\n"
60 "- End with a call-to-action\n\n"
61 f"Key phrases: {phrases_list}\n\n"
62 f"Transcript:\n{transcript_text}"
63 ),
64 }
65 ],
66 "max_tokens": 3000,
67 },
68)
69llm_response.raise_for_status()
70
71print("=== Blog Post Draft ===\n")
72print(llm_response.json()["choices"][0]["message"]["content"])
=== Blog Post Draft ===
# When the Sky Turns Orange: Understanding Wildfire Smoke and Air Quality
**How Canadian wildfires are reshaping air quality across the United States**
**TL;DR:** Wildfire smoke from Canada is triggering widespread air quality alerts
in the US, with particulate matter levels reaching 10x normal in some cities.
Here's what you need to know about the health risks and how to protect yourself.
## The smoke crosses borders
Hundreds of wildfires burning across Canada have sent massive plumes of smoke
southward into the United States, creating hazy skies and triggering air quality
alerts from the Midwest to the Eastern Seaboard...
## Understanding particulate matter
The real danger lies in fine particulate matter — microscopic particles that
can penetrate deep into your lungs and even enter your bloodstream...
## Protecting your health
Health experts recommend staying indoors, using air purifiers, and wearing
N95 masks when outdoor exposure is unavoidable...
## Looking ahead
As climate change intensifies wildfire seasons, these cross-border smoke events
are likely to become more frequent...
---
*Want to transcribe your own podcast or webinar? Get started with AssemblyAI's
API at [assemblyai.com](https://assemblyai.com).*

See the End-to-end examples overview for all available pipelines.