gpt-image-2-api
Skill14 starsChanged 3 months agoMITView on GitHub
Generate and edit images with gpt-image-2 through a third-party OpenAI-compatible API using .env-configured OPENAI_API_KEY and OPENAI_BASE_URL values. Use when the user asks to create images, edit reference images, create visual assets, illustrations, or image variations with a configurable API endpoint.
- Reads credentials
1 other project uses a version of this.
Adopted by
Most recently taken up by
- kiakun-collab/kiakun-skillstheir own version, first seen Nov 1, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- kiakun-collab/kiakun-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- codex-reviewSkill
- context7-auto-researchSkill
- exa-searchSkill
- firecrawl-scraperSkill
- tavily-webSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 0 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 49
Use scripts/gpt-image-2-api.mjs for text-to-image and image-edit requests.
- Very specific: line 50
If required OPENAI_* settings are not available from the current environment or this skill's .env, stop and tell the user which variables …
- Very specific: line 52
Use OPENAI_IMAGE_PROTOCOL=openai_chat only when the endpoint lacks /images/* support.
- Very specific: line 53
Add one or more --image <path> arguments to edit/reference an input image.
- Very specific: line 54
Use --mask <path> or --mask auto only with openai_images edits.
- Very specific: line 68
Use --base-url, --model, --protocol, --size, --quality, --n, --output-format, --background, --moderation, --response-format, and …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
gpt-image-2-api
Purpose
Generate and edit images with gpt-image-2 through a third-party OpenAI-compatible API using .env-configured OPENAI_API_KEY and OPENAI_BASE_URL values. Use when the user asks to create images, edit reference images, create visual assets, illustrations, or image variations with a configurable API endpoint.
Environment Variables & API Key
Two ways to configure API settings (priority: environment variable > .env):
- Environment variables:
OPENAI_API_KEY,OPENAI_BASE_URL, and optionalOPENAI_IMAGE_*overrides .envfile: Place in.env, can copy from.env.example
You can manage the .env file manually or through skill-master env set.
Configuration
OPENAI_API_KEY: API key for the third-party endpointOPENAI_BASE_URL: OpenAI-compatible base URL, for examplehttp://127.0.0.1:3688/v1OPENAI_IMAGE_MODEL: image model name, defaults togpt-image-2OPENAI_IMAGE_PROTOCOL:openai_imagesoropenai_chat, defaults toopenai_imagesOPENAI_IMAGE_SIZE: image size, defaults to1024x1024OPENAI_IMAGE_QUALITY: optional image qualityOPENAI_IMAGE_N: number of images (1-10), defaults to1OPENAI_IMAGE_OUTPUT_FORMAT: optional output format (png,jpeg,webp)OPENAI_IMAGE_FORMAT: legacy alias forOPENAI_IMAGE_OUTPUT_FORMATOPENAI_IMAGE_RESPONSE_FORMAT: optional response format (url,b64_json)OPENAI_IMAGE_BACKGROUND: optional background (transparent,opaque,auto)OPENAI_IMAGE_MODERATION: optional moderation level (low,auto)OPENAI_IMAGE_OUTPUT_COMPRESSION: optional compression level0–100forjpeg/webpOPENAI_IMAGE_PARTIAL_IMAGES: optional streaming partial image count0–3OPENAI_IMAGE_INPUT_FIDELITY: optional edit fidelity (high,low)OPENAI_IMAGE_STYLE: optional generation style fordall-e-3(vivid,natural)OPENAI_IMAGE_STREAM: optionalopenai_imagesSSE toggle (true,false)OPENAI_IMAGE_USER: optional end-user identifierOPENAI_IMAGE_EXTRA_JSON: optional JSON object merged into the request body
Workflow
- Use
scripts/gpt-image-2-api.mjsfor text-to-image and image-edit requests. - If required
OPENAI_*settings are not available from the current environment or this skill's.env, stop and tell the user which variables need to be configured. openai_imagesgeneration uses/images/generationswith JSON;openai_imagesediting uses/images/editswithmultipart/form-data.- Use
OPENAI_IMAGE_PROTOCOL=openai_chatonly when the endpoint lacks/images/*support; it does not support--mask,--background,--output-format, or streaming image events. - Add one or more
--image <path>arguments to edit/reference an input image. - Use
--mask <path>or--mask autoonly withopenai_imagesedits. - Save generated files under the user requested output directory, or the current working directory when unspecified.
- Report saved file paths and any API errors exactly.
Available Scripts
scripts/gpt-image-2-api.mjs— Sends a text prompt, optionally with input images, to the configured OpenAI-compatible endpoint and saves returned images.
Generate Image
node scripts/gpt-image-2-api.mjs --prompt "a concise image prompt" --output ./generated-images --size 1024x1024 --n 1 --output-format pngUse --base-url, --model, --protocol, --size, --quality, --n, --output-format, --background, --moderation, --response-format, and --extra-json only when the user or endpoint requires overrides.
Edit Image
node scripts/gpt-image-2-api.mjs --prompt "make the dog wear a red scarf" --image ./input.png --output ./edited-imagesMultiple input images are supported by repeating --image. --input is accepted as an alias for --image.
Mask example for openai_images:
node scripts/gpt-image-2-api.mjs --protocol openai_images --prompt "replace the background" --image ./input.png --mask ./mask.png --output ./edited-imagesAuto-mask example for openai_images:
node scripts/gpt-image-2-api.mjs --protocol openai_images --prompt "remove the background" --image ./input.png --mask auto --background transparent --output-format png --output ./edited-imagesFallback example when the endpoint only supports chat completions:
OPENAI_IMAGE_PROTOCOL=openai_chat node scripts/gpt-image-2-api.mjs --prompt "a concise image prompt" --output ./generated-imagesParameters
| Parameter | Required | Type | Default | Description |
prompt | yes | string | — | Text description for generation or edit |
model | no | string | gpt-image-2 | Image model name |
n | no | integer | 1 | Number of images, range 1–10 |
size | no | string | 1024x1024 | Output size passed through to the upstream endpoint |
quality | no | string | endpoint default | low, medium, high, auto |
output-format | no | string | endpoint default | png, jpeg, webp |
response-format | no | string | endpoint default | url, b64_json; mainly for DALL·E-compatible responses |
background | no | string | endpoint default | transparent, opaque, auto |
moderation | no | string | endpoint default | low, auto |
output-compression | no | integer | endpoint default | Compression 0–100 for jpeg/webp |
partial-images | no | integer | endpoint default | Streaming partial image count 0–3 |
input-fidelity | no | string | endpoint default | Edit fidelity: high, low |
style | no | string | endpoint default | Generation style for dall-e-3: vivid, natural |
user | no | string | — | End-user identifier |
format | no | string | — | Legacy alias for output-format |
Size Behavior
The script does not hard-validate size; values are passed through so OpenAI-compatible upstream endpoints can decide what they support.
For the Yunwu-compatible docs currently checked in this project:
/images/generationsdocumentsauto,1024x1024,1536x1024,1024x1536,2048x2048,2048x1152,3840x2160, and2160x3840/images/editscurrently documents the classic GPT image set:auto,1024x1024,1536x1024,1024x1536dall-e-2documents256x256,512x512,1024x1024dall-e-3documents1024x1024,1792x1024,1024x1792- Chat-compatible fallbacks remain endpoint-specific
Because provider behavior may differ by endpoint and documentation may lag behind the implementation, this skill forwards size unchanged and lets the upstream API accept or reject it.
Size Constraints
- Max side length ≤ 3840px
- Both sides must be multiples of 16px
- Aspect ratio ≤ 3:1 (long/short)
- Total pixels: min 655360, max 8294400
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

