imagegen
imagegen
Generate images through the Azure OpenAI-compatible image generation API and save the returned base64 image data to local files.
Defaults
- Endpoint/base URL:
AZURE_OPENAI_BASE_URL, orhttps://maritimeai-resource.openai.azure.com/openai/v1/if unset. - API key:
AZURE_OPENAI_API_KEYis required. - Model/deployment:
AZURE_OPENAI_IMAGE_MODEL, orgpt-image-2if unset. - API version header:
AZURE_OPENAI_API_VERSION, orpreviewif unset. - Output directory:
./generated-images/if the user does not specify a file path.
Never write API keys into files, command examples, logs, or final responses.
Standard Workflow
- Collect the prompt. If the prompt is missing, ask for it.
- Choose output settings. Default to
1024x1024,high,png, andn=1unless the user specifies otherwise. - Run the Node CLI from the skills workspace or with an absolute script path:
node imagegen/scripts/generate-image.mjs \
--prompt "A watercolor painting of a maritime research vessel at sunrise" \
--output ./generated-images/ship.png
- Report the saved file path(s), model, size, quality, and format.
- If Azure returns an error, preserve the status code and message, but redact secrets.
Command Reference
node imagegen/scripts/generate-image.mjs \
--prompt "A cinematic harbor at dawn" \
--size 1536x1024 \
--quality high \
--format png \
--n 1 \
--output ./generated-images/harbor.png
Optional environment overrides:
export AZURE_OPENAI_BASE_URL="https://maritimeai-resource.openai.azure.com/openai/v1/"
export AZURE_OPENAI_IMAGE_MODEL="gpt-image-2"
export AZURE_OPENAI_API_VERSION="preview"
Useful CLI flags:
--prompt <text>: text prompt for image generation.--prompt-file <path>: read the prompt from a UTF-8 file.--output <path>: output file path for one image, or filename prefix whenn > 1.--output-dir <path>: directory for auto-named outputs.--base-url <url>: overrideAZURE_OPENAI_BASE_URL.--model <name>: overrideAZURE_OPENAI_IMAGE_MODEL.--size <WxH>: image size, such as1024x1024.--quality <low|medium|high>: generation quality.--format <png|jpeg>: output format.--n <1-10>: number of images.--user <id>: optional end-user identifier for Azure/OpenAI tracking.--timeout-ms <ms>: request timeout, default180000.--dry-run: validate inputs and print the redacted request without calling Azure.
GPT-image-2 Size Rules
For gpt-image-2, validate custom sizes before calling the API:
- Width and height must both be multiples of 16.
- Long edge must be no more than 3840 px.
- Aspect ratio must be no more than 3:1.
- Total pixels must be between 655,360 and 8,294,400.
Use 1024x1024 when unsure.
Reference
Read references/azure-openai-image-api.md when troubleshooting API shape, headers, endpoint variants, or model parameter constraints.
More from inforix/skills
notion-to-weixin
Fetch a Notion page by title, export to Markdown, convert Markdown to HTML with a user-provided CSS file, and create a Weixin draft via node-wxcli. Use when asked to publish Notion content into Weixin draftbox, or when moving Notion pages into Weixin draft as HTML.
26obsidian-to-weixin
Find an Obsidian note by title/path with obsidian-cli, keep note content as Markdown, upload note images to Weixin, and create a Weixin draft via node-wxcli from Markdown stdin. Use when publishing Obsidian notes into Weixin draftbox.
14shmtu-word-formatter
把文章按“上海海事大学党政公文格式”刷成 Word(.docx),或对已有 .docx 进行统一排版后保存。凡是用户提到“刷格式”“按公文格式排版”“生成 Word”“把这篇文章整理成正式公文格式”“这个 docx 帮我统一格式”时都应触发本技能。
4electronic-trusted-certificate
Use this skill whenever the user mentions 电子可信证明,成绩单,在读证明,绩点证明 electronic trusted certificates, student proof documents, enrollment or study-status certificates, transcript or degree verification, verification codes, or asks to use the SHMTU MCP server over HTTP. This skill probes the endpoint, initializes the MCP session, lists tools, and calls the right tool with bearer-token authentication without writing secrets into repo files.
1