Quick start
Prefer using scripts/generate_image.js, do not repeatedly hand-write the request body.
First inject the API Key into the current shell:
export IKUNCODE_API_KEY='你的 API Key'
Text-to-image:
node skills/ikuncode-image-gen/scripts/generate_image.js \
--prompt '一只可爱的皮卡丘正在开心地吃生日蛋糕,明亮温馨插画风格' \
--output ./pikachu-cake.png
Image-to-image:
node skills/ikuncode-image-gen/scripts/generate_image.js \
--input ./source.png \
--prompt '把背景改成星空,保留主体姿态和配色' \
--output ./edited.png
Workflow
- Confirm that the user wants IKunCode image generation, not the OpenAI Images API.
- Use
gemini-3.1-flash-image-previewwhen the user explicitly requests a high-quality final version.gemini-3-pro-image-preview。 - Use
--aspect-ratio 1:1 --size 2Kfor default parameters unless the user explicitly specifies otherwise. - Have the output file land in the directory requested by the user; if the user does not specify one, save it in the current working directory.
- If the user provides a reference image, pass
--input, and the script will automatically convert it to Base64 and put it intoinlineData。 - If the command fails due to network or sandbox issues, request execution permission; do not blame the failure on the script itself.
Security rules
- Only read the key from the environment variable
IKUNCODE_API_KEY. - Do not write the API Key into
SKILL.md, scripts, test files, terminal history examples, or git commits. - If a command needs to be shown, always write
'你的 API Key'or reference the environment variable in examples, and do not show the real value. - If the user pastes the Key directly in the conversation, it may be used temporarily for the current command, but do not write it to disk.
Parameter selection
--modelgemini-3.1-flash-image-preview: default, speed firstgemini-3-pro-image-preview: final version, quality first
--aspect-ratio- Common:
1:1、16:9、9:16、4:3、3:4
- Common:
--size- Common:
1K、2K、4K - Default recommendation
2K
- Common:
When more parameters or return format details are needed, read references/api.md。
Troubleshooting
Missing IKUNCODE_API_KEY- The current shell does not have the environment variable injected.
- API returns 4xx/5xx
- Show the API response body directly; it is usually a model name, authentication, or parameter error.
- There is no
inlineData- in the response, indicating that the API did not successfully produce an image; print the full JSON first before troubleshooting.
Examples
- "Use flash to generate an image of Pikachu eating cake, and save it to the current directory"
- "Based on this product image, change the background to a snowy mountain, and do not change the subject"
- "Help me batch-generate 3 16:9 cover images at 2K resolution"