apiyi-gpt-image-2-all-gen

Original🇨🇳 Chinese
Translated
2 scriptsChecked / no sensitive code detected

AI Image Generation Skill, using the latest ChatGPT image generation model gpt-image-2-all. This skill is applied when users need to generate images, visual infographics, create graphics, or edit/modify/adjust existing images. Based on the image generation service of the latest ChatGPT image generation model gpt-image-2-all from APIYI Platform (https://api.apiyi.com/), no external network access is required. The model is charged per image at $0.03 per piece, supporting text-to-image generation, single image editing, multi-image fusion, and natural language-based image modification, with high text restoration accuracy and friendly Chinese prompts. The size is controlled by prompt description (no explicit size parameter). Key differences from NanoBanana2: no size parameter, need to describe the size at the beginning of the prompt; unified $0.03 per image with no resolution tiering; the conversational endpoint /v1/chat/completions is the recommended one.

2installs
Added on

NPX Install

npx skill4agent add wuchubuzai2018/expert-skills-hub apiyi-gpt-image-2-all-gen

Tags

Translated version includes tags in frontmatter

SKILL.md Content (Chinese)

View Translation Comparison →

Image Generation and Editing (GPT Image 2 All) Skills

This image generation skill is implemented based on the latest ChatGPT image generation model gpt-image-2-all from APIYI Platform. It can help users generate images through natural language, accessed via APIYI's domestic proxy service, and supports both Node.js and Python runtime environments. gpt-image-2-all is an official reverse ChatGPT image generation model launched on APIYI Platform, priced at a highly competitive $0.03 per image on a pay-per-use basis. It takes approximately 60 to 300 seconds to generate an image, supporting text-to-image generation, single image editing, multi-image fusion, and natural language-based image modification, with high text restoration accuracy, few content restrictions, and native support for Chinese prompts.

Usage Guide

Follow these steps:

Step 1: Requirement Analysis and Parameter Extraction

  1. Clarify Intent: Distinguish whether the user needs [Text-to-Image] (generate new images), [Image-to-Image] (edit/modify existing images), or [Multi-Image Fusion].
  2. Prompt Analysis:
    • Use the user's original complete input: Directly use the user's original full question and requirement description as the main body of the
      -p
      prompt. Avoid rewriting, summarizing, or secondary creation on your own to prevent loss of details.
    • Confirm first when supplementation is needed: If information is insufficient (e.g., missing style, number of subjects, shot language, scene details, text content, prohibited elements, etc.), ask the user for confirmation first; after the user confirms, append the supplementary content to the original prompt in an "appended" manner.
    • Examples:
      • User input: "Help me generate a picture of a cat, with a cute style."
      • Correct example: Use the user's input directly as the prompt:
        -p "Help me generate a picture of a cat, with a cute style."
      • Incorrect example: Unauthorized rewriting to "Generate a cute-style cat picture" will lose the details and tone of the user's original input.
      • If details need to be supplemented (e.g., color, background, etc.), ask for confirmation first: "What color do you want the cat to be? Any requirements for the background?" After the user replies, append it to the prompt:
        -p "Help me generate a picture of a cat, with a cute style. The cat is orange, and the background is grass."
  3. Key Parameter Organization:
    • Prompt (Required): The final prompt after analysis (default = the user's original complete and consistent input; only append supplementary information after user confirmation).
    • Filename (Optional): Output image filename/path (must include a random identifier to avoid duplication). If not provided, the script will automatically generate a filename with a timestamp. It is recommended to generate a reasonable filename based on the content (e.g.,
      cat_in_garden.png
      ), avoid using generic names.
    • Size/Aspect (Optional): Since the model has no explicit size parameter, the size is controlled by prompt description. It is recommended to describe the size at the beginning of the prompt.
      • "Mobile wallpaper" -> Write
        Vertical 9:16
        or
        Mobile poster 9:16
        at the start of the prompt
      • "Computer wallpaper/video cover" -> Write
        Horizontal 16:9
        or
        Movie aspect ratio 16:9
        at the start of the prompt
      • "Avatar" -> Write
        1:1 Square composition
        or
        1024×1024 Square image
        at the start of the prompt
      • Default: If the user does not explicitly specify the image ratio, leave it blank (adaptive by the model).
    • Response Format (Optional): Response format, default is
      url
      (R2 CDN accelerated link), optional
      b64_json
      (base64 image data).
    • Note: The model does not support
      size
      ,
      n
      ,
      quality
      ,
      aspect_ratio
      parameters; passing them may trigger parameter validation errors.

Step 2: Environment Check and Command Execution

  1. Check Environment: Confirm whether the
    APIYI_API_KEY
    environment variable is set (usually assumed to be set; prompt the user if the operation fails).
  2. Build and Run Commands:
    • Priority: Node.js version: If Node is available in the environment (the
      node
      command works), prefer using
      scripts/generate_image.js
      (zero dependencies, parameters consistent with Python).
    • Use Python version if Node is unavailable: Use
      scripts/generate_image.py
      .
    Text-to-Image Command Template (Priority: Node.js):
    bash
    node scripts/generate_image.js -p "{prompt}" -f "{filename}" [-r {response_format}]
    Image-to-Image Command Template (Priority: Node.js):
    bash
    node scripts/generate_image.js -p "{edit_instruction}" -i "{input_path}" -f "{output_filename}" [-r {response_format}]
    Multi-Image Fusion Command Template (Priority: Node.js):
    bash
    node scripts/generate_image.js -p "Merge the styles of image 1 and image 2" -i ref1.png ref2.png -f "merged.png" [-r {response_format}]
    (Optional) Python Version Command Template (When Node is Unavailable):
    bash
    python scripts/generate_image.py -p "{prompt}" -f "{filename}" [-r {response_format}]
    python scripts/generate_image.py -p "{edit_instruction}" -i "{input_path}" -f "{output_filename}" [-r {response_format}]

⏱️ Long-running Task Handling Strategy

1. Pre-task Prompt

Must inform the user before execution:
  • "Image generation has started, it is expected to take 60 to 300 seconds"

2. 🎨 Best Practice Example

"Image generation in progress, expected to complete in 60 to 300 seconds...
⏳ Generating..."

Step 3: Result Feedback

  1. Execution Feedback: Wait for the terminal command to complete execution.
  2. Success: Inform the user that the image has been generated and indicate the save path.
  3. Failure:
    • If prompted with missing API Key, guide the user to set the environment variable.
    • If prompted with network error, suggest the user check the network or try again later.

Command Line Usage Examples

Generate New Images

bash
python scripts/generate_image.py -p "Image description text" -f "output.png" [-r url|b64_json]
Example:
bash
# Basic generation
python scripts/generate_image.py -p "A cute orange cat playing on the grass" -f "cat.png"

# Specify size (describe at the start of the prompt)
python scripts/generate_image.py -p "Horizontal 16:9 Movie aspect ratio, sunset mountain scenery" -f "sunset.png"

# Vertical high-definition image (suitable for mobile wallpaper)
python scripts/generate_image.py -p "Vertical 9:16 Mobile poster, city night view" -f "city.png"
(Optional) Node.js Version Example:
bash
# Basic generation
node scripts/generate_image.js -p "A cute orange cat playing on the grass" -f "cat.png"

# Specify size
node scripts/generate_image.js -p "Horizontal 16:9 Movie aspect ratio, sunset mountain scenery" -f "sunset.png"

Edit Existing Images

bash
python scripts/generate_image.py -p "Editing instruction" -f "output.png" -i "path/to/input.png"
Example:
bash
# Modify style
python scripts/generate_image.py -p "Convert the image to watercolor style" -f "watercolor.png" -i "original.png"

# Add elements
python scripts/generate_image.py -p "Add a rainbow to the sky" -f "rainbow.png" -i "landscape.png"

# Replace background
python scripts/generate_image.py -p "Change the background to a beach" -f "beach-bg.png" -i "portrait.png"
(Optional) Node.js Version Example:
bash
# Modify style
node scripts/generate_image.js -p "Convert the image to watercolor style" -f "watercolor.png" -i "original.png"

# Merge multiple reference images (up to 5)
node scripts/generate_image.js -p "Merge the styles of image 1 and image 2" -i ref1.png ref2.png -f "merged.png"

Command Line Parameter Description

Parameters are consistent between Python and Node.js versions (short parameters are equivalent to long parameters).
ParameterRequiredDescription
-p
/
--prompt
YesImage description (for text-to-image) or editing instruction (for image-to-image). Keep the user's original complete input.
-f
/
--filename
NoOutput image path/filename; if not provided, a PNG filename with timestamp will be automatically generated and saved to the current directory.
-r
/
--response-format
NoResponse format:
url
(default, R2 CDN link) or
b64_json
(base64 image data).
-i
/
--input-image
NoInput image path for image-to-image; multiple images can be passed (up to 5). Passing this parameter enters editing mode.

File Resource Description

ResourceDescription
scripts/generate_image.js
Node.js version (zero dependencies, preferred)
scripts/generate_image.py
Python version (alternative)
references/size-guide.md
Size and ratio control document, use when needed, load on demand
references/batch-template.md
Batch generation configuration template, use when batch generation is needed, load on demand

Batch Generation

When the user needs to generate multiple images at once (batch generation):
  1. Load Configuration Template: references/batch-template.md — includes JSON configuration format description and usage examples
  2. Obtain/Generate JSON File: Users can provide their own JSON file, or describe requirements and let AI generate it based on the needs
  3. Preprocess Prompt: Ensure each prompt starts with size description (e.g., "Horizontal 16:9"), supplement
    global.size_hint
    if necessary
  4. Execute One by One: Read the prompts array, execute generation commands one by one, and feed back results after each image is completed
  5. Summarize Feedback: After completion, inform the user of the number of successful images and the list of image paths
Note: Total time for batch tasks = single image time (60-300 seconds) × number of images. Please inform the user of the estimated duration in advance.

Image Ratio Description

Since the gpt-image-2-all model has no size parameter, the size is controlled by prompt description. The following verified stable expressions are recommended:
RequirementRecommended Expression
Square1024×1024 Square image / 1:1 Square composition
HorizontalHorizontal 16:9 / Wide screen 16:9 Movie aspect ratio
VerticalVertical 9:16 / Mobile poster 9:16
Ultra-wide bannerBanner 21:9 Ultra-wide screen
Classic printing4:3 Standard aspect ratio / 3:2 Classic aspect ratio
Tip: Describe the size/composition at the beginning of the prompt for better model compliance. You can match it with aspect ratio style words (e.g., movie aspect ratio, mobile poster, square composition) to further improve consistency.

Response Format Description

url (Default)

Returns an R2 CDN accelerated link by default, valid for approximately 24 hours. Suitable for direct rendering in web applications. For images that need long-term storage, please transfer and save them to your own object storage immediately after generation.

b64_json

Returns base64 encoded image data (with
data:image/png;base64,
prefix included). Suitable for:
  • Server-side direct image data processing
  • Need to write to local files
  • Direct rendering on the frontend

Notes

  • API Key must be set, which can be provided via environment variable or command line parameter
  • Image generation time: approximately 60 to 300 seconds
  • When editing images, the input image will be automatically converted to base64 encoding
  • Ensure the output directory has write permission
  • The model does not support
    size
    ,
    n
    ,
    quality
    ,
    aspect_ratio
    parameters
  • The default response url field is an R2 CDN accelerated link, valid for approximately 24 hours

API Key Setup and Acquisition

How to Obtain API Key

If you don't have an API Key yet, please go to https://api.apiyi.com to register an account and apply for an API Key.
Acquisition Steps:
  1. Visit https://api.apiyi.com
  2. Register/log in to your account
  3. Create an API Key in the console
  4. Copy the key and set it as an environment variable or use it in the command line

Set API Key

The script obtains the API Key from the environment variable
APIYI_API_KEY
.
Set Environment Variable:
bash
# Linux/Mac
export APIYI_API_KEY="your-api-key-here"

# Windows CMD
set APIYI_API_KEY=your-api-key-here

# Windows PowerShell
$env:APIYI_API_KEY="your-api-key-here"

API Endpoint Description

Recommended Endpoint: POST /v1/chat/completions

Conversational endpoint — compared to
/v1/images/generations
and
/v1/images/edits
, the conversational endpoint follows prompts better, and the same endpoint supports both text-to-image generation and reference image-based modification, naturally enabling multi-round iterations.
  • Only input text messages → Text-to-image generation
  • Add image_url (URL or base64 data URL) to messages → Reference image-based modification
  • Retain assistant historical messages and continue asking → Multi-round iterative image modification

Model Information

  • Model Name: gpt-image-2-all
  • Image Generation Speed: Approximately 60-300 seconds
  • Output Resolution: No explicit size parameter, adaptive by the model (recommended to describe in prompt)
  • Default Response Format: url (R2 CDN accelerated link, default 1-day validity)
  • Optional Response Format: b64_json
  • Chinese Prompts: ✅ Natively supported
  • Supported Capabilities: Text-to-image generation, single image editing, multi-image fusion, natural language-based image modification
  • Price: $0.03 per image

Author Introduction

  • Everywhere who loves One Piece
  • My WeChat Official Account: Ubiquitous Technology",