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:

    1. 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.
    2. 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-pptx to 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:

    1. import json
    2. import requests
    3. def generate_ppt_outline(topic, page_count, style):
    4. prompt = f"""
    5. You are a professional technical presentation expert. Based on the topic "{topic}",
    6. generate an outline for a {page_count}-slide presentation.
    7. Style requirement: {style}.
    8. Return strictly valid JSON in the following structure:
    9. {{
    10. "title": "Presentation main title",
    11. "slides": [
    12. {{
    13. "slide_title": "Slide title",
    14. "bullet_points": ["Point 1", "Point 2"],
    15. "notes": "Speaker notes"
    16. }}
    17. ]
    18. }}
    19. """
    20. # Call a general-purpose LLM API service here.
    21. # Developers can integrate with any compatible chat completion endpoint,
    22. # such as Baidu AI Cloud's Qianfa large model platform or similar services.
    23. api_url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions"
    24. headers = {"Content-Type": "application/json"}
    25. payload = {
    26. "messages": [{"role": "user", "content": prompt}]
    27. }
    28. # Add authentication token in production
    29. # response = requests.post(api_url, headers=headers, json=payload)
    30. # result = response.json()
    31. # Mocked response for demonstration
    32. mock_result = {
    33. "title": f"Technical Practice Sharing: {topic}",
    34. "slides": [
    35. {"slide_title": "Background", "bullet_points": ["Industry status", "Pain point analysis"], "notes": "Brief overview"},
    36. {"slide_title": "Technical Solution", "bullet_points": ["Architecture design", "Core modules"], "notes": "Detail the solution"}
    37. ]
    38. }
    39. 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:

    1. from pptx import Presentation
    2. from pptx.util import Inches, Pt
    3. def render_ppt(outline_data, output_path):
    4. # Initialize the presentation
    5. prs = Presentation()
    6. # Set slide size to 16:9
    7. prs.slide_width = Inches(13.333)
    8. prs.slide_height = Inches(7.5)
    9. for slide_data in outline_data.get("slides", []):
    10. # Use a blank layout for custom positioning
    11. slide_layout = prs.slide_layouts[6]
    12. slide = prs.slides.add_slide(slide_layout)
    13. # Add the title
    14. title_box = slide.shapes.add_textbox(Inches(0.5), Inches(0.5), Inches(12), Inches(1))
    15. tf = title_box.text_frame
    16. tf.text = slide_data.get("slide_title", "")
    17. # Set font size and bold
    18. p = tf.paragraphs[0]
    19. p.font.size = Pt(32)
    20. p.font.bold = True
    21. # Add bullet points
    22. content_box = slide.shapes.add_textbox(Inches(0.8), Inches(2), Inches(11), Inches(5))
    23. ctf = content_box.text_frame
    24. ctf.word_wrap = True
    25. for idx, point in enumerate(slide_data.get("bullet_points", [])):
    26. if idx == 0:
    27. p = ctf.paragraphs[0]
    28. else:
    29. p = ctf.add_paragraph()
    30. p.text = f"• {point}"
    31. p.font.size = Pt(20)
    32. p.space_after = Pt(12)
    33. prs.save(output_path)
    34. print(f"PPT generated successfully at: {output_path}")
    35. # Run the generation pipeline
    36. if __name__ == "__main__":
    37. topic = "Building an Automated Operations System"
    38. page_num = 10
    39. style = "Minimalist technical style"
    40. outline = generate_ppt_outline(topic, page_num, style)
    41. 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:

    1. 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.
    2. 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.
    3. 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.