# How to Migrate Prose Prompts to GPT-Image2 JSON Templates: A Complete Guide

> Easily migrate prose prompts to GPT-Image2 JSON templates. Learn how to convert free-form descriptions into structured, reproducible templates for GPT-Image2.

- Repository: [苍何/awesome-gpt-image-2](https://github.com/freestylefly/awesome-gpt-image-2)
- Tags: migration-guide
- Published: 2026-08-31

---

**Convert your free-form prompt descriptions into structured JSON templates that GPT-Image2 can parse, store, and render reproducibly.**

GPT-Image2 expects prompts in a standardized JSON format rather than raw prose strings. Migrating your existing text-based prompts unlocks template reusability, parameter precision through explicit fields like `cfgScale` and `seed`, and seamless integration with the repository's generation pipeline. This guide walks through the exact transformation process using the repository's actual tooling.

---

## 1. Understand the Target JSON Schema

Before migration, you must know the schema that GPT-Image2 consumes. The canonical structure is defined in [`docs/templates.md`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/docs/templates.md) and implemented in [`data/style-library.json`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/data/style-library.json):

```json
{
  "name": "tpl-cyberpunk-portrait",
  "title": "Cyberpunk Portrait",
  "description": "Futuristic character with neon accents",
  "prompt": "A close-up portrait of a cybernetically enhanced woman, glowing cyan neural implants, rain-slicked streets reflected in her irises, volumetric fog, 8k detail",
  "style": "photorealistic",
  "cfgScale": 7.5,
  "steps": 60,
  "seed": 42,
  "type": "image"
}

```

| Field | Type | Purpose |
|-------|------|---------|
| `name` | string | Unique identifier used in API calls and UI references |
| `title` | string | Human-readable display label |
| `description` | string | Tooltip or documentation string |
| `prompt` | string | The core natural-language description passed to the diffusion model |
| `style` | string | Preset selector (e.g., `photorealistic`, `illustration`, `low-poly`) |
| `cfgScale` | number | Classifier-free guidance scale (typically 6–12) |
| `steps` | integer | Inference steps count (20–150) |
| `seed` | integer \|\| null | Reproducibility seed; `null` yields random generation |
| `type` | string | Content category (always `"image"` in current implementation) |

The [`api/generate-image.js`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/api/generate-image.js) endpoint validates these fields before forwarding them to the Stable Diffusion backend. Invalid or missing `cfgScale` or `steps` values default to repository-defined constants.

---

## 2. Parse Your Prose Prompt into Semantic Components

A typical prose prompt embeds multiple instructions that must be teased apart:

> *"Make a fantasy book cover showing a dragon rising from molten gold, dramatic rim lighting, oil painting style, high detail, seed 777 for consistency."*

Extract the structured data:

| Source Fragment | JSON Field | Value |
|-----------------|------------|-------|
| "fantasy book cover…" | `prompt` | Core description minus style/syntax markers |
| "oil painting style" | `style` | `illustration` (mapped from natural description) |
| "seed 777" | `seed` | `777` |
| (implicit) | `cfgScale` | `7` (default) |
| "high detail" | `steps` | `60` (inferred from quality descriptor) |

The repository provides no automated prose parser, but you can implement extraction logic in **`scripts/generate-style-skill.mjs`** style:

```javascript
// scripts/parse-prose.mjs
import fs from 'fs';

const PROSE = `Make a fantasy book cover showing a dragon rising from molten gold, 
dramatic rim lighting, oil painting style, high detail, seed 777 for consistency.`;

function extractTemplate(prose, id) {
  // Pattern matching for explicit parameters
  const seedMatch = prose.match(/seed\s*[:=]?\s*(\d+)/i);
  const styleMap = {
    'oil painting': 'illustration',
    'photorealistic': 'photorealistic',
    'anime': 'anime',
    '3d render': '3d-render'
  };
  
  // Detect style keyword
  const detectedStyle = Object.keys(styleMap)
    .find(k => prose.toLowerCase().includes(k)) || 'photorealistic';
  
  // Strip metadata markers from prompt body
  const cleanPrompt = prose
    .replace(/seed\s*[:=]?\s*\d+/gi, '')
    .replace(/,? (oil painting|photorealistic|anime|3d render) style/gi, '')
    .replace(/high detail/gi, '')
    .trim();
  
  return {
    name: `tpl-parsed-${id}`,
    title: `Parsed Template ${id}`,
    description: 'Auto-extracted from prose',
    prompt: cleanPrompt,
    style: styleMap[detectedStyle],
    cfgScale: 7,
    steps: prose.match(/high detail|8k|intricate/i) ? 60 : 30,
    seed: seedMatch ? parseInt(seedMatch[1], 10) : null,
    type: 'image'
  };
}

const template = extractTemplate(PROSE, Date.now());
console.log(JSON.stringify(template, null, 2));

```

Run this to preview your extracted structure before committing.

---

## 3. Persist Templates to the Style Library

The runtime source of truth is **[`data/style-library.json`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/data/style-library.json)**. Append your migrated template:

```bash

# Using Node for safe JSON manipulation

node -e "
const fs = require('fs');
const lib = JSON.parse(fs.readFileSync('data/style-library.json', 'utf8'));
const newTpl = $(cat /tmp/extracted-template.json);
lib.templates = lib.templates || [];
lib.templates.push(newTpl);
fs.writeFileSync('data/style-library.json', JSON.stringify(lib, null, 2));
"

```

The `lib.templates` array is what [`src/main.jsx`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/src/main.jsx) enumerates when rendering the template gallery. Each entry becomes a selectable card in the UI.

---

## 4. Regenerate Style Skill Assets

After updating [`data/style-library.json`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/data/style-library.json), rebuild the derived assets so the UI and documentation stay synchronized:

```bash
node scripts/generate-style-skill.mjs

```

This script performs three critical operations:

1. **Validates** every template name against anchors in [`docs/templates.md`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/docs/templates.md) (line 53)
2. **Generates** thumbnail metadata and preview configurations
3. **Updates** cached skill definitions consumed by the frontend state management

The anchor-check ensures that each `name` field has corresponding documentation. If you see validation errors, add a section to [`docs/templates.md`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/docs/templates.md):

```markdown

### tpl-parsed-1693502400000

**Category**: Fantasy & Book Covers  
**Prompt**: A dragon rising from molten gold, dramatic rim lighting...  
**Style**: illustration  
**CFG Scale**: 7  
**Steps**: 60  
**Seed**: 777 (fixed)  
**Migration Source**: Original prose prompt, 2023-08-31

```

---

## 5. Verify End-to-End Integration

Test the migrated template through the API:

```bash
curl -X POST http://localhost:3000/api/generate-image \
  -H "Content-Type: application/json" \
  -d '{
    "templateId": "tpl-parsed-1693502400000",
    "variations": 1
  }'

```

The [`api/generate-image.js`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/api/generate-image.js) handler (around lines where `p_prompt` is destructured) resolves the `templateId` to the full JSON object from [`data/style-library.json`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/data/style-library.json), then forwards `prompt`, `cfgScale`, `steps`, and `seed` to the diffusion pipeline.

For UI verification, start the development server:

```bash
npm run dev

```

Navigate to the template gallery; your migrated entry appears with its `title` and `description` rendered from the JSON fields.

---

## 6. Batch Migration Workflow

For dozens or hundreds of prose prompts, orchestrate the pipeline:

```javascript
// scripts/batch-migrate.mjs
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const PROSE_DIR = path.join(__dirname, '../prose-inputs');
const LIB_PATH = path.join(__dirname, '../data/style-library.json');

const library = JSON.parse(fs.readFileSync(LIB_PATH, 'utf8'));
library.templates = library.templates || [];

const proseFiles = fs.readdirSync(PROSE_DIR).filter(f => f.endsWith('.txt'));

proseFiles.forEach((file, idx) => {
  const prose = fs.readFileSync(path.join(PROSE_DIR, file), 'utf8');
  const id = `${Date.now()}-${idx}`;
  
  // Reuse extraction logic from Step 2
  const template = extractTemplate(prose, id);
  library.templates.push(template);
  
  console.log(`✅ Migrated: ${file} → ${template.name}`);
});

fs.writeFileSync(LIB_PATH, JSON.stringify(library, null, 2));
console.log(`\n🔄 Run: node scripts/generate-style-skill.mjs`);

```

Execute:

```bash
mkdir prose-inputs

# Copy your .txt prompt files into prose-inputs/

node scripts/batch-migrate.mjs
node scripts/generate-style-skill.mjs

```

---

## Summary

- **Extract** semantic fields (prompt text, style, seed, quality hints) from prose using pattern matching
- **Structure** the extracted data into the JSON schema defined in [`docs/templates.md`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/docs/templates.md)
- **Persist** templates to [`data/style-library.json`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/data/style-library.json) for runtime consumption
- **Validate** by running `scripts/generate-style-skill.mjs` to ensure documentation parity
- **Test** via [`api/generate-image.js`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/api/generate-image.js) endpoints or the [`src/main.jsx`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/src/main.jsx) frontend
- **Document** new templates in [`docs/templates.md`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/docs/templates.md) for discoverability

---

## Frequently Asked Questions

### What happens if I omit the `seed` field in my JSON template?

The [`api/generate-image.js`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/api/generate-image.js) handler treats `null` or missing `seed` as a signal to generate a random seed per request. For reproducible outputs, always provide an explicit integer.

### Can I nest templates or reference one template from another?

The current schema in [`data/style-library.json`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/data/style-library.json) does not support composition or inheritance. Each template must be self-contained. For variant generation, duplicate the base template and modify specific fields.

### How does `scripts/generate-style-skill.mjs` know if my template is documented?

The script performs an anchor check at line 53: it scans [`docs/templates.md`](https://github.com/freestylefly/awesome-gpt-image-2/blob/main/docs/templates.md) for `### {template.name}` headers. If missing, the build warns and skips asset generation for that template until documentation is added.

### What `cfgScale` and `steps` values should I use for migrated prompts?

Default to `cfgScale: 7` and `steps: 50` as conservative starting points. Increase `steps` to 60–80 for prompts containing "high detail," "intricate," or "8k." Raise `cfgScale` to 8–10 for stronger prompt adherence, or lower to 5–6 for more creative interpretation.