How to Configure Batch Generation for Multi-Card Series in GPT-Image2

Configure a batch object inside your style definition in data/style-library.json, set size for the card count and imagesPerCard for the image count, then execute node scripts/generate-style-skill.mjs to generate the entire series in bulk.

GPT-Image2 from the freestylefly/awesome-gpt-image-2 repository automates multi-card image production through declarative JSON batch configuration. Instead of generating images one by one, you define a batch generation schema that controls volume, pacing, and prompt variation across the series. This guide details how to configure batch generation for multi-card series in GPT-Image2 using the core source files and execution scripts.

Understanding the Batch Architecture

The batch generation system orchestrates four primary components to produce multi-card series:

  • data/style-library.json – Stores declarative style definitions and contains the top-level batch object that specifies generation volume and rate limiting.
  • scripts/generate-style-skill.mjs – CLI script that reads the JSON configuration, constructs request payloads, and manages API throttling via delayMs.
  • api/generate-image.js – Serverless endpoint receiving individual generation requests and returning task_id references.
  • src/main.jsx – Frontend React component polling task IDs and rendering the completed multi-card carousel.

When invoked, generate-style-skill.mjs extracts the batch parameters, iterates through the card index range from 0 to size-1, and dispatches requests to the /api/generate-image endpoint either concurrently or with controlled delays.

Batch Configuration Schema

The batch object accepts five parameters that define the multi-card behavior:

Field Type Description Example
size number Total cards to generate in the batch. 8
imagesPerCard number Images requested per individual card. 3
delayMs number Milliseconds between API calls to avoid rate limits. 500
repeat boolean Reuse the same prompt across all cards when true. true
template string Prompt template with {{i}} interpolation for card indexing. "Cyberpunk skyline #{{i}}"

When repeat is false, the generator expects a cards array with explicit prompts. If the array length is less than size, the system pads remaining slots with empty prompts.

Step-by-Step Configuration

Define the Batch Object in data/style-library.json

Create a style definition that includes the batch configuration. For indexed variations across cards, use the template field with the {{i}} placeholder:

{
  "name": "Neon-City-Series",
  "model": "stable-diffusion-xl",
  "resolution": "1024x1024",
  "batch": {
    "size": 5,
    "imagesPerCard": 2,
    "delayMs": 300,
    "template": "A neon-lit cyberpunk city at night, skyline {{i}}"
  }
}

This configuration creates five distinct cards, each containing two images, with a 300-millisecond delay between API requests to prevent throttling.

Execute the Generation Script

Run the batch processor from the project root:

node scripts/generate-style-skill.mjs --style data/style-library.json

The script parses the JSON, extracts the batch parameters, and constructs the request queue. Console output indicates real-time progress:


[▶] Generating card 0 – prompt: "A neon-lit cyberpunk city at night, skyline 0"
[▶] Generating card 1 – prompt: "A neon-lit cyberpunk city at night, skyline 1"

Each successful API call returns a task_id that the script persists via supabaseClient.js for frontend polling.

Handle Rate Limits with delayMs

For large batches or strict API quotas, increase the delayMs value to serialize requests. Setting delayMs: 1000 ensures one-second gaps between calls, keeping you within provider limits while processing the full size quota. Omitting this field causes the script to fire all requests concurrently using Promise.all.

Advanced Batch Patterns

Explicit Card Definitions Without Templates

For precise control over each card's content, disable templating and provide a cards array:

{
  "name": "Art-Collage-Series",
  "model": "midjourney",
  "resolution": "1536x1536",
  "batch": {
    "size": 3,
    "imagesPerCard": 1,
    "repeat": false
  },
  "cards": [
    { "prompt": "A surreal portrait of a woman made of clouds" },
    { "prompt": "An abstract composition of geometric shapes in pastel tones" },
    { "prompt": "A vintage travel poster for a moon colony" }
  ]
}

With repeat: false, the generator maps each array index directly to a card, ignoring the template field. The size parameter must equal or exceed the array length.

Generating Variations with repeat: true

To create stylistic variations using identical prompts, enable the repeat flag:

{
  "batch": {
    "size": 10,
    "imagesPerCard": 1,
    "repeat": true,
    "delayMs": 500
  },
  "cards": [
    { "prompt": "A minimalist logo design for a coffee brand" }
  ]
}

This produces ten cards requesting the same prompt with different random seeds, yielding varied outputs suitable for A/B testing.

Summary

  • Store configuration in data/style-library.json using a top-level batch object containing size, imagesPerCard, and optional delayMs.
  • Run executions via scripts/generate-style-skill.mjs, which parses the batch schema and manages API throttling automatically.
  • Use template with {{i}} interpolation for indexed variations, or set repeat: true to clone prompts for seed variations.
  • Respect rate limits by configuring delayMs to insert milliseconds between requests; omit for maximum concurrency.
  • Poll results through src/main.jsx, which displays completed images in a multi-card interface once task_id resolution finishes.

Frequently Asked Questions

What is the maximum batch size supported by GPT-Image2?

The codebase imposes no hardcoded limit on the size parameter; the practical ceiling depends on your API provider's rate limits and available Supabase storage quota. For production workloads, test with delayMs: 1000 and monitor for HTTP 429 errors before scaling beyond 50 cards per batch.

Can I mix templated and explicit card definitions in one batch?

No. The generate-style-skill.mjs script evaluates the repeat flag to determine generation mode. When repeat is false, it exclusively consumes the cards array and ignores template. When repeat is true or undefined with a template present, it uses interpolation exclusively.

How does the frontend know when a batch is complete?

The frontend component in src/main.jsx polls the Supabase database for task_id statuses matching the current series name. Once all IDs in the batch return status completed, React state updates trigger a re-render displaying the full multi-card grid.

Where are the generated images stored during batch processing?

The scripts/generate-style-skill.mjs script persists each returned task_id and subsequent image URL to the Supabase instance configured in your environment variables via supabaseClient.js. The api/generate-image.js endpoint handles the initial task creation, while the script manages the association between card indices and storage records.

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 →