Generating a full presentation programmatically — outline, slide content, and images — takes three tools working together: an LLM for the content structure, an image generator for visuals, and python-pptx to assemble it all into an actual .pptx file. Here’s the working pipeline, end to end.
Step 1: Generate the Outline and Content
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY")
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{
"role": "user",
"content": """Create a 5-slide presentation outline about [YOUR TOPIC].
For each slide, provide: a title, 3-4 bullet points, and a one-sentence
image description for a relevant visual. Format as JSON with keys:
title, bullets (list), image_prompt."""
}],
response_format={"type": "json_object"}
)
import json
slides_data = json.loads(response.choices[0].message.content)
Asking for structured JSON output directly (rather than parsing free-form text) makes the rest of the pipeline far more reliable — you’re not writing fragile regex to extract slide titles from prose.
Step 2: Generate Images for Each Slide
def generate_slide_image(prompt, filename):
result = client.images.generate(
model="dall-e-3",
prompt=prompt,
size="1024x1024",
n=1
)
import requests
img_data = requests.get(result.data[0].url).content
with open(filename, "wb") as f:
f.write(img_data)
return filename
DALL-E 3 is the straightforward default here since you’re already using OpenAI for content generation — one API, one billing relationship. If you need a specific visual style or lower cost at higher volume, Stable Diffusion (self-hosted or via a provider like Replicate) is the usual alternative, at the cost of more setup.
Step 3: Assemble the .pptx File
from pptx import Presentation
from pptx.util import Inches, Pt
prs = Presentation()
for i, slide_data in enumerate(slides_data["slides"]):
slide_layout = prs.slide_layouts[1] # Title and Content layout
slide = prs.slides.add_slide(slide_layout)
slide.shapes.title.text = slide_data["title"]
body = slide.placeholders[1].text_frame
for bullet in slide_data["bullets"]:
p = body.add_paragraph()
p.text = bullet
p.font.size = Pt(18)
img_path = generate_slide_image(slide_data["image_prompt"], f"slide_{i}.png")
slide.shapes.add_picture(img_path, Inches(5.5), Inches(1.5), width=Inches(4))
prs.save("generated_presentation.pptx")
Where This Approach Actually Helps
- Batch-generating first drafts for a recurring presentation format (weekly reports, standardized training decks) where the structure repeats but content changes.
- Rapid prototyping of a presentation’s structure and flow before investing design time in the final version.
- Programmatic pipelines where presentation generation is one step in a larger automated workflow, not a one-off manual task.
For a single, important, polished presentation, this pipeline gets you a strong first draft, not a finished product — plan on a manual design pass afterward for layout, spacing, and visual polish that automated generation doesn’t handle well.
Frequently Asked Questions
Do I need both OpenAI’s chat model and DALL-E, or can I use one provider for everything?
You can mix providers freely — the pipeline just needs something that returns structured text (any capable LLM) and something that returns images (DALL-E, Stable Diffusion, Midjourney’s API where available). Using one provider for both simplifies billing but isn’t required.
Is python-pptx able to handle complex slide layouts and animations?
It handles standard layouts, text, and images well, but has limited support for animations and highly custom designs — for those, treat the generated file as a content-complete draft to finish manually in PowerPoint or Google Slides.
Conclusion
A working AI-generated presentation pipeline is three straightforward pieces: an LLM for structured slide content, an image generator for visuals, and python-pptx to assemble the final file. It’s genuinely useful for drafts and repeatable formats — just plan on a manual polish pass for anything presentation-critical.
📑 About the author: I also build Digital Bizz Card — hosted digital business cards you can share with a QR code, no app required.


