codex-image

Generate images via the ChatGPT Codex backend API using the gpt-image-2 image generation tool.

1|Updated Jun 20, 2026
One-click install
npx skills add https://github.com/riipandi/minis-skills --skill codex-image-riipandi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: codex-image
Source: https://github.com/riipandi/minis-skills/tree/main/codex-image
Command: npx skills add https://github.com/riipandi/minis-skills --skill codex-image-riipandi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? It lets you generate and edit images through ChatGPT's Codex backend API without manually managing API keys, since the session token is fetched automatically from your browser login. ## Core Features & Use Cases - Text-to-Image Generation: Create images from text prompts via the gpt-image-2 tool on the Codex responses endpoint. - Image-to-Image Editing: Transform a local reference image into a new image using multimodal input (input_text + input_image). - Automatic Authentication: Tokens are resolved from cache, an existing browser session, or an interactive login flow, and are never printed to stdout. - Use Case: Ask for a cinematic portrait based on your photo, and the skill encodes the reference image, calls the Codex API, and saves the result as a PNG. ## Quick Start Generate an image of a cute rabbit on a light background using the codex image skill and save it as rabbit.png.

Frequently Asked Questions about codex-image

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate an image with ChatGPT from the command line?

Run scripts/codex_image.py with a prompt and an --output path. The script calls the chatgpt.com Codex responses endpoint with the image_generation tool and saves the returned base64 PNG to your file.

How to do image-to-image generation with a reference photo?

Use scripts/codex_image_edit.py with --image pointing to your local reference file. The script encodes it as a base64 data URL and sends it as multimodal input alongside your edit instruction.

Do I need an OpenAI API key for ChatGPT image generation?

No API key is required. The skill uses your ChatGPT session token, fetched automatically from chatgpt.com via browser session or an interactive login flow, and caches it in ~/.chatgpt_auth.json for 8 hours.

Why does ChatGPT image generation fail with a 401 or 403 error?

A 401 or 403 means the session token expired or is invalid. The script detects OAuth errors, deletes the stale cache, refreshes the token from the browser session, and retries once automatically.

Is the ChatGPT Codex image API an official endpoint?

No, it uses an internal, unofficial chatgpt.com backend endpoint, so availability may change without notice. Token usage is split between text tokens and image generation tokens tracked separately.