Purrx

Plan an outline, then write the slides

Generate a whole presentation in two Gemini calls: a structured JSON outline with a schema, then the deck in SlideML, compiled into slides and a .pptx.

14 min+40 XPHands-on

You could ask for a whole deck in one call. It works, but the model then has to decide what to say, how to order it, which component fits each point, and write valid SlideML, all at once. Splitting the job into two calls makes each one simpler, and the result more consistent.

Topic

Call 1: outline

JSON schema: component, heading, points

Call 2: deck

system prompt + outline → SlideML

compileDeck

slides + problems

Planning and writing are separate calls. The outline is checked JSON, so the second call starts from a solid plan instead of inventing structure and layout at once.

Call 1: the outline

The is plain data: a title, and for each slide a component, a heading and a few points. Plain data is what structured output is for. With a responseSchema, Gemini can only reply with JSON of that shape.

  • component is an of the slide components in your library, so the plan can't ask for a slide type that doesn't exist.
  • points is an array of strings: the content, before any layout decisions.

Call 2: the deck

writeDeck (written for you) sends the outline with the system prompt you generated in lesson 7.1 and extracts the <deck>. Then compileDeck turns it into slides and problems. You wire the three steps together in generateDeck.

Under the hood — Doesn't a second call cost more?

A little: the outline is a few hundred tokens. In return, the deck call starts from a checked plan instead of inventing structure, which means fewer broken slides. Once self-repair is in, broken slides trigger repair calls, which cost far more than the outline did. The outline also gives a UI something to show within a couple of seconds.

Key takeaways

  • Split planning from writing: an outline first, then the slides.
  • The outline is JSON with a schema, so the structure is guaranteed before any layout is written.
  • An enum of component names keeps the plan inside what your library can draw.

Sign in to run the exercise

Reading is free. Writing code here needs an account so we have somewhere to keep your Gemini key and the +40 XP you are about to earn.