Image2 Generate
Generate images through an OpenAI-compatible image2 relay API and save the outputs as local files.
Configuration
Read configuration from environment variables. Never ask the user to paste an API key into chat, and never write API keys into this skill, scripts, README files, or a Git repository.
IMAGE2_BASE_URL: relay base URL, such ashttps://apinebula.ai/v1IMAGE2_API_KEY: bearer token for the relayIMAGE2_MODEL: image model, defaultgpt-image-2IMAGE2_SIZE: image size, default1024x1024IMAGE2_SYNC: default1; set to0to use the async endpointIMAGE2_TIMEOUT: request or task timeout in seconds, default1800IMAGE2_POLL_INTERVAL: async polling interval in seconds, default3IMAGE2_USER_AGENT: optional User-Agent override
If IMAGE2_BASE_URL or IMAGE2_API_KEY is missing, pause and help the user configure it locally. Ask the user to obtain the API key from their relay provider's dashboard/API Keys page and enter it through a local hidden prompt or environment variable command.
For OS-specific setup commands, read references/env.md.
Workflow
- Clarify the prompt, aspect/size, output count, and style only when they are missing.
- Use
scripts/generate_image.pywith the user's prompt. - Prefer the default synchronous
/images/generationsendpoint because common image2 relays support it; use--asynconly when the relay documents async support. - Save generated images locally and return absolute file paths. In Codex desktop, render the result with Markdown image syntax.
Usage
On Windows PowerShell:
py -3 "C:\path\to\image2-generate\scripts\generate_image.py" `
--prompt "A cinematic product cover of ..."
On macOS/Linux:
python3 /path/to/image2-generate/scripts/generate_image.py \
--prompt "A cinematic product cover of ..."
Use --size, --n, --output-dir, and --prefix when the user asks for a specific format, multiple variants, or a target folder.
Notes
IMAGE2_BASE_URLis only the base URL; do not append/images/generationsto it.- The script supports responses containing
data[].b64_json,data[].url,output[].result,image,base64, or common nested image fields. - Stop after a clear 401, 403, quota, or invalid URL error and report the status plus response body without retrying endlessly.