Google AI Studio structured output
Use AI Studio structured outputs to make Gemini return OPF-shaped JSON that can be copied, validated, and rendered.
Steps
- Open Google AI Studio and choose a Gemini model that supports structured outputs.
- Open Structured outputs, switch to Code Editor, and paste the schema below.
- Save the structured output schema.
- Paste the prompt template into the main prompt field, replace the brief, and run it.
- Copy the JSON response into a
*.opf.jsonfile and validate it against the OPF schema.
This is a compact AI Studio starter schema, not the full OPF schema. It stays within the object, array, string, enum, description, and required-field shape that works well for model-constrained output. Use the full schema reference when you need more OPF fields or mixed audience metadata.
Structured output schema
Paste this into AI Studio's structured output Code Editor. The copy button copies the full schema object.
{
"type": "object",
"description": "An Open Presentation Format deck. Generate one valid OPF JSON presentation document.",
"properties": {
"$schema": {
"type": "string",
"enum": [
"https://openpresentation.org/schema/opf/v1"
],
"description": "The OPF schema URL. Always use this exact value."
},
"name": {
"type": "string",
"description": "Short title for the presentation."
},
"audience": {
"type": "string",
"description": "The intended audience for the deck. Use the common single-audience OPF string form: a free-form description, audiences catalog id, HTTPS URL, or pkg: reference."
},
"tone": {
"type": "string",
"description": "The tone of the deck, such as formal, executive, technical, educational, or sales."
},
"narrative": {
"type": "object",
"description": "The narrative spine that slide beats can reference.",
"properties": {
"id": {
"type": "string",
"description": "A short kebab-case narrative identifier."
},
"name": {
"type": "string",
"description": "Human-readable narrative name."
},
"beats": {
"type": "array",
"description": "Ordered story beats used by slides.",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "A short kebab-case beat identifier."
},
"name": {
"type": "string",
"description": "Human-readable beat name."
}
},
"required": [
"id",
"name"
]
}
}
},
"required": [
"id",
"name",
"beats"
]
},
"design": {
"type": "object",
"description": "Portable design hints for an OPF renderer.",
"properties": {
"theme": {
"type": "string",
"description": "Theme identifier or descriptive theme name."
},
"colorScheme": {
"type": "string",
"description": "Color scheme identifier or descriptive color scheme name."
},
"fontScheme": {
"type": "string",
"description": "Font scheme identifier or descriptive font scheme name."
},
"dimensions": {
"type": "string",
"enum": [
"widescreen",
"standard"
],
"description": "Deck aspect ratio."
}
}
},
"slides": {
"type": "array",
"minItems": 1,
"description": "Ordered slides in the deck.",
"items": {
"type": "object",
"properties": {
"beat": {
"type": "string",
"description": "Optional narrative beat id from narrative.beats."
},
"layout": {
"type": "string",
"description": "Renderer layout hint.",
"enum": [
"title",
"title-subtitle",
"section",
"content",
"bullets",
"two-column",
"quote",
"closing"
]
},
"title": {
"type": "string",
"description": "Concise slide title."
},
"subtitle": {
"type": "string",
"description": "Optional slide subtitle."
},
"text": {
"type": "string",
"description": "Short body paragraph for the slide."
},
"items": {
"type": "array",
"description": "Bullet points or short takeaways.",
"items": {
"type": "string"
}
}
},
"required": [
"title"
]
}
}
},
"required": [
"$schema",
"name",
"slides"
]
}Audience forms
OPF accepts the common single-audience case as a string. That string can be a free-form description, an audiences catalog id such as executives, an HTTPS URL, or a pkg: reference. The existing non-empty array form remains valid for multiple audiences.
{
"singleFreeFormAudience": {
"audience": "Biology Students and Wildlife Enthusiasts"
},
"singleCatalogAudience": {
"audience": "executives"
},
"multipleAudiences": {
"audience": [
"board",
{
"id": "executives",
"attentionBudgetMinutes": 20
}
]
}
}Multiple audiences in AI Studio
The starter schema above asks AI Studio for the single-string form. If a deck must return multiple audiences with mixed string and object metadata, replace the audience property in the schema with this array-only property.
{
"type": "array",
"minItems": 1,
"description": "Multiple intended audiences. Each item is a free-form audience description, an audiences catalog id, an HTTPS URL, a pkg: reference, or an inline audience metadata object.",
"items": {
"oneOf": [
{
"type": "string",
"description": "Free-form description, audiences catalog id, HTTPS URL, or pkg: reference."
},
{
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Audience catalog id, HTTPS URL, pkg: reference, or stable custom audience id."
},
"name": {
"type": "string",
"description": "Human-readable audience name or description."
},
"attentionBudgetMinutes": {
"type": "integer",
"description": "Optional audience attention budget in minutes."
},
"technicalFluency": {
"type": "string",
"enum": [
"low",
"medium",
"high"
],
"description": "Optional technical fluency hint."
},
"decisionPower": {
"type": "string",
"description": "Optional decision-making role, such as decision-maker, advisory, or influencer."
}
},
"required": [
"id"
]
}
]
}
}Prompt
Use this prompt with the structured output schema enabled.
Create an Open Presentation Format (OPF) JSON deck for the brief below.
Follow the structured output schema exactly. Use the "$schema" value from the schema. Use "audience" as a single string unless you are using a multi-audience OPF schema. Prefer short slide titles, one main idea per slide, and either "text" or "items" on each content slide. Use "beat" values that match narrative.beats when a narrative is useful.
Brief:
[Paste the topic, audience, desired slide count, source notes, and any must-include points here]Example brief
Topic: A 10-minute board update on Q2 customer retention.
Audience: Board of Directors.
Slide count: 6.
Tone: Formal and concise.
Must include: retention trend, churn drivers, product adoption signals, renewal risks, and next-quarter actions.Validate
AI Studio constrains the shape of the response, but OPF tooling should still validate the finished file before rendering. Compare the result with the OPF schema reference, or fetch the canonical schema at https://openpresentation.org/schema/opf/v1.
Google documents structured output support in the Gemini structured outputs guide.