gpt-image-2

gpt-image-2-skill

OtherClaude Codeby leoleoasd

Summary

Generate and edit images with OpenAI's gpt-image-2 model.

Install to Claude Code

/plugin install gpt-image-2@gpt-image-2-skill

Run in Claude Code. Add the marketplace first with /plugin marketplace add leoleoasd/gpt-image-2-skill if you haven't already.

README.md

gpt-image-2-skill

A Claude Code skill that generates and edits images with OpenAI's gpt-image-2 model — text-to-image, image editing, inpainting, and multi-image composition — without leaving your terminal.

Packaged as a Claude Code plugin so it installs with two commands.

Install

In Claude Code:

/plugin marketplace add luyuxuanleo/gpt-image-2-skill
/plugin install gpt-image-2

Then give it your OpenAI API key. Easiest way — run the setup command and follow the prompt:

/gpt-image-2:setup

It saves the key to ~/.config/gpt-image-2/credentials (permissions 600) so you only do it once. Prefer to manage it yourself? Either of these also works:

export OPENAI_API_KEY=sk-...                 # per shell session
printf '%s' sk-... | python3 plugins/gpt-image-2/skills/gpt-image-2/gpt_image.py set-key -

The skill checks OPENAI_API_KEY first, then the saved file.

Use

Just ask Claude, e.g.:

  • "Generate a watercolor red fox sleeping in the snow, portrait orientation."
  • "Make a transparent PNG logo of a minimalist mountain icon."
  • "Edit photo.png to look like a vintage oil painting."
  • "Combine product.png and beach.png into one product shot on the beach."

Claude invokes the skill, saves the image next to your working directory, and gives you the path.

Run the script directly

The skill is a single zero-dependency Python script (urllib only — no pip install):

python3 plugins/gpt-image-2/skills/gpt-image-2/gpt_image.py \
  generate "a red fox in snow" --size 1024x1536 --quality high --out fox.png

python3 plugins/gpt-image-2/skills/gpt-image-2/gpt_image.py \
  edit "make the sky a starry night" --image scene.png --mask sky.png --out night.png

Options

| Option | Values | |---|---| | --size | WxH or auto — edges multiple of 16, max 3840, ratio ≤ 3:1 (e.g. 1024x1024, 2048x2048, 3840x2160) | | --quality | low, medium, high, auto | | --background | transparent, opaque, auto | | --format | png, jpeg, webp | | --compression | 0-100 (jpeg/webp) | | --n | number of images | | --out | output path | | --model | override model id (or set GPT_IMAGE_MODEL) |

Configuration

| Env var | Purpose | |---|---| | OPENAI_API_KEY | required — your OpenAI API key | | GPT_IMAGE_MODEL | optional — override the model (default gpt-image-2) | | OPENAI_BASE_URL | optional — point at a compatible/proxy endpoint |

License

MIT

Related plugins

Browse all →