agentleFS
OpenMinisOpenMinis/MinisSkills/codex-image/SKILL.md

codex-image

Skill584 starsChanged 59 days agoMITView on GitHub

Generate images using OpenAI's Codex backend API with gpt-image-2 tool. Use when the user asks to generate images via Codex, ChatGPT image generation, or gpt-image-2. Triggers on "codex image", "codex generate", "gpt-image", "chatgpt generate image". Token is auto-fetched from chatgpt.com session — no manual token setup needed.

We split this skill into the rules it gives an agent

5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No manual token setup needed — the skill handles auth automatically

    line 13
  2. Distinctive:

    If already logged in → token extracted and saved to cache immediately

    line 22
  3. Very specific:

    If not logged in → opens chatgpt.com/auth/login in the browser, then polls every 10s in a new tab for up to 5 minutes

    line 23
  4. Very specific:

    Not logged in → minis-open pops the ChatGPT login page to the user in foreground, then polls every 10s (up to 5 min) until login is detected

    line 79
  5. Very specific:

    Run scripts/codex_image.py with appropriate arguments.

    line 81

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Codex Image Generation

Generate images via chatgpt.com/backend-api/codex/responses using the image_generation tool (gpt-image-2).

Requirements

  • A ChatGPT account (token is fetched automatically via browser session)
  • No manual token setup needed — the skill handles auth automatically

Auth Token Resolution (in order)

  1. --token argument (CLI only)
  2. CODEX_IMAGE_TOKEN environment variable
  3. --token-file argument (CLI only)
  4. ~/.chatgpt_auth.json cache (valid for 8 hours)
  5. Auto login flow — fetches from https://chatgpt.com/api/auth/session via minis-browser-use:
    • If already logged in → token extracted and saved to cache immediately
    • If not logged in → opens chatgpt.com/auth/login in the browser, then polls every 10s in a new tab for up to 5 minutes
    • On success → saves token to ~/.chatgpt_auth.json (chmod 600, token + timestamp only)
    • Token is never printed to stdout or logs — it stays in the cache file only

Usage

Text-to-image

python3 scripts/codex_image.py "a cute rabbit on a light background" \
  --output rabbit.png \
  --model gpt-5.4 \
  --effort low

Image-to-image / reference image

python3 scripts/codex_image_edit.py "turn this person into a cinematic iOS AI assistant portrait" \
  --image reference.jpg \
  --output portrait.png \
  --model gpt-5.4 \
  --effort low

codex_image_edit.py encodes the local reference image as a base64 data URL and sends it as multimodal input (input_text + input_image) to the same Codex responses endpoint, then asks the image_generation tool to create a new image from the reference.

Parameters

ParameterDefaultDescription
prompt(required)Image description or edit instruction
--image(edit only, required)Local reference image path for image-to-image generation
--outputcodex_image.png / codex_image_edit.pngOutput file path
--modelgpt-5.4Codex model
--effortlowReasoning effort: low/medium/high
--token-Access token directly (skips auto auth; text-to-image script only)
--token-file-File containing token (skips auto auth; text-to-image script only)

Output

JSON with success, path, size, revised_prompt on success.

Auth Script (standalone)

python3 scripts/get_auth.py

Returns JSON {"success": true, "source": "cache|session|login"} — the token itself is never printed to stdout. It is written only to ~/.chatgpt_auth.json (chmod 600, token + timestamp only, no PII). This prevents the token from appearing in shell logs, conversation context, or screenshots.

Workflow

  1. Token: auto-resolved via get_auth.py:
    • Already cached → use directly
    • Already logged in (browser session) → extract immediately
    • Not logged in → minis-open pops the ChatGPT login page to the user in foreground, then polls every 10s (up to 5 min) until login is detected
  2. Construct the prompt from the user's request.
  3. Run scripts/codex_image.py with appropriate arguments.
  4. Send the generated image to the user.

Notes

  • Token is cached in ~/.chatgpt_auth.json for 8 hours (chmod 600, token + timestamp only — no PII stored).
  • Token is never printed to stdout or conversation context — always read from cache file internally.
  • The endpoint requires stream: true; the script handles SSE parsing internally.
  • Token is a ChatGPT session token, not an OpenAI API key. It expires and is refreshed automatically on next use.
  • Image generation uses gpt-image-2 under the hood with auto quality/size.
  • Token usage is split: main usage tracks text tokens, tool_usage.image_gen tracks image tokens separately.
  • This uses an internal/unofficial API endpoint. Availability may change.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.