How to use AI to create a PowerPoint presentation?

Andreas Nigg
Andreas Nigg · Co-Founder, Pondhouse Data
Published Updated 7 min read
How to use AI to create a PowerPoint presentation?
On this page

You can use AI to create a complete PowerPoint presentation by asking a large language model like GPT-4 to write Python code for the python-pptx library and then running that code. In this post we build a small Python script that does exactly that: it retrieves facts from your company's documents with Retrieval Augmented Generation (RAG), lets GPT-4 structure them into slides, and has GPT-4 generate the code that builds the .pptx file. With a small change to the prompt, GPT-4 even uses your company's PowerPoint template, so the slides follow your corporate design. (The code uses OpenAI's gpt-4o model.)

Most people already use ChatGPT to brainstorm presentation ideas or flesh out speaker notes. A great presentation still takes careful planning and an understanding of your audience. But GPT-4's ability to write code means it can take over the time-consuming, less important part: producing the full presentation, not just the text snippets.

Update (November 2026): OpenAI has deprecated the GPT-4o snapshots behind the gpt-4o model name used below and will remove them from the API on January 14, 2027, with gpt-6-luna as the recommended replacement (see OpenAI's deprecations page). After that date, change the model name in OpenAI(model="gpt-4o", ...); the rest of the code stays the same.

How to use GPT-4 to create a PowerPoint presentation

What we are going to build

To test how well GPT-4 creates PowerPoint presentations, including ones that follow corporate design guidelines, we build a small Python script that generates a PowerPoint presentation from given prompts.

Experienced AI practitioners will rightfully ask: "How do you make sure the presentation is about the right topic?" It's a valid question. GPT-4 doesn't know the specifics of your company or topic and might hallucinate content.

To reduce this risk, and to give GPT-4 the information it needs, we connect the PowerPoint generator to a small Retrieval Augmented Generation pipeline. RAG lets us connect GPT-4 to our company's data safely and reliably.

Outline for using GPT-4 to create PowerPoint presentations

The system we are going to implement works in the following steps:

  1. We create a small Python script that connects to the OpenAI API and gets answers from GPT-4 for a given prompt.

  2. We create a small Retrieval Augmented Generation pipeline that retrieves relevant information from our company's data sources.

  3. We create a prompt that asks GPT-4 to generate a PowerPoint presentation based on provided information. We ask GPT-4 to use a package called python-pptx to create the PowerPoint presentation.

    python-pptx is a Python package for creating PowerPoint presentations programmatically. You can use it to create presentations from scratch or to modify existing ones.

  4. We connect the 3 previous components as follows:

    a. We use the user prompt (what the presentation should be about) to query the Retrieval Augmented Generation pipeline.

    b. We send the output of the RAG pipeline to GPT-4, with a prompt asking for a Python script that uses python-pptx to create a PowerPoint presentation.

    c. We execute the generated Python script, which creates the PowerPoint presentation.

  5. As an add-on, we test whether GPT-4 can use an existing PowerPoint template for the presentation and stick to corporate design guidelines.

Retrieval Augmented Generation enhanced PowerPoint creation with AI

Preparation

Because we rely on GPT-4's programming capabilities, you need a working Python 3.11 environment. We recommend a virtual environment to keep your dependencies clean.

Other than that, you need:

  • A PowerPoint 2007 or newer installation (to open the result)
  • A PowerPoint template file
  • An OpenAI API key

Install the required Python packages:

1
2pip install python-pptx llama_index

Implementing the PowerPoint generator

Creating the presentation itself is the most critical part, so we start there.

To avoid overwhelming the AI with too many tasks at once, we split the job into two parts:

  • Structuring the information into presentation material
  • Using that material to create the presentation
  1. Import the required packages:
1from llama_index.core import PromptTemplate
2from llama_index.llms.openai import OpenAI
3from llama_index.embeddings.openai import OpenAIEmbedding
4from llama_index.core import Settings
5from llama_index.core import SimpleDirectoryReader
6from llama_index.core import VectorStoreIndex
7import json
8import os
9import re
  1. Create a prompt template that asks GPT-4 to structure the provided information into presentation material:

    1prompt = """
    2You are a power point presentation specialist. You are asked to create
    3the content for a presentation about {topic}.
    4You have been given the following information to create a presentation:
    5---
    6{information}.
    7---
    8Structure the information in a way that it can be put in a power point
    9presentation. Each slide should have a title and content, with the content
    10being a summary of the information provided. Each slide should have one or
    11more sentences that capture the key points of the information.
    12Return the structured information as a JSON as follows.
    13Your answer should only contain the JSON - no markdown formatting.
    14"""
    15prompt_template = PromptTemplate(prompt)
    16prompt_examples = """
    17 Example:
    18 {"slides": [
    19 {"title": "Slide 1", "content": "Content for slide 1"},
    20 {"title": "Slide 2", "content": "Content for slide 2"},
    21 {"title": "Slide 3", "content": "Content for slide 3"},
    22 ]}
    23"""

    NOTE: There are several ways to ask GPT-4 for JSON output, for example function calling or llama_index's structured prediction functionality. At the time of writing, function calling with GPT-4 was not working reliably, so we opted for the few-shot prompt above.

  2. Create a test topic and some test information to try the prompt. We replace this later with the output of the retrieval augmented generation pipeline.

    1test_topic = "the benefits of exercise"
    2test_information = """
    3Exercise plays a crucial role in maintaining both physical and mental health.
    4Engaging in regular physical activity can significantly reduce the risk of
    5chronic diseases such as heart disease, diabetes, and obesity. It also enhances
    6muscular strength, flexibility, and endurance. Beyond physical benefits, exercise
    7contributes to improved mental health by reducing symptoms of depression and anxiety,
    8boosting mood through the release of endorphins, and improving cognitive function.
    9It fosters a sense of well-being and can be a great way to manage stress.
    10Overall, incorporating exercise into one's daily routine is a key factor in
    11achieving a healthier and more balanced lifestyle.
    12"""
    13
    14content_prompt = (
    15 prompt_template.format(topic=test_topic, information=test_information)
    16 + prompt_examples
    17)
  3. Create the LLM inference code:

    1api_key = os.getenv("OPENAI_API_KEY")
    2llm = OpenAI(model="gpt-4o", api_key=api_key)
    3slides = json.loads(llm.complete(content_prompt, True).text)

    The output of this call should be JSON-formatted text containing a list of slides with titles and content, which we parse into slides.

  4. Create a second LLM inference step that turns these slides into a PowerPoint slide deck:

    1powerpoint_prompt = """
    2You are a PowerPoint presentation specialist. You'll get a list of slides, each
    3slide containing a title and content. You need to create a PowerPoint presentation
    4based on the provided slides.
    5But there is a catch: Instead of creating the presentation, provide python code
    6that generates the PowerPoint presentation based on the provided slides.
    7Use the package python-pptx to create the PowerPoint presentation.
    8The presentation should be visually appealing and professionally designed.
    9
    10If the slides content contains more than one information, make bullet points.
    11Save the presentation as 'presentation.pptx'.
    12
    13Your answer should only contain the python code, no explanatory text.
    14
    15Slides:
    16
    17"""
    18
    19presentation_code = llm.complete(powerpoint_prompt + str(slides), True).text
    20
    21match = re.findall(r"python\n(.*?)\n```", presentation_code, re.DOTALL)
    22python_code = match[0]
  5. Execute the generated python code to create the PowerPoint presentation.

    1exec(python_code)

    This creates a file called presentation.pptx in the current working directory. Open it to see the generated presentation.

    From a topic and a few facts, GPT-4 wrote the code for a complete PowerPoint presentation without any manual slide work.

At this point GPT-4 can build a presentation from a topic and information we hard-coded. Next, we replace the hard-coded information with a retrieval augmented generation (RAG) pipeline that pulls it from our documents.

Implement the retrieval augmented generation pipeline

To simulate a company's document repository, we use a plain directory and assume all company documents are stored there. Real repositories are full of PDF, Word and Excel files; our post on parsing PDF, Word and Excel documents with GPT-4o shows how to turn them into text the index can use.

LlamaIndex (the llama_index package) indexes the documents and retrieves the information relevant to the presentation topic.

As the example document we use Paul Graham's well-known essay about his life, and ask GPT-4 to create a presentation about him.

  1. Download the sample document

    1mkdir -p 'data/paul_graham/'
    2wget 'https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/paul_graham/paul_graham_essay.txt' -O 'data/paul_graham/paul_graham_essay.txt'
  2. Load all files in our directory

    1reader = SimpleDirectoryReader(
    2 input_files=["./data/paul_graham/paul_graham_essay.txt"]
    3)
    4docs = reader.load_data()
    5index = VectorStoreIndex.from_documents(docs)
  3. With the vector store in place, we can retrieve information relevant to the presentation. To do that, set up the embedding model and the vector retriever.

    NOTE: This guide assumes you know how RAG works. For a primer, see our introduction to RAG and recursive retrieval with LlamaIndex.

    1docs = reader.load_data()
    2embed_model = OpenAIEmbedding(api_key=api_key)
    3Settings.embed_model = embed_model
    4index = VectorStoreIndex.from_documents(docs)
    5
    6retriever = index.as_retriever(similarity_top_k=5)
  4. Finally, define the topic and retrieve the relevant information for it.

    1topic = "Paul Grahams life and what he worked on"
    2relevant_information = retriever.retrieve(topic)

    relevant_information now holds the passages about Paul Graham's life that match the topic.

Combining the RAG pipeline with PowerPoint creation

We can now create presentations and retrieve the information for them. Putting the two together is mostly a matter of reusing code from the previous sections.

1# Continue from previous chapter
2information = "\n---\n".join([res.text for res in relevant_information])
3
4content_prompt = (
5 prompt_template.format(topic=topic, information=information) + prompt_examples
6)
7
8slides = json.loads(llm.complete(content_prompt, True).text)
9
10
11powerpoint_prompt = """
12You are a PowerPoint presentation specialist. You'll get a list of slides, each
13slide containing a title and content. You need to create a PowerPoint presentation
14based on the provided slides.
15But there is a catch: Instead of creating the presentation, provide python code
16that generates the PowerPoint presentation based on the provided slides.
17Use the package python-pptx to create the PowerPoint presentation.
18The presentation should be visually appealing and professionally designed.
19
20If the slides content contains more than one information, make bullet points.
21
22Your answer should only contain the python code, no explanatory text.
23
24Slides:
25
26"""
27
28presentation_code = llm.complete(powerpoint_prompt + str(slides), True).text
29
30match = re.findall(r"python\n(.*?)\n```", presentation_code, re.DOTALL)
31python_code = match[0]
32
33exec(python_code)

That's a complete presentation about Paul Graham's life in about 10 seconds.

I'll admit it's not the most enticing presentation of all time, and it probably needs some refinements. But a deck with all the relevant (and factually correct!) information is a very helpful starting point.

What is annoying, and gets in the way of real productive use, is the lack of styling and corporate design. Let's fix that.

Using GPT-4 to create a PowerPoint presentation with corporate design

Now for the holy grail: a PowerPoint presentation in your corporate design. We won't convince GPT-4 to design the slides from our written input.

Instead, we use a PowerPoint template as the base presentation, and GPT-4 adds the content to this template. The result is the same: a presentation in our corporate design language.

  1. Create a PowerPoint template and save it in your current working directory as template.pptx.

  2. Slightly change the PowerPoint creation prompt as follows:

    1powerpoint_prompt = """
    2You are a PowerPoint presentation specialist. You'll get a list of slides, each
    3slide containing a title and content. You need to create a PowerPoint presentation
    4based on the provided slides.
    5But there is a catch: Instead of creating the presentation, provide python code
    6that generates the PowerPoint presentation based on the provided slides.
    7Use the package python-pptx to create the PowerPoint presentation.
    8In your code, use a file called 'template.pptx' as the template for the presentation
    9and stick to the template's design.
    10
    11If the slides content contains more than one information, make bullet points.
    12
    13Your answer should only contain the python code, no explanatory text.
    14
    15Slides:
    16
    17"""
    18
    19presentation_code = llm.complete(powerpoint_prompt + str(slides), True).text
    20
    21match = re.findall(r"python\n(.*?)\n```", presentation_code, re.DOTALL)
    22python_code = match[0]
    23
    24exec(python_code)
  3. Run the code again.

That's it. All we needed was to tell GPT-4 to use our template, and it happily obliged. I like it when life's that simple.

The output looks great: a presentation about Paul Graham in our corporate design language, created in less than 10 seconds.

Generated slide about Paul Graham's essays in the corporate template

NOTE: If you get a "Package not found" error when running the last line of the code example, template.pptx is not in the directory where you run the script. Move the template to that location.

Conclusion

GPT-4 can create PowerPoint presentations that have relevant content and follow your company's slide templates. The approach in this post has three parts: a RAG pipeline retrieves the facts from your documents, GPT-4 structures them into slides as JSON, and GPT-4 then writes python-pptx code that fills template.pptx with those slides. In our example, that produced a presentation about Paul Graham in our corporate design in less than 10 seconds.

The generated deck is a starting point, not a finished presentation. Expect to refine the slides, and check the content against your sources. But it takes the manual slide assembly off your plate, so you can spend your time on the message and the delivery.

As a next step, replace the local sample directory with your real document sources. Our guide on chatting with your Confluence using Airbyte shows how to load company wiki pages into a RAG pipeline. To let colleagues request a deck from a chat window, you can wrap the script in an n8n workflow and call it from Open WebUI, as described in our guide on integrating n8n with Open WebUI.

Further reading

Interested in building high-quality AI agent systems?

We prepared a comprehensive guide based on cutting-edge research for how to build robust, reliable AI agent systems that actually work in production. This guide covers:

  • Understanding the 14 systematic failure modes in multi-agent systems
  • Evidence-based best practices for agent design
  • Structured communication protocols and verification mechanisms
Andreas Nigg

About the author

Andreas Nigg

Co-Founder, Pondhouse Data

Andreas has spent more than eight years building data applications. At Pondhouse Data he designs and ships AI systems and integrates them into complex, real-world environments.