Common Prompt Blocks in GPT-Image2 Templates: A Complete Guide to Structured Image Generation
GPT-Image2 templates utilize five modular prompt blocks—Basic Text, JSON-Formatted, Specialized Layout, Domain-Specific, and Pitfall Guard—to standardize visual generation tasks and reduce model hallucinations through explicit constraints.
The freestylefly/awesome-gpt-image-2 repository provides a comprehensive templating system for generating high-fidelity images using structured prompts. Understanding the common prompt blocks in GPT-Image2 templates allows developers and designers to create consistent, machine-readable instructions that produce predictable visual outputs across UI screenshots, infographics, and other visual domains.
The Five Core Prompt Block Types
The repository's docs/templates.md file defines a modular architecture where each prompt follows a consistent three-part pattern. These blocks are designed to be interchangeable, allowing users to switch between human-readable descriptions and structured API calls.
Basic Text Prompts (常规模板)
The Basic Text Prompt block provides a quick, human-readable description ideal for copy-paste workflows. According to the source code in docs/templates.md (lines 14-22), this block follows a standardized template structure:
为[产品类型]生成一张[平台]界面图。核心功能:[功能]。视觉风格:[风格],主色[颜色]。输出:高保真 UI 截图,比例[9:16/16:9]。
This format uses bracketed placeholders ([产品类型], [平台], [功能]) that users replace with specific values. The block explicitly declares the output format, aspect ratio, and visual constraints within a single natural-language sentence.
JSON-Formatted Prompts (JSON 进阶模板)
For programmatic invocation, the JSON-Formatted Prompt block offers a machine-readable structure. As implemented in docs/templates.md (lines 24-46), this block organizes parameters into nested objects:
{
"type": "UI Screenshot",
"platform": "iOS",
"product": "Fitness App",
"layout": "Card-based feed with bottom tab bar",
"style": {
"theme": "Dark Mode",
"primary_color": "Neon Green"
},
"constraints": "High fidelity, readable text, 9:16 aspect ratio"
}
This format is specifically designed for integration with the /api/generate-image.js endpoint, allowing agents to construct prompts dynamically without string concatenation.
Specialized Layout Prompts (截图生成模板)
The Specialized Layout Prompt block targets UI generation with granular control over components. Defined in docs/templates.md (lines 48-66), this block specifies platform-specific constraints, visual element lists, and content hierarchies:
生成一张[平台]内容截图,[深色/浅色]模式。核心内容:账号信息、正文内容、互动数据。界面元素:顶部、底部、附加。约束:文字必须准确显示指定的中文,比例固定。
This structure enforces explicit constraints such as "文字必须准确显示指定的中文" (text must accurately display specified Chinese characters) to prevent common generation errors like garbled text or incorrect aspect ratios.
Domain-Specific Prompts
GPT-Image2 organizes templates by visual domains, including infographic, poster, product, brand, architecture, photography, illustration, character, scene, history, document, and other categories. Each domain includes three standardized components:
- 常规模板 (Standard Template): The basic text format for the domain
- JSON 进阶模板 (Advanced JSON Template): The structured format for API calls
- 避坑指南 (Pitfall Guide): Domain-specific constraints
For example, the Infographic domain's standard template (docs/templates.md, lines 99-105) structures information hierarchy explicitly:
生成[主题]信息图,目标读者为[人群]。结构:标题区 + [3-5]个模块...
Pitfall Guard Blocks (避坑指南)
The Pitfall Guard block serves as a constraint checklist to reduce hallucinations. Located in docs/templates.md (lines 86-92), this block forces prompts to include disambiguating constraints such as:
- "文字必须可读" (Text must be legible)
- "不要混合平台特征" (Do not mix platform characteristics)
- "比例必须锁定" (Aspect ratio must be locked)
These constraints address common failure modes in text-to-image generation, particularly regarding typography accuracy and visual consistency.
How to Use Prompt Blocks in Your Workflow
When constructing a new generation task, the repository recommends a four-step workflow:
- Select the domain (UI, infographic, poster, etc.) based on your visual output requirements
- Populate the 常规模板 by replacing placeholder tokens (
[xxx]) with specific values - Convert to JSON 进阶模板 when making programmatic calls via the API
- Append 避坑指南 items to enforce clarity and prevent common errors
This modular approach allows designers to start with natural language descriptions and transition to structured API calls without rewriting the underlying content.
Implementation in the GPT-Image2 API
The api/generate-image.js handler processes these prompt blocks by forwarding structured JSON to the image model. Here is a complete implementation example using the JSON-Formatted Prompt block:
const prompt = {
type: "UI Screenshot",
platform: "iOS",
product: "Fitness App",
layout: "Card-based feed with bottom tab bar",
style: {
theme: "Dark Mode",
primary_color: "Neon Green",
typography: "Clean sans-serif"
},
content: {
header: "Today's Activity",
cards: [
{title: "Running", data: "5.2 km", button: "Start"},
{title: "Calories", data: "340 kcal"}
]
},
constraints: "High fidelity, readable text, 9:16 aspect ratio"
};
fetch("/api/generate-image", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({prompt})
});
For direct template usage without API integration, copy the plain-text format from docs/templates.md:
为移动应用生成一张iOS界面图。核心功能:运动记录、卡路里统计、社交分享。视觉风格:极简、暗色主题,主色 Neon Green。布局:卡片流,信息层级清晰,留白充足。输出:高保真 UI 截图,比例 9:16。
Domain-specific examples, such as infographic generation, follow the same structural principles with vocabulary tailored to the visual genre:
生成"老年人日常健康管理指南"信息图,目标读者为 65-80 岁的退休人群。结构:标题区 + 4个模块(图标、短标题、说明)。图表类型:流程图。风格:专业报告,主色蓝色,背景浅色。输出:信息层级清晰、可读性高的中文信息图。
Summary
- Five modular blocks structure all GPT-Image2 templates: Basic Text, JSON-Formatted, Specialized Layout, Domain-Specific, and Pitfall Guard
- Source definitions reside in
docs/templates.md, with line-specific implementations for each template type (lines 14-22 for basic UI, lines 24-46 for JSON, lines 86-92 for pitfall guards) - Workflow flexibility allows switching between human-readable text (
常规模板) and machine-readable JSON (JSON 进阶模板) without content loss - Constraint enforcement through
避坑指南blocks explicitly prevents hallucinations like illegible text or incorrect aspect ratios - API integration is handled by
/api/generate-image.js, which accepts the JSON-Formatted Prompt block directly - Agent compatibility is documented in
agents/skills/gpt-image-2-style-library/SKILL.mdfor AI system integration
Frequently Asked Questions
What is the difference between 常规模板 and JSON 进阶模板?
The 常规模板 (Standard Template) provides a human-readable text format with bracketed placeholders ideal for manual editing and copy-paste workflows. The JSON 进阶模板 (Advanced JSON Template) offers the same semantic content as a structured object with typed fields, making it suitable for programmatic API calls in api/generate-image.js. Both templates describe identical visual requirements but serve different technical contexts—natural language editing versus machine parsing.
Where are the prompt block definitions located in the repository?
All prompt block definitions are centralized in docs/templates.md according to the repository structure. This file contains the complete specifications for UI screenshots (lines 14-66), domain-specific templates including infographics (lines 99-105), and Pitfall Guard checklists (lines 86-92). Additional implementation details appear in agents/skills/gpt-image-2-style-library/SKILL.md for agent-based usage.
How do Pitfall Guard blocks prevent generation errors?
Pitfall Guard (避坑指南) blocks function as explicit constraint checklists that force the model to avoid common failure modes. By requiring statements like "文字必须准确显示指定的中文" (text must accurately display specified Chinese characters) or "比例必须锁定" (aspect ratio must be locked), these blocks act as guardrails against hallucinations. They transform implicit assumptions into explicit instructions, significantly improving text legibility and visual consistency in generated outputs.
Can I combine multiple prompt blocks for complex generation tasks?
Yes, the modular architecture explicitly supports combining blocks. A typical complex workflow uses the Domain-Specific block to establish the visual genre, the Specialized Layout block to define component hierarchies, and the Pitfall Guard block to enforce technical constraints. For API implementations, these combine into a single JSON object that merges layout specifications with constraint arrays in the constraints field.
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 →