Duck
Tutorials6 min read

Building a Reliable AI Slide Generator from Scratch

Samet Turan— Editor··6 min read

Learn how to create an AI slide generator that turns prompts into polished decks, with real prompts, tool costs, and debugging tips.

Most solopreneurs waste hours fiddling with slide tools when a simple automation could spit out a deck in minutes. The problem isn’t the idea; it’s the brittle prompts and hidden costs that turn a neat demo into a maintenance headache. After reading this you’ll know how to wire together a language model, a slide API, and a few guardrails so you can generate reliable decks on demand.

What most guides get wrong about prompting for slides

Many tutorials tell you to just ask the model for “a slide about X” and call it a day. That approach ignores structure, leading to walls of text or random bullet piles. I’ve seen guides suggest feeding the model a whole outline and hoping it formats correctly; the result is often a slide that looks like a notes page. The missing piece is a explicit layout cue: tell the model exactly how many bullets, where the title goes, and whether you want an image placeholder.

Instead of a vague request, use a prompt that mimics a JSON‑like skeleton but stays readable for the model. For example:


Create a slide with the following structure:
Title: [short, punchy title]
Bullet 1: [one‑sentence benefit]
Bullet 2: [one‑sentence data point]
Bullet 3: [one‑sentence call to action]
Note: keep each bullet under 12 words.

When you give the model that kind of scaffold, the output lines up with what Google Slides or PowerPoint expects, and you spend less time post‑processing.

How do you handle inconsistent slide lengths when the AI rambles?

Even with a tight prompt, the model sometimes decides to add a fourth bullet or a lengthy explanation. That breaks the slide layout and forces you to trim manually. I ran into this last month while generating a pitch deck for a SaaS client; the AI kept appending a “future vision” bullet that pushed the slide beyond the visible area.

My fix is a two‑step validation loop. First, I ask the model to count its own bullets and report the number. Second, I compare that count to the expected value; if it’s off, I ask the model to regenerate with a reminder to stick to the count. In code‑like pseudocode:

  1. Send the structured prompt and capture the response.
  2. Run a simple regex to count lines that start with “Bullet”.
  3. If count != 3, send a follow‑up: “You gave me {count} bullets; please give exactly 3 bullets, each under 12 words.”
  4. Repeat until the count matches or you hit two attempts (then fall back to a template).

This loop adds maybe two seconds per slide but saves minutes of manual cleanup.

A concrete named example: building a slide deck with GPT-4 and Google Slides API

Let’s walk through a real workflow I use for client proposals. I start with a Google Sheet that holds the proposal data: client name, problem, solution, pricing. A Apps Script reads each row, builds a prompt, calls the OpenAI API (gpt-4‑turbo), gets the slide JSON, then uses the Google Slides API to create a new deck and populate slides.

Here’s the prompt I send to the model for each row (the sheet column headers are inserted via script):


Create a slide with the following structure:
Title: Solution for {client}
Bullet 1: Problem they face: {problem}
Bullet 2: Our fix: {solution}
Bullet 3: Investment: {pricing}
Note: keep each bullet under 12 words.

The model returns something like:


Title: Solution for Acme Corp
Bullet 1: Problem they face: Manual reporting takes 10 hrs/week
Bullet 2: Our fix: Automated dashboard with real‑time alerts
Bullet 3: Investment: $4,500 one‑time setup

I then parse that into a slide payload:

  • Title goes into the title placeholder.
  • Each bullet becomes a separate text box in the body placeholder.
  • I set the font size to 24 for title, 18 for bullets.

The Apps Script then calls Slides.Presentations.create, adds a slide, and inserts the text. The whole process for a 10‑slide deck runs in about 45 seconds.

Cost breakdown: OpenAI charges $0.03 per 1k tokens for gpt-4‑turbo; each prompt+completion averages ~800 tokens, so roughly $0.024 per slide. Google Slides API is free. For a typical proposal of 12 slides, the AI cost is under $0.30. Add the negligible Apps Script runtime and you’re looking at pennies per deck.

How to debug when this breaks

When the deck looks wrong, the first place to check is the raw model output. I log the exact response to Stackdriver (or just a simple console.log if you’re running locally). If the bullets are missing or the title is garbled, the prompt likely got mangled by special characters from the sheet—think commas or line breaks that confuse the model.

If the slide API throws an error, verify that the presentation ID you’re using is still valid; a common mistake is reusing an ID after you’ve deleted the deck in the Drive trash. The API will return a 404 with a cryptic message.

Sometimes the model returns extra commentary like “Here is the slide you asked for:” before the structured text. Strip that prefix with a regex that looks for the first line that starts with “Title:”. If you see the model refusing to follow the bullet limit, increase the temperature slightly (to 0.7) and add a stronger instruction: “Do not add any extra bullets or explanations.”

Finally, if the deck looks fine but the fonts are wrong, remember that the Slides API inherits the theme’s default font unless you explicitly set it. I now include a batchUpdate request that sets the font family to ‘Arial’ for all text boxes; it’s a one‑liner that prevents the occasional Helvetica surprise.

Cost breakdown and my honest opinion on pricing

I’ve seen vendors sell “AI slide generators” as SaaS products for $29/mo or even $79/mo. Those prices feel steep when the underlying AI call costs a fraction of a cent and the slide API is free. The markup covers hosting, a UI, and support, but for a solo operator who can run a script on their own machine or a cheap VPS, the recurring fee is hard to justify.

On the flip side, the free tier of many AI slide tools is a joke: they limit you to five slides a month and slap a watermark on every export. If you need to send out more than a handful of decks, you’ll hit the wall fast.

I think $5/mo is a fair price for a hosted version that handles the API keys, provides a simple form, and stores your decks. Anything above that is paying for convenience you can replicate with a 20‑line script.

— and good luck finding docs for this — the Google Slides API reference is scattered across multiple pages, but the batchUpdate method is where you’ll spend most of your time.

If you want the deep cut on this, AI meeting tools coverage.

If you’d rather skip the build and deploy a working version in an afternoon, we’ve packaged this workflow as a blueprint at deepusecase.com/vault.

— The Colophon

One AI tool. Tested. Reviewed.
In your inbox every Sunday.

~3 minute read. Real outcomes from operators, not marketers.

Free. One email per Sunday. Unsubscribe in one click.