How to Use the JSON Variant of a Prompt Template for Agent Invocation in awesome-gpt-image-2
Feed a structured JSON template from docs/templates.md into the gpt-image-2-style-library skill to generate production-ready GPT-Image2 prompts without manual string concatenation.
The awesome-gpt-image-2 repository provides dual-format prompt templates designed for both human readability and machine consumption. When agents like Claude Code, Codex, or Cursor need to invoke image generation capabilities, the JSON variant of a prompt template offers a schema-driven approach that ensures consistent layout, style constraint handling, and platform-specific formatting. This guide demonstrates how to leverage the JSON templates stored in docs/templates.md through the repository's dedicated agent skill.
Understanding the JSON Template Structure
Every template category in the repository—ranging from UI screenshots to infographics and posters—includes a machine-readable JSON counterpart. These objects follow a strict schema defined in the repository's documentation.
A standard JSON template contains six primary keys:
- type – The image category (e.g., "UI Screenshot", "Infographic")
- platform – Target environment (e.g., "iOS", "Web", "Android")
- layout – Structural description of the composition
- style – Nested object defining theme, colors, and typography
- content – Data payload including headers, cards, and actionable elements
- constraints – Technical requirements like aspect ratio and fidelity settings
The canonical reference for these schemas lives in docs/templates.md, where each category (such as tpl-ui) provides both human-readable explanations and copy-pasteable JSON blocks.
Step-by-Step Agent Invocation Workflow
Agent invocation using the JSON variant follows a four-stage pipeline that bridges the gap between structured data and the final text prompt consumed by OpenAI's image models.
Selecting the Template Category
Begin by identifying the appropriate template category for your use case. The repository organizes templates by visual type in docs/templates.md. For interface mockups, reference the UI JSON template; for data visualizations, select the Infographic variant. Each category link in the documentation points to a specific JSON schema anchor (e.g., #tpl-ui) containing the base structure.
Populating JSON Fields
Once selected, populate the template fields with case-specific values. The JSON object must include valid entries for all required keys to ensure the style library can merge your input with its internal reference data.
Consider a fitness application UI mockup:
{
"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"
}
This structure aligns with the schema defined at tpl-ui in docs/templates.md, ensuring compatibility with the processing skill.
Passing JSON to the Skill
The gpt-image-2-style-library skill, documented in agents/skills/gpt-image-2-style-library/SKILL.md, serves as the processing engine. It accepts the populated JSON template and merges it with the canonical style definitions stored in data/style-library.json.
Agents can invoke this skill through two primary interfaces: a CLI wrapper or a direct Node module import. Both methods handle the transformation of your JSON object into a fully-qualified prompt string suitable for gpt-image-2-sunburst or gpt-image-2-flare models.
Executing the Final Prompt
Upon processing, the skill emits a plain-text prompt that incorporates all style tags, scene tags, and constraint specifications from the repository's internal database. This final string is ready for immediate transmission to the OpenAI Images API or compatible front-end interfaces.
Implementation Examples
The repository supports both shell-based and programmatic invocation patterns for agent automation.
CLI Method Using Child Process
For agent environments that execute shell commands, wrap the JSON template in the skill's CLI interface. The package.json at the repository root defines the gpt-image-2-style-library binary with a generate command.
const { execSync } = require('child_process');
const uiTemplate = {
"type": "UI Screenshot",
"platform": "iOS",
"product": "Fitness App",
"layout": "Card-based feed with bottom tab bar",
"style": {
"theme": "Dark Mode",
"primary_color": "Neon Green"
},
"content": {
"header": "Today's Activity",
"cards": [
{ "title": "Running", "data": "5.2 km" }
]
},
"constraints": "High fidelity, 9:16 aspect ratio"
};
const jsonArg = JSON.stringify(uiTemplate).replace(/"/g, '\\"');
const cmd = `gpt-image-2-style-library generate --json "${jsonArg}"`;
const finalPrompt = execSync(cmd, { encoding: 'utf8' });
console.log(finalPrompt);
The generate command processes the escaped JSON string through the skill's internal merger, returning a prompt that respects all specified constraints.
Programmatic Method Using Node Module
For TypeScript or JavaScript agents preferring direct imports, the skill exports a generatePrompt function. This approach eliminates shell escaping and provides type safety.
import { generatePrompt } from 'gpt-image-2-style-library';
const uiTemplate = {
"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" }
]
},
"constraints": "High fidelity, readable text, 9:16 aspect ratio"
};
(async () => {
const prompt = await generatePrompt(uiTemplate);
const response = await fetch('https://api.openai.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-image-2-sunburst',
prompt,
n: 1,
size: '1024x1024'
})
});
const result = await response.json();
console.log(result.data[0].url);
})();
The generatePrompt function sources style definitions from data/style-library.json to enrich the template with repository-standard vocabulary and formatting rules.
Key Files for JSON Template Workflows
Understanding the repository structure ensures agents reference the correct resources during invocation:
-
docs/templates.md– Contains both human-readable explanations and machine-parsable JSON templates organized by visual category (UI, Infographic, Poster). Each section provides a schema anchor liketpl-uifor direct linking. -
agents/skills/gpt-image-2-style-library/SKILL.md– Documents the agent skill interface, available CLI flags, and the transformation logic used to convert JSON templates into final prompts. -
data/style-library.json– The canonical data source mapping style tags, color palettes, and layout constraints to specific template types. The skill references this file during the merge process. -
package.json(root) – Defines thegpt-image-2-style-librarypackage metadata and thegeneratescript entry point used in CLI invocations.
Summary
-
The JSON variant of prompt templates in
docs/templates.mdprovides a structured alternative to plain-text prompts, ensuring consistent schema compliance across agent invocations. -
The
gpt-image-2-style-libraryskill processes these JSON objects by merging them withdata/style-library.jsonto produce finalized prompts forgpt-image-2-sunburstandgpt-image-2-flaremodels. -
Agents can invoke the skill via CLI (
gpt-image-2-style-library generate --json) or programmatically (import { generatePrompt }), depending on the execution environment. -
Required JSON fields include
type,platform,layout,style,content, andconstraints, matching the schemas defined in the template documentation.
Frequently Asked Questions
What is the difference between the plain-text and JSON prompt templates in awesome-gpt-image-2?
The plain-text templates provide human-readable guidelines for manual prompt engineering, while the JSON templates offer a machine-friendly schema with explicit keys for type, platform, layout, and constraints. Agents should use the JSON variant to ensure consistent parsing and integration with the gpt-image-2-style-library skill.
Which OpenAI models are compatible with prompts generated from JSON templates?
According to the skill documentation in agents/skills/gpt-image-2-style-library/SKILL.md, generated prompts are optimized for gpt-image-2-sunburst and gpt-image-2-flare models. These models interpret the constraint flags and style tokens injected during the JSON-to-text transformation process.
Can I extend the JSON schema with custom fields for specific use cases?
The base schema defined in docs/templates.md provides standard fields like style and constraints, but the generatePrompt function in the skill merges your input with data/style-library.json. Custom fields may be preserved in the output, but only standard keys trigger the style library's enrichment logic and constraint validation.
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 →