Purpose
Generate images with OpenAI's latest gpt-image-2 model, supporting 2.0's new capabilities: accurate text rendering, multi-image consistency (up to 8 images), and reasoning-based composition.
Trigger Scenarios
The user says:
- "Draw a picture of XX", "Generate an image", "Make an image"
- "Draw a cover / illustration / diagram / storyboard"
- "Produce an image", "Generate an image for me"
- "Draw with gpt-image"
- "Edit this image", "Modify the image", "Change the background to XX", "Edit the image for me" (→ edit mode, requires an image path)
Prerequisites
- Environment variable
OPENAI_API_KEYis set (or the current project root directory has a.envfile containing this variable) - The OpenAI organization has completed Individual verification (required for gpt-image-2)
- Installed
openaiPython package
Script Location
C:/Users/mathr/.claude/skills/draw/draw.py
Usage
Basic Call
python C:/Users/mathr/.claude/skills/draw/draw.py "要畫的內容" --name 檔名前綴
Parameters
prompt(required): what to draw, described in natural language--size:1024x1024(square, default) /1536x1024(landscape) /1024x1536(portrait) /auto--quality:low/medium/high/auto--n: number of images to generate, 1–8 (2.0 supports multi-image consistency)--name: output filename prefix--outdir: output directory (default:slides/generated/in the current working directory; if it doesn't exist, create it in./generated/)
Principles for Determining the quality Level
By default, always use low(when the user explicitly requests: prioritize saving money + speed)
- low(about NT$0.3):the correct choice for 99% of scenarios. It can handle lecture slides, teaching illustrations, concept diagrams, covers, transitions, demos, screen projection purposes, and even slide pages with Chinese titles. It is also 4–5 times faster.
- medium(about NT$1.3): usually unnecessary, unless low is clearly insufficient.
- high(about NT$5.5):only for the following scenarios:
- The user explicitly says "I want the best quality", "I want high", or "it needs to be printed"
- Physical printed materials (posters, book covers, business cards)
- Dense cross-language text with absolutely zero errors (menus, multilingual labels)
If unsure, low. Do not upgrade on your own initiative.
Size impact:1536x1024 is multiplied by about 1.5; multiple n>1 is multiplied by the number of images.
No need to report the level or cost after execution
The user is already familiar with the specifications;do notadd another line like "using low (about NT$0.3)". Just present the result directly and keep it concise.
If you determine that an upgrade to medium or high is needed,stop and ask the user first, and do not make the decision on your own.
Error Handling
- If
403 Organization must be verifiedappears → prompt the user to go to platform.openai.com/settings/organization/general to complete Individual verification - If
401 Invalid API keyappears → check.envor the environment variable - If
429 Rate limitappears → it may be that the OpenAI quota is used up; prompt the user to top up in Billing
Output
PNG file, filename format:<name>_<YYYYMMDD_HHMMSS>.png, when there are multiple, add the _1 _2 suffix.