openai-image-generation

Installation
SKILL.md

OpenAI Image Generation Skill

Tool Overview

This skill is a thin, reliable wrapper that lets an AI agent generate an image with OpenAI's gpt-image-2 in a single CLI call. The agent supplies the prompt and any parameters that matter for the task (size, quality, format, count, output path); the script handles API key discovery (4-tier loader: process env → Windows User env → .env.local.env), validates and forwards the request to POST /v1/images/generations, decodes the returned base64 payload, writes the file(s) to disk, and — in --json mode — emits a single JSON line on stdout with the saved path(s), key source, and cost estimate. Distinct exit codes (0 ok, 1 missing key/SDK, 2 API failure, 3 empty response) let the caller branch deterministically.

Practical recipe for an agent with task context (e.g. "I need a hero banner for the landing page"):

  1. Pick parameters from the use case — see the smart-defaults table in Step 2.
  2. Pick an output path — relative or absolute; parent dirs are auto-created.
  3. Run the script with --json, parse the JSON, use saved[0] (or saved[] for n>1) downstream.

The skill is global (installed under ~/.agents/skills/openai-image-generation/ via npx skills, or under the plugin cache when installed as a Claude Code plugin — see Script Location), so it's available across sessions and projects without per-project setup — the only requirement is an OPENAI_API_KEY discoverable from one of the four sources above. Image edits / reference images via /v1/images/edits are not wrapped here; for those, call the OpenAI API directly.

Trigger Rules

ONLY activate when user mentions:

  • "OpenAI" + image / "OpenAI image" / "use OpenAI"
  • "gpt-image" / "gpt-image-2" / "GPT Image 2"
  • /openai-image command
Installs
9
First Seen
May 24, 2026
openai-image-generation — chirag2653/openai-image-generation