Building an Automated AI Presentation Generator with LLMs and python-pptx
Generating PowerPoint presentations with AI is often locked behind subscription paywalls and rigid templates. This article walks through building a custom, low-cost automated workflow that decouples content generation from slide rendering: a large language model produces structured JSON outlines, and a Python script renders them into polished .pptx files using python-pptx. It includes working code, architecture design, and deployment tips for team-level use.
For developers and project managers, creating slide decks is an unavoidable part of the job. Many have tried one-click AI presentation generators to speed things up, only to find that most platforms tie this feature to paid membership tiers, blocking lightweight users behind commercial paywalls. This article skips the product comparisons and takes a practical, engineering-focused look at how to build a controllable, low-cost presentation generation workflow using a general-purpose LLM and automation scripts.
Current State and Pain Points of AI Presentation Generators
The typical AI slide-generation flow looks the same everywhere: you enter a topic, set the target number of slides, pick a style like “business” or “minimal,” and the system generates an outline and renders the slides automatically. While this lowers the interaction barrier, two real pain points emerge in practice:
- Commercial paywalls. Separating content generation from rendering is standard practice in AI text and image generation, but in the presentation space, most platforms put a membership wall in front of the rendering step. For developers who only occasionally need to build a report deck, paying a subscription for a single feature offers poor value.
- Limited layout control. Built-in generation logic usually relies on fixed templates, which rarely meet the fine-grained requirements of technical presentations—code block display, architecture diagram placement, and so on. Deep customization often costs as much effort as building the deck from scratch.
Given these pain points, developers can absolutely build a private, fully controllable presentation pipeline using general-purpose LLM APIs and open-source rendering libraries.
Architecture: A Decoupled Automation Workflow
The core idea behind a custom solution is decoupling content generation from layout rendering. The workflow has two stages:
- Structured content generation: Call a general-purpose LLM API to turn a vague topic description into structured text with a clear hierarchy (Markdown or JSON).
- Automated rendering: Use a document-processing library such as Python’s
python-pptxto parse the structured text, apply predefined template rules, and output the final .pptx file.
This architecture sidesteps third-party commercial restrictions and gives developers absolute control over the layout logic.
Implementation Details and Code
1. Generating a Structured Outline with an LLM
First, design a well-crafted prompt that guides the model to return a standardized JSON outline, which is easy for downstream scripts to parse:
import jsonimport requestsdef generate_ppt_outline(topic, page_count, style):prompt = f"""You are a professional technical presentation expert. Based on the topic "{topic}",generate an outline for a {page_count}-slide presentation.Style requirement: {style}.Return strictly valid JSON in the following structure:{{"title": "Presentation main title","slides": [{{"slide_title": "Slide title","bullet_points": ["Point 1", "Point 2"],"notes": "Speaker notes"}}]}}"""# Call a general-purpose LLM API service here.# Developers can integrate with any compatible chat completion endpoint,# such as Baidu AI Cloud's Qianfa large model platform or similar services.api_url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions"headers = {"Content-Type": "application/json"}payload = {"messages": [{"role": "user", "content": prompt}]}# Add authentication token in production# response = requests.post(api_url, headers=headers, json=payload)# result = response.json()# Mocked response for demonstrationmock_result = {"title": f"Technical Practice Sharing: {topic}","slides": [{"slide_title": "Background", "bullet_points": ["Industry status", "Pain point analysis"], "notes": "Brief overview"},{"slide_title": "Technical Solution", "bullet_points": ["Architecture design", "Core modules"], "notes": "Detail the solution"}]}return mock_result
2. Automated Rendering with python-pptx
Once you have the structured JSON, use the python-pptx library to render it into a presentation. You can pre-design a slide master and fill in content via code for consistent styling:
from pptx import Presentationfrom pptx.util import Inches, Ptdef render_ppt(outline_data, output_path):# Initialize the presentationprs = Presentation()# Set slide size to 16:9prs.slide_width = Inches(13.333)prs.slide_height = Inches(7.5)for slide_data in outline_data.get("slides", []):# Use a blank layout for custom positioningslide_layout = prs.slide_layouts[6]slide = prs.slides.add_slide(slide_layout)# Add the titletitle_box = slide.shapes.add_textbox(Inches(0.5), Inches(0.5), Inches(12), Inches(1))tf = title_box.text_frametf.text = slide_data.get("slide_title", "")# Set font size and boldp = tf.paragraphs[0]p.font.size = Pt(32)p.font.bold = True# Add bullet pointscontent_box = slide.shapes.add_textbox(Inches(0.8), Inches(2), Inches(11), Inches(5))ctf = content_box.text_framectf.word_wrap = Truefor idx, point in enumerate(slide_data.get("bullet_points", [])):if idx == 0:p = ctf.paragraphs[0]else:p = ctf.add_paragraph()p.text = f"• {point}"p.font.size = Pt(20)p.space_after = Pt(12)prs.save(output_path)print(f"PPT generated successfully at: {output_path}")# Run the generation pipelineif __name__ == "__main__":topic = "Building an Automated Operations System"page_num = 10style = "Minimalist technical style"outline = generate_ppt_outline(topic, page_num, style)render_ppt(outline, "output_presentation.pptx")
Deployment and Enterprise-Level Enhancements
Running the script locally works, but it doesn’t support team collaboration or on-demand access. For enterprise use, consider a cloud-native deployment:
- Wrap it as a service. Package the Python script as a RESTful API deployed on a container platform or serverless function service. Team members simply send an HTTP request with a topic and slide count, and the deck is generated asynchronously in the cloud.
- Integrate cloud storage. Upload generated files directly to object storage (such as BOS) and return a temporary download link, avoiding local storage pressure on the server.
- Model selection. When calling the LLM, you can flexibly switch between models of different parameter sizes to balance generation quality against token cost.
Conclusion
Rather than being confined to the UI interactions of a single commercial product, developers can combine “LLM-generated structured content + Python-controlled rendering” to avoid unnecessary subscription costs and gain full control over layouts and diagrams. With cloud compute and storage orchestration layered on top, this approach can evolve into an internal efficiency tool that provides standardized, high-quality automation for frequent technical reporting.
