Understanding the JSON Template Structure in awesome-gpt-image-2: A Complete Guide

JSON templates in awesome-gpt-image-2 are structured objects within the templates array of data/style-library.json, each containing metadata fields like id, anchor, bilingual titles, and structured guidance arrays that drive prompt generation for GPT-Image-2.

The awesome-gpt-image-2 repository serves as a comprehensive style library for GPT-Image-2 prompt engineering. Its JSON template structure standardizes how visual styles, UI patterns, and scene definitions are stored and retrieved by both human users and automated agents.

Core JSON Template Schema

Each template object resides in the top-level "templates" array inside [data/style-library.json](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/data/style-library.json). The schema consists of thirteen distinct properties that define everything from gallery display to prompt generation logic.

Required Fields

The following fields are mandatory for every template:

  • id – A unique string identifier used programmatically (e.g., "ui-screenshot-system").
  • anchor – A markdown-page anchor enabling direct linking (e.g., "tpl-ui", "tpl-poster").
  • title – An object containing bilingual keys en and zh for English and Chinese display names.
  • category – A string matching an entry in the categories array (e.g., "UI & Interfaces").
  • styles or scenes – At least one of these arrays must be present to classify the template.

Optional Metadata Fields

Templates can include additional descriptive properties:

  • cover – A string path to a thumbnail image displayed in the gallery (e.g., "/images/case17.jpg").
  • description – A bilingual object ({en, zh}) explaining the visual style or use-case.
  • tags – An array of free-form strings for search indexing (e.g., ["UI", "Dashboard", "Screenshot"]).

Prompt Engineering Fields

The structure includes specialized arrays that guide AI image generation:

  • useWhen – Bilingual guidance on appropriate application contexts.
  • guidance – Step-by-step prompt instructions stored as bilingual arrays of strings.
  • pitfalls – Common mistakes to avoid, formatted as bilingual string arrays.
  • exampleCases – An array of numeric IDs referencing case studies in the gallery (e.g., [17, 2, 4]).

Bilingual Support and Localization

A distinctive feature of this JSON template structure is its built-in internationalization. Any field that displays human-readable text supports dual-language objects:

{
  "title": {
    "en": "UI Screenshot System",
    "zh": "UI 截图系统"
  },
  "guidance": {
    "en": [
      "Lock platform, aspect ratio, layout hierarchy, and exact visible text.",
      "Specify UI chrome such as status bars, tabs, action rows, or comment layers."
    ],
    "zh": [
      "锁定平台、比例、层级和画面文字。",
      "明确状态栏、Tab、操作区、评论层等 UI 元素。"
    ]
  }
}

This design allows the UI to switch languages automatically without requiring separate template files.

Working with Templates Programmatically

You can consume these templates in any language that parses JSON. The following examples demonstrate how to extract specific templates for use in custom applications.

JavaScript/Node.js Implementation

import fs from 'fs';

// Load the style library
const lib = JSON.parse(fs.readFileSync('data/style-library.json', 'utf8'));

// Find the UI screenshot template by anchor
const uiTemplate = lib.templates.find(t => t.anchor === 'tpl-ui');

console.log(uiTemplate.title.en);
// → UI Screenshot System

console.log(uiTemplate.guidance.en.join('\n'));
// → Lock platform, aspect ratio, layout hierarchy, and exact visible text.
// → Specify UI chrome such as status bars, tabs, action rows, or comment layers.

Python Implementation

import json

with open('data/style-library.json') as f:
    lib = json.load(f)

# Retrieve a poster template by its ID

poster = next(t for t in lib['templates'] if t['anchor'] == 'tpl-poster')

print(poster['title']['zh'])

# → 海报排版系统

print(', '.join(poster['tags']))

# → Poster, Typography, Campaign

Key Files That Define the Template System

The JSON template architecture spans four critical files in the repository:

File Role
[data/style-library.json](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/data/style-library.json) Central store containing categories, styles, scenes, and the complete template schema.
[docs/templates.md](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/docs/templates.md) Human-readable documentation that mirrors the JSON structure using anchors like #tpl-ui.
[agents/skills/gpt-image-2-style-library/references/style-library.md](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/agents/skills/gpt-image-2-style-library/references/style-library.md) Reference guide consumed by auto-generated style skill scripts.
scripts/generate-style-skill.mjs Build script that reads data/style-library.json, extracts template objects, and produces the skill package for GPT-Image-2 agents.

Summary

  • JSON templates are stored in the templates array of data/style-library.json.
  • Required fields include id, anchor, title, category, and at least one of styles or scenes.
  • The schema supports bilingual content through en and zh sub-objects in text fields.
  • Specialized arrays like guidance and pitfalls provide structured prompting instructions.
  • Four interconnected files manage the template lifecycle from storage to agent consumption.

Frequently Asked Questions

What are the required fields for a JSON template in awesome-gpt-image-2?

Every template must include an id (unique identifier), anchor (URL hash link), title (bilingual object), category (classification string), and at least one of the arrays styles or scenes. All other fields, including cover, tags, and exampleCases, remain optional.

How does the bilingual support work in the template structure?

Fields containing human-readable text use objects with en and zh keys instead of plain strings. This applies to title, description, useWhen, guidance, and pitfalls, enabling automatic language switching in the UI without duplicating template entries.

Where are the JSON templates stored and how are they accessed?

Templates reside in [data/style-library.json](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/data/style-library.json) inside a top-level "templates" array. Build scripts like scripts/generate-style-skill.mjs parse this file, while documentation in docs/templates.md provides human-readable anchors that correspond to each template's anchor property.

What is the difference between styles, scenes, and tags in the template schema?

styles classify the visual language (e.g., ["UI"]), scenes describe the intended usage context (e.g., ["Tech", "Social"]), and tags serve as free-form search keywords (e.g., ["Dashboard", "Screenshot"]). While styles and scenes categorize templates structurally, tags optimize discoverability through text search.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →