/skill-image-gen:generate-image [description of the image to generate]from skill-image-gen
Generates AI images and visual assets via OpenAI gpt-image-2 or Google Gemini image models, handling provider selection, API calls, and file saving.
Ships in skill-image-gen. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Generate an image from a user prompt, choose an available provider from environment keys, call the provider API safely, decode the returned image, save it in a sensible project location, and report the output path.
Use $ARGUMENTS as the image prompt. Preserve the user's subject, style, dimensions, file format, and output path when specified. If $ARGUMENTS is empty, use the most recent user request as the prompt; if no prompt exists, return blocked with the missing input instead of inventing an image.
SKILL_IMAGE_GEN_OPENAI_KEY enables OpenAI image generation.SKILL_IMAGE_GEN_GEMINI_KEY enables Google Gemini image generation.assets/, images/, public/, or the current directory.| Environment | Provider choice | Rationale |
|---|---|---|
Only SKILL_IMAGE_GEN_OPENAI_KEY is set | OpenAI | Use the available key without asking. |
Only SKILL_IMAGE_GEN_GEMINI_KEY is set | Gemini | Use the available key without asking. |
| Both keys are set and user names one | User's provider | Explicit request wins. |
| Both keys are set and no preference | OpenAI for polish or text rendering; Gemini for speed and iteration | Choose based on prompt context. |
| No keys are set | Onboarding | Explain both providers and ask for configuration in interactive environments; otherwise report blocked. |
Only run onboarding when neither key is set. Explain the provider choices without generating anything:
| Provider | Model | Best for | Key URL |
|---|---|---|---|
| OpenAI | gpt-image-2 | High quality, polished visuals, stronger text rendering, paid image generation. | https://platform.openai.com/api-keys |
| Google Gemini | Nano Banana / Gemini image models | Fast iteration, free tier availability, visual drafts and variations. | https://aistudio.google.com/apikey |
If the user provides a key in the same session, set only the corresponding process environment variable (SKILL_IMAGE_GEN_OPENAI_KEY or SKILL_IMAGE_GEN_GEMINI_KEY) for the current run. Persist to a shell profile only when explicitly requested.
| Field | Value |
|---|---|
| Method | POST |
| URL | https://api.openai.com/v1/images/generations |
| Headers | Authorization: Bearer <SKILL_IMAGE_GEN_OPENAI_KEY>, Content-Type: application/json |
| Default model | gpt-image-2 |
| Alternative model | gpt-image-1 |
| Default size | 1024x1024 |
| Size options | 1024x1024, 1024x1536, 1536x1024, auto |
| Default quality | medium |
| Quality options | low, medium, high |
{
"model": "gpt-image-2",
"prompt": "<user prompt>",
"n": 1,
"size": "1024x1024",
"quality": "medium"
}
Decode data[0].b64_json when present. If data[0].url is returned instead, download that URL and save the image. Escape special characters in the prompt before placing it in JSON.
| Field | Value |
|---|---|
| Method | POST |
| URL shape | https://ai.google.dev/gemini-api/docs/models<model>:generateContent |
| Headers | x-goog-api-key: <SKILL_IMAGE_GEN_GEMINI_KEY>, Content-Type: application/json |
| Default model | gemini-2.0-flash-exp |
| Alternative model | gemini-2.5-flash-image |
| Response image | candidates[0].content.parts[] item with inlineData.data and inlineData.mimeType |
{
"contents": [{"parts": [{"text": "Generate an image: <user prompt>"}]}],
"generationConfig": {"responseModalities": ["TEXT", "IMAGE"]}
}
Handle API errors in error, safety blocks in promptFeedback.blockReason, and filtered completions with finishReason: "SAFETY".
| User asks for | Add prompt constraints |
|---|---|
| Game texture | seamless, tileable, game asset, material detail, no perspective seams. |
| Icon | Simple silhouette, centered composition, transparent or plain background when supported. |
| Sprite | Consistent camera angle, clean outline, limited palette, animation frame constraints if needed. |
| Mockup | Product context, UI/device frame, readable text only when needed. |
| Batch generation | Keep a shared style seed in prose and vary only the requested subject. |
For batch generation, make independent API calls in parallel when tooling allows it, but write each output to a distinct path.
$ARGUMENTS and determine prompt, provider preference, output directory, file name, and batch count.SKILL_IMAGE_GEN_OPENAI_KEY and SKILL_IMAGE_GEN_GEMINI_KEY.b64_json or inlineData.data, or download data[0].url when OpenAI returns a URL.Authorization and x-goog-api-key values in logs and responses.Check whether SKILL_IMAGE_GEN_OPENAI_KEY and/or SKILL_IMAGE_GEN_GEMINI_KEY are available before choosing a provider.
## Image generation result
**Status:** complete | blocked | failed
**Provider:** OpenAI | Gemini | none
**Model:** `<model>`
**Prompt:** `<final prompt summary>`
**Output:** `<path/to/image>`
### Files
- `<path/to/image>`: <format>, <size if known>, <nonzero bytes verified>
### Validation
- API response decoded: pass | fail
- Output directory created: pass | fail
- Image file exists and is nonzero: pass | fail
$ARGUMENTS or conversation context supplied a concrete image prompt.SKILL_IMAGE_GEN_OPENAI_KEY and SKILL_IMAGE_GEN_GEMINI_KEY were never printed or committed.data[0].b64_json, data[0].url, or inlineData.data as appropriate.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin skill-image-genOther plugins' skills for the same job