gpt-image-2 · gargantuax — скилл для Claude Code: генерация и редактирование изображений
Python-скилл для всех маршрутов GPT Image 2: генерация, редактирование по маске и Responses API. Запускается из командной строки и работает с любым OpenAI-совместимым шлюзом.
npx skills add GargantuaX/openskills --skill gpt-image-2 -a claude-codeЧто делает gpt-image-2
Один Python-скрипт покрывает три сценария работы с GPT Image 2. generations создаёт картинки по текстовому описанию, edits принимает несколько изображений и маску, responses даёт стриминг, частичные превью и смешанный ввод текст плюс картинка.
Перед запуском скилл валидирует параметры: размер, соотношение сторон, ограничения конкретной модели. Несовместимые комбинации вроде прозрачного фона или partial_images вне диапазона 0..3 отбрасываются сразу, без запроса к API.
Конфигурация читается из .env, переменные окружения процесса имеют приоритет над файлом, а CLI-флаги перекрывают оба источника. Для отладки есть --dry-run — он показывает собранный запрос, ничего не отправляя. Чтобы сохранить сырой JSON или SSE-поток, добавьте --save-response <path>. Секреты в выводе не печатаются.
Для работы нужен Python и ключ API в окружении. По умолчанию используется https://api.openai.com/v1, но подойдёт любой OpenAI-совместимый endpoint.
Какие задачи решает
- Сгенерировать картинку по текстовому описанию
- Отредактировать изображение с маской
- Создать пачку изображений за один запуск
- Получить стриминг с частичными превью через Responses API
- Проверить запрос перед отправкой в API
Примеры запросов агенту
- Сгенерируй обложку для лендинга через
python ./skills/gpt-image-2/scripts/gpt_image.py generations --prompt "Минималистичная обложка" --output ./out/cover.png - Сделай редактирование с маской: `python ./skills/gpt-image-2/scripts/gpt_image.py edits --prompt "Замени фон" --image ./refs/subject.png --mask ./refs/mask.png --output ./out/result.png`
- Проверь запрос, не отправляя его:
python ./skills/gpt-image-2/scripts/gpt_image.py generations --prompt "Тест" --output ./out/test.png --dry-run
Как установить gpt-image-2
1Через Skills CLI (Vercel)
npx skills add GargantuaX/openskills --skill gpt-image-2 -a claude-code2Вручную: положить файлы
~/.claude/skills/gpt-image-2/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/gpt-image-2/
1Через Skills CLI (Vercel)
npx skills add GargantuaX/openskills --skill gpt-image-2 -a codex2Вручную: положить файлы
.agents/skills/gpt-image-2/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add GargantuaX/openskills --skill gpt-image-2 -a cursor2Вручную: положить файлы
.cursor/skills/gpt-image-2/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install GargantuaX/openskills gpt-image-22Вручную: положить файлы
.github/skills/gpt-image-2/SKILL.md1Через Skills CLI (Vercel)
npx skills add GargantuaX/openskills --skill gpt-image-2 -a gemini-cli2Командой платформы
gemini skills install https://github.com/GargantuaX/openskills --path skills/gpt-image-2Вручную: положить файлы
.devin/skills/gpt-image-2/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add GargantuaX/openskills --skill gpt-image-2 -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о gpt-image-2
Как установить gpt-image-2 в Claude Code?
Выполните npx skills add GargantuaX/openskills --skill gpt-image-2 -a claude-code. Скилл появится в ~/.claude/skills/gpt-image-2/SKILL.md.
Что делает gpt-image-2?
Запускает генерацию, редактирование и Responses-потоки GPT Image 2 из командной строки. Валидирует параметры до отправки запроса и работает с любым OpenAI-совместимым шлюзом.
Чем generations отличается от responses?
generations — это публичный Images API для обычной генерации. responses — отдельный маршрут для стриминга, смешанного ввода и частичных превью, он использует текстовую модель вроде gpt-5.4.
Исходный текст
SKILL.md · MIT
---
name: gpt-image-2
description: Full OpenAI-compatible GPT Image 2 coverage across images/generations, images/edits, and responses with the image_generation tool. Use when the one-shot image helper is not enough - text-to-image, mask edits, multi-image batches, streaming, partial_images, and mixed text+image Responses flows. Reads .env and respects process environment variables; works with any OpenAI-compatible gateway.
---
# GPT Image 2
A single Python entrypoint that covers every GPT Image 2 route, with strict pre-flight validation of the model's size, aspect, and feature constraints.
## Workflow
1. Open [references/config.md](./references/config.md) to pick environment variables and defaults.
2. Open [references/api-surface.md](./references/api-surface.md) to choose between `generations`, `edits`, and `responses`.
3. Prefer `OPENAI_BASE_URL=https://api.openai.com/v1` unless the user asks for a different OpenAI-compatible endpoint.
4. Use `gpt-image-2` for `generations` and `edits`; use a text-capable Responses model such as `gpt-5.4` for `responses`.
5. Run `scripts/gpt_image.py` with one of the three subcommands.
6. Add `--dry-run` first when the payload shape is the main risk.
7. Add `--save-response <path>` when the raw JSON body or SSE event stream needs to be kept for debugging.
## Commands
Text-to-image through the public Images API:
```powershell
python .\skills\gpt-image-2\scripts\gpt_image.py generations `
--prompt "A bold product hero image for a developer tool homepage" `
--output .\out\hero.png `
--size 1536x1024 `
--quality high `
--format png
```
Multi-image batch with a filename pattern:
```powershell
python .\skills\gpt-image-2\scripts\gpt_image.py generations `
--prompt "A cinematic city skyline at night" `
--output .\out\skyline-{index}.webp `
--n 3 `
--format webp `
--compression 90
```
Image edits with two inputs plus a mask:
```powershell
python .\skills\gpt-image-2\scripts\gpt_image.py edits `
--prompt "Blend the two references into one clean marketing illustration" `
--image .\refs\subject.png `
--image .\refs\background.png `
--mask .\refs\mask.png `
--output .\out\edit-{index}.png `
--image-field-style brackets `
--n 2
```
Responses API with streaming and partial previews:
```powershell
python .\skills\gpt-image-2\scripts\gpt_image.py responses `
--input-text "Generate a poster for an AI developer summit" `
--model gpt-5.4 `
--output .\out\poster-{index}.png `
--stream `
--partial-images 2 `
--save-response .\out\poster-events.json
```
Responses API edit with a local image plus a mask:
```powershell
python .\skills\gpt-image-2\scripts\gpt_image.py responses `
--input-text "Turn this product shot into a clean studio ad" `
--model gpt-5.4 `
--input-image .\refs\product.png `
--mask .\refs\mask.png `
--output .\out\studio.png `
--action edit
```
Inspect the built request without sending it:
```powershell
python .\skills\gpt-image-2\scripts\gpt_image.py generations `
--prompt "A minimal cover image" `
--output .\out\cover.png `
--dry-run
```
## Rules
- Use `generations` for public text-to-image calls.
- Use `edits` for multipart image edits and mask uploads.
- Use `responses` for advanced flows: streaming, mixed text + image input, `previous_response_id`, `tool_choice`, `action`, and optional `tool_model`.
- Process environment variables override `.env`; CLI flags override both.
- Never print secrets.
- `--output` takes either a single path or a pattern such as `image-{index}.png` for multi-image or streaming flows.
- `responses` uses a top-level Responses model separate from the image model; default it to `gpt-5.4` unless you need another text-capable model.
- `quality` on Responses tool flows is passed through, but final behavior still depends on the hosted image tool.
- On OpenAI GPT image models, omit `response_format`; image data already comes back as base64.
- Fail fast on unsupported `gpt-image-2` combinations: transparent background, invalid size, `partial_images` outside `0..3`, or `stream=true` with `n>1` on public Images routes.
## Resources
- Script: [scripts/gpt_image.py](./scripts/gpt_image.py)
- Config reference: [references/config.md](./references/config.md)
- API surface reference: [references/api-surface.md](./references/api-surface.md)
© GargantuaX · MIT · GargantuaX/openskills
Похожие скиллы
Всё по теме «ИИ и ML» →Сначала — gpt-image-2 от других авторов.