Templates for Scenes and Storytelling in GPT-Image2: A Complete Guide to Narrative Image Generation
GPT-Image2 provides a dedicated tpl-scene template that structures narrative prompts through both a plain-text format for manual entry and a JSON schema for programmatic agent workflows, enabling precise control over story context, environment, action, and cinematography.
The freestylefly/awesome-gpt-image-2 repository offers specialized templates for scenes and storytelling in GPT-Image2 that transform simple descriptions into cinematic visual narratives. These templates standardize how you communicate story elements—such as conflict, atmosphere, and camera angles—to the image generation model, ensuring consistent narrative outputs whether you are writing prompts by hand or building automated agent systems.
Architecture of the Scene Template System
According to the source code in docs/templates.md, the storytelling functionality centers on the tpl-scene anchor identifier. This template is registered in data/style-library.json under the Scenes & Storytelling category, linking human-readable definitions to programmatic implementations in agents/skills/gpt-image-2-style-library/**.
The system provides two delivery mechanisms:
- Plain-text version: Optimized for direct copy-paste workflows into API calls
- JSON version: Designed for structured programmatic consumption by automated agents
Plain-Text Template for Manual Storytelling
Template Structure and Syntax
The plain-text variant in docs/templates.md uses a bracketed fill-in-the-blank format that covers seven narrative dimensions:
- Story theme and temporal/spatial setting
- Primary event and protagonist description
- Central conflict or tension point
- Cinematographic lens language (e.g., Wide establishing shot, Medium narrative, Close-up)
- Emotional atmosphere (Tense/Warm/Suspenseful)
- Color temperature (Cold/Warm/High contrast)
The template syntax follows this exact pattern:
生成[故事主题]场景图,发生在[时间+地点]。
主事件:[事件描述],主角:[角色],冲突点:[冲突]。
镜头语言:[广角建立镜头/中景叙事/特写]。
氛围:[紧张/温暖/悬疑],色调:[冷/暖/高反差]。
输出:具备叙事张力的场景概念图。
Practical Implementation Example
To generate an alchemical laboratory scene, populate the brackets as follows:
生成“古代炼金师的实验室”场景图,发生在“黄昏的石窟”。
主事件:“炼金师正在点燃符文”,主角:“身披长袍的老人”,冲突点:“突现的暗影螺旋”。
镜头语言:“广角建立镜头”。
氛围:“悬疑”,色调:“冷”。
输出:具备叙事张力的场景概念图。
JSON Template for Agent-Driven Workflows
Schema Structure
For programmatic integration, the tpl-scene JSON template provides machine-parseable fields that mirror the narrative structure of the plain-text version. As defined in docs/templates.md, the schema accepts the following top-level keys:
{
"type": "Narrative Scene",
"story_context": "The exact moment an ancient seal breaks",
"environment": "Crumbling stone temple overgrown with glowing blue vines",
"action": "A young explorer dropping their torch as a massive beam of light shoots into the sky",
"atmosphere": {
"mood": "Awe‑inspiring, terrifying",
"lighting": "Blinding central light casting long dramatic shadows"
},
"camera": "Low angle shot, emphasizing the scale of the light beam"
}
Field Definitions and Data Types
When constructing payloads for api/generate-image.js, ensure your JSON includes these specific fields:
story_context: String describing the narrative moment to captureenvironment: String detailing physical setting, architecture, and ambient conditionsaction: String specifying the main event occurring in the sceneatmosphere: Object containingmood(string) andlighting(string) sub-fieldscamera: String indicating shot composition (e.g., "Dutch angle", "Over-the-shoulder")
Code Implementation Examples
Direct API Integration with Plain Text
For immediate generation without agent mediation, send the populated Chinese template as a string payload:
// Example request to the /api/generate-image endpoint
fetch('/api/generate-image', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
prompt: `生成“星际航母指挥中心”场景图,发生在“夜晚的太空站”。主事件:“舰长下达紧急撤离指令”,主角:“戴头盔的指挥官”,冲突点:“外部陨石雨”。镜头语言:“特写”。氛围:“紧张”,色调:“高反差”。输出:具备叙事张力的场景概念图。`
})
});
Python Agent Implementation Using JSON
Automated agents in agents/skills/gpt-image-2-style-library/** should construct structured payloads:
import requests, json
payload = {
"type": "Narrative Scene",
"story_context": "Starship bridge during a solar flare emergency",
"environment": "Futuristic bridge with holographic consoles, orange glare from a nearby star",
"action": "Captain shouting orders while crew scrambles to stabilize the reactors",
"atmosphere": {
"mood": "Urgent, chaotic",
"lighting": "Harsh orange flare backlighting the crew"
},
"camera": "Wide shot from behind the captain, low angle"
}
resp = requests.post(
"https://api.yourdomain.com/api/generate-image",
headers={"Content-Type": "application/json"},
data=json.dumps(payload)
)
print(resp.json())
Summary
- The
tpl-scenetemplate indocs/templates.mdprovides standardized templates for scenes and storytelling in GPT-Image2, available in both plain-text and JSON formats. - Use the plain-text version for rapid manual prompt engineering in Chinese, filling bracketed fields for theme, event, conflict, and cinematography.
- Use the JSON version for agent-based workflows, supplying structured data for
story_context,environment,action,atmosphere, andcamerafields. - Repository files
data/style-library.jsonandagents/skills/gpt-image-2-style-library/**handle template registration and programmatic parsing respectively. - Both methods interface with the backend through endpoints like
api/generate-image.jsto produce narrative-driven visual outputs.
Frequently Asked Questions
What is the difference between the plain-text and JSON templates for scenes and storytelling?
The plain-text template provides a human-readable, bracketed format optimized for direct copy-paste into API calls, while the JSON template offers a structured schema with typed fields (story_context, atmosphere, etc.) designed for programmatic generation by automated agents.
Where are the scene templates defined in the repository?
The canonical definitions reside in docs/templates.md under the tpl-scene anchor. The template registry in data/style-library.json links these definitions to the Scenes & Storytelling category, and the parsing logic is implemented in agents/skills/gpt-image-2-style-library/**.
How do agents access the storytelling templates programmatically?
Agents leverage the JSON schema by constructing HTTP POST requests to the image generation endpoint (e.g., api/generate-image.js) with payloads containing the type: "Narrative Scene" field and appropriately filled narrative parameters.
Can I customize the camera angles and atmosphere descriptions?
Yes. The camera field accepts any cinematographic descriptor (e.g., "Dutch angle", "Over-the-shoulder"), and the atmosphere object supports arbitrary strings for mood and lighting, allowing full customization of the visual narrative style.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →