Generate images via the OpenAI Images API from the CLI, save returned images to files, and control model/size/quality/format. Use when a user asks to create images with OpenAI's image generation API (for example /v1/images/generations), wants a script or CLI to call it, or needs local image files from gpt-image-1 or DALL-E models.
Use scripts/generate_image.py to call the OpenAI Images API (/v1/images/generations) and write the returned images to disk. Read the API key from OPENAI_API_KEY.
export OPENAI_API_KEY="..."
python scripts/generate_image.py --prompt "Retro 90s space strategy UI, beveled panels, map view" --size 1024x1024 --quality high --output-format png --output-dir ./out --prefix space-ui
--prompt, --prompt-file, trailing args, or stdin (in that order).--model to gpt-image-1 (default) or a DALL-E model.--output-dir with --prefix and a matching extension.--json to print the full API response (saved paths go to stderr).--no-save to skip writing files.--json: full API response JSON on stdout; saved paths (if any) on stderr.nano-banana-pro.--size, --quality, --background, --output-format, --output-compression, and --moderation with GPT image models.--response-format and --style with DALL-E models.--n to control the number of images to generate.--timeout, --retries, and --backoff to handle slow or rate-limited requests.