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:
-
We create a small Python script that connects to the OpenAI API and gets answers from GPT-4 for a given prompt.
-
We create a small Retrieval Augmented Generation pipeline that retrieves relevant information from our company's data sources.
-
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-pptxto create the PowerPoint presentation.python-pptxis a Python package for creating PowerPoint presentations programmatically. You can use it to create presentations from scratch or to modify existing ones. -
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-pptxto create a PowerPoint presentation.c. We execute the generated Python script, which creates the PowerPoint presentation.
-
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:
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
- Import the required packages:
-
Create a prompt template that asks GPT-4 to structure the provided information into presentation material:
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. -
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.
-
Create the LLM inference code:
The output of this call should be JSON-formatted text containing a list of slides with titles and content, which we parse into
slides. -
Create a second LLM inference step that turns these slides into a PowerPoint slide deck:
-
Execute the generated python code to create the PowerPoint presentation.
This creates a file called
presentation.pptxin 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.
-
Download the sample document
-
Load all files in our directory
-
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.
-
Finally, define the topic and retrieve the relevant information for it.
relevant_informationnow 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.
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.
-
Create a PowerPoint template and save it in your current working directory as
template.pptx. -
Slightly change the PowerPoint creation prompt as follows:
-
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
- How to save on LLM costs?
- Chat with your Confluence Data
- GenAI: Technological Masterpiece or Ecological Disaster?
- Optimize prompts like the slide prompt automatically with DSPy
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



