Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Generate or edit images with XApex asynchronous tasks as the default route, AtlasCloud as the first edit fallback, and aifast as the final fallback, plus forced-provider profiles and batch generation. Use for text-to-image, local or URL reference editing, multi-reference composition, precision-sensitive graphics, XApex image-group tokens, provider-specific sizes and quality, resilient routing, and batch jobs.
.claude/skills/kiakun-collab-gpt-image-2-api/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-06 | ✗→✓ | ▲ Improved | 1% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 563% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 180% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 121% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 88% | 0% |
The scripts are already built and tested. Run them directly — never rewrite, regenerate, or reimplement them. Just call node scripts/<name>.js from this skill directory with the right flags. Reach for references/api-reference.md only when you need provider payloads or to diagnose an API error.
bash# Text to image node scripts/generate.js --prompt "a red fox in snow" # Edit one image node scripts/edit.js --image photo.png --prompt "add sunglasses" # Batch: many prompts at once node scripts/batch.js --promptlist prompts.txt # Default: XApex asynchronous submission and polling node scripts/generate.js --prompt "a red fox in snow" --quality low node scripts/edit.js --image photo.png --prompt "add sunglasses" # Force synchronous XApex or a specific fallback provider only when needed node scripts/generate.js --sync --prompt "a lighthouse at dusk" node scripts/generate.js --profile vip --prompt "force aifast max"
Add --dry-run for a no-cost route/cost preview. Add --json for a machine-readable result.
If a run fails with a missing-key or config error, do the one-time setup below. Otherwise skip it.
| You want to... | Use | |---|---| | One image from text | generate.js | | One image edited from a reference | edit.js | | Many images in one go | batch.js |
When the user supplies a reference image, decide why the pixels matter, then route:
A. Identity / replication — the reference itself must be preserved. Face swap, same character across scenes, keep this exact product/logo, "use this photo", composition or subject must carry over. The model needs the actual pixels as context. → Use edit.js with --image/--url. For multi-image consistency (e.g. character + scene), pass every needed reference; the default XApex edit accepts multiple references.
B. Style / material / palette only — borrow the look, not the subject. "Same art style as this", "this brushwork/texture", "this color mood", but a new subject or scene. Feeding raw pixels here tends to leak the reference's subject and composition. → Prefer describing the look in words and using generate.js (text-to-image): read the reference, write the style/material/palette/lighting into the prompt, then generate fresh. → If the style is hard to verbalize and fidelity matters, fall back to edit.js with a prompt that explicitly says to copy only the style and invent a new subject/composition.
When unsure, ask one short question: "Do you want this image reproduced (keep the subject), or just its style on a new subject?" Default to A (edit with the reference) only when the user clearly means "this exact thing".
Two input modes:
Prompt list — one prompt per line, all sharing the same routing/size params:
bashnode scripts/batch.js --promptlist prompts.txt --model gpt-image-2-max --size 9:16
JSON manifest — per-task control (mix generate and edit, different sizes, references):
bashnode scripts/batch.js --batch tasks.json
tasks.json is a JSON array (or one JSON object per line, JSONL). Each task:
json[ { "prompt": "a red fox in snow" }, { "prompt": "a launch poster", "model": "gpt-image-2-max", "size": "9:16", "quality": "high" }, { "prompt": "add sunglasses", "images": ["photo.png"] }, { "prompt": "combine references", "images": ["a.png", "b.png"], "output": "combo.png" } ]
Per-task fields: prompt or promptfile, profile, model, size, quality, n, async, output, and images / urls (presence of either routes the task to edit.js).
Batch flags: --concurrency <n> (default 2, keeps clear of rate limits), --output-dir <dir> (base for auto-named outputs), --dry-run, --json. Batch continues past a failed task and prints a summary of successes and failures at the end. Batch runs generate/edit tasks in-process, so it avoids starting a fresh Node.js child process for every image.
Auto-named outputs include milliseconds plus a process-local counter, so parallel or rapid same-prompt tasks do not overwrite each other by default.
Preview a high-detail edit before incurring cost, then rerun without --dry-run:
bashnode scripts/edit.js --profile vip --url https://example.com/source.jpg \ --prompt "high-detail e-commerce poster" --size 2048x2048 --quality high --dry-run node scripts/edit.js --profile vip --url https://example.com/source.jpg \ --prompt "high-detail e-commerce poster" --size 2048x2048 --quality high \ --output output/poster.png --json
VIP text-to-image:
bashnode scripts/generate.js --model gpt-image-2-max --size 9:16 --quality high \ --prompt "A launch poster with dense product detail" --output output/poster.png --json
For generation, --quality high is only a routing hint that selects gpt-image-2-max; it is not sent as an API field. Standard gpt-image-2 uses the provider 1K create sizes. Max gpt-image-2-max follows the aifast VIP size table; ratio tokens such as 9:16 map to documented 2K presets such as 1440x2560 so the requested and returned dimensions stay aligned.
Default --profile auto. In auto, XApex handles the task asynchronously first. Provider fallback is capability-aware and records each failed attempt in structured JSON.
| Task | Primary route | Fallback | |---|---|---| | Text-to-image | XApex gpt-image-2 async | aifast; AtlasCloud is skipped because it is edit-only | | Image edit, one or multiple references | XApex gpt-image-2 async | AtlasCloud, then aifast | | Explicit --profile xapex | XApex only, async by default | None | | Explicit --profile atlas | AtlasCloud edit only | None | | Explicit --profile standard|vip | aifast only | Existing VIP-to-Atlas edit fallback remains |
--profile hd is a legacy alias for vip. Use --profile atlas only to force the AtlasCloud channel for diagnosis. AtlasCloud uses openai/gpt-image-2/edit, so it needs at least one reference image; VIP text-to-image does not fall back. Disable edit fallback with GPT_IMAGE_ATLAS_FALLBACK=false.
--profile xapex forces the isolated XApex route. Leave the profile at auto to enable the default priority chain. Provider keys and Base URLs remain isolated throughout fallback.
--prompt or --promptfile.--profile auto|standard|vip|atlas|xapex; prefer auto for XApex-first resilientrouting. Explicit profiles force a provider (hd = legacy alias for vip).
--image for local files or repeat --url for public URLs.Do not mix --image and --url in the same request.
auto, 256x256, 512x512, 1024x1024, 1280x720,720x1280, 1536x1024, 1024x1536, 1792x1024, or 1024x1792.
entries such as 2048x2048, 2560x1440, 1440x2560, 3840x2160, or 2160x3840. Ratio tokens such as 9:16 map to the documented 2K presets by default.
9:16.1024x1024, 1536x1024, or 1024x1536. Other pixel sizes and ratios aremapped client-side by orientation to one of these safe sizes.
--quality only routes to gpt-image-2-max and is omitted from theAPI request. Live probes against aifast showed quality can make max generation disconnect even when the same size succeeds without it. For edit/Atlas fallback, auto, low, medium, or high are supported. XApex sends quality for both generation and edits; its default is low.
XAPEX_ASYNC_DEFAULT=true. The script submits to theXApex /async endpoint and polls /v1/images/tasks/{task_id} with the same key. Use --sync only for diagnosis; --async remains an explicit override.
auto generation uses XApex -> aifast; auto editing usesXApex -> AtlasCloud -> aifast. Set GPT_IMAGE_DEFAULT_FALLBACK=false to disable it.
OPENAI_IMAGE_TIMEOUT_MS=0 so long high-resolution jobs can finish.OPENAI_IMAGE_MAX_RETRIES also covers generated-image URL downloads and remotereference downloads; 5xx/429/network failures retry, ordinary 4xx failures do not.
quality and response_format; the scripts save either data[].url ordata[].b64_json responses.
--output, optional --prompt-output, and recommended --json.Read references/api-reference.md for provider payloads, supported sizes, fallback behavior, or API error diagnosis.
bashnode scripts/check-config.js # reports keys, models, endpoints, timeout, fallback cp .env.example .gateway.env # then fill OPENAI_API_KEY
.env, current-directory.gateway.env, user-level ~/.gateway.env, or the skill root .env / .gateway.env. Earlier sources win; process environment variables always win over files.
XAPEX_API_KEY is required for the default route and must be an XApex 图片 group token.Add ATLASCLOUD_API_KEY for the first edit fallback and OPENAI_API_KEY for the final aifast fallback or forced standard/VIP profiles.
OPENAI_IMAGE_TIMEOUT_MS=0 unless the caller wants a local abort limit.check-config.js shows ready: true, hasApiKey: true, and timeoutMs: none.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-06 | fail→pass | 13,534 | 2,469 | -82% | 1 | 1 | 0% | 3,307 | 3,328 | +1% | 0 | 0 | — |
case-01 | fail→fail | 9,147 | 9,426 | +3% | 1 | 1 | 0% | 1,676 | 3,225 | +92% | 0 | 0 | — |
case-02 | fail→pass | 7,806 | 4,465 | -43% | 1 | 1 | 0% | 469 | 3,111 | +563% | 0 | 0 | — |
case-03 | fail→pass | 5,352 | 1,786 | -67% | 1 | 1 | 0% | 1,114 | 3,122 | +180% | 0 | 0 | — |
case-04 | fail→fail | 8,767 | 4,142 | -53% | 1 | 1 | 0% | 1,994 | 3,418 | +71% | 0 | 0 | — |
case-05 | fail→pass | 14,181 | 1,700 | -88% | 1 | 1 | 0% | 1,426 | 3,146 | +121% | 0 | 0 | — |
case-07 | fail→pass | 10,382 | 4,625 | -55% | 1 | 1 | 0% | 2,039 | 3,836 | +88% | 0 | 0 | — |
case-08 | pass→pass | 8,802 | 4,139 | -53% | 1 | 1 | 0% | 1,798 | 3,678 | +105% | 0 | 0 | — |
case-09 | fail→pass | 10,448 | 3,000 | -71% | 1 | 1 | 0% | 1,905 | 3,079 | +62% | 0 | 0 | — |
case-10 | fail→fail | 12,416 | 3,384 | -73% | 1 | 1 | 0% | 2,581 | 3,134 | +21% | 0 | 0 | — |
case-11 | fail→pass | 12,770 | 3,421 | -73% | 1 | 1 | 0% | 2,517 | 3,518 | +40% | 0 | 0 | — |
case-12 | fail→pass | 8,813 | 2,665 | -70% | 1 | 1 | 0% | 1,623 | 3,323 | +105% | 0 | 0 | — |
case-13 | fail→pass | 11,111 | 4,919 | -56% | 1 | 1 | 0% | 2,180 | 3,708 | +70% | 0 | 0 | — |
case-14 | fail→pass | 7,345 | 2,665 | -64% | 1 | 1 | 0% | 1,216 | 3,206 | +164% | 0 | 0 | — |
case-15 | fail→pass | 7,127 | 3,928 | -45% | 1 | 1 | 0% | 1,440 | 3,584 | +149% | 0 | 0 | — |
case-16 | fail→pass | 16,424 | 3,985 | -76% | 1 | 1 | 0% | 1,359 | 3,671 | +170% | 0 | 0 | — |
case-17 | fail→pass | 6,826 | 2,173 | -68% | 1 | 1 | 0% | 1,438 | 3,191 | +122% | 0 | 0 | — |
case-18 | fail→pass | 11,054 | 3,466 | -69% | 1 | 1 | 0% | 2,050 | 3,414 | +67% | 0 | 0 | — |
case-19 | pass→pass | 2,307 | 2,667 | +16% | 1 | 1 | 0% | 488 | 3,340 | +584% | 0 | 0 | — |
case-20 | pass→pass | 2,056 | 1,810 | -12% | 1 | 1 | 0% | 477 | 3,146 | +560% | 0 | 0 | — |
case-21 | pass→pass | 4,749 | 2,478 | -48% | 1 | 1 | 0% | 984 | 3,302 | +236% | 0 | 0 | — |
case-22 | fail→pass | 7,896 | 2,221 | -72% | 1 | 1 | 0% | 1,785 | 3,229 | +81% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 19 counted toward the lift figure. The other 3 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +68 percentage points is the difference between those two pass rates over the 19 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.