Agent skill

Codex Imagen

by darkamenosa in darkamenosa/codex-imagen

Generate or edit raster images by calling the ChatGPT/Codex hosted imagegeneration flow with local Codex or OpenClaw OAuth credentials, then save decoded image files for OpenClaw and other agent…

MITAuto-check passedMedia & Creative

Install Codex Imagen

skills CLI
$ npx skills add darkamenosa/codex-imagen --skill codex-imagen -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install darkamenosa/codex-imagen codex-imagen --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
codex-imagen
GitHub stars
135
Token cost
~2.6k tokens
SKILL.md length
1,142 words
Files
11 (incl. scripts)
Skills in repo
1
Repo updated
First seen
Licence
MIT

At a glance

Generate or edit raster images by calling the ChatGPT/Codex hosted imagegeneration flow with local Codex or OpenClaw OAuth credentials, then save decoded image files for OpenClaw and other agent…

  • Works in 9 steps: auth → CODEX_IMAGEN_AUTH_JSON,… → OPENCLAW_AGENT_DIR/auth-profiles.json or… → …
  • Tasks that involve Image generation
  • SKILL.md covers Quick Start, Retry Behavior, Timeout Units and Generation Timing, plus 5 more sections
  • Runs JavaScript scripts from its folder; calls node and codex; reaches chatgpt.com and auth.openai.com; needs OPENAI_API_KEY

What it does

Codex Imagen is an agent skill from darkamenosa/codex-imagen. Generate or edit raster images by calling the ChatGPT/Codex hosted imagegeneration flow with local Codex or OpenClaw OAuth credentials, then save decoded image files for OpenClaw and other agent workflows.

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. The skill folder holds 15 other files, including scripts (for example `.github/workflows/ci.yml`, `CHANGELOG.md` and `README.md`).

It sits in Media & Creative, covering Image generation and OAuth and OpenID Connect. It works with OpenAI. The repository describes itself as: Codex/OpenClaw skill for generating images with ChatGPT/Codex OAuth. The licence is MIT.

When your agent uses it

  • Tasks that involve Image generation
  • Tasks that involve OAuth and OpenID Connect

Example prompts

  • “/codex-imagen”

Requirements

  • Node.js
  • A credential in OPENAI_API_KEY

Workflow steps

9 steps, taken from the first numbered list in SKILL.md.

  1. auth
  2. CODEX_IMAGEN_AUTH_JSON, OPENCLAW_CODEX_AUTH_JSON, CODEX_AUTH_JSON
  3. OPENCLAW_AGENT_DIR/auth-profiles.json or PI_CODING_AGENT_DIR/auth-profiles.json
  4. OPENCLAW_AGENT_DIR/auth.json or PI_CODING_AGENT_DIR/auth.json
  5. ~/.openclaw/agents/main/agent/auth-profiles.json
  6. ~/.openclaw/agents/main/agent/auth.json
  7. ~/.openclaw/credentials/oauth.json
  8. CODEX_HOME/auth.json
  9. ~/.codex/auth.json

What it can do on your machine

Read from SKILL.md and the folder at commit d25daed. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (JavaScript), which the agent can run.

    Shell commands in SKILL.md call:

    • node
    • codex

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • chatgpt.com
    • auth.openai.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • OPENAI_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Codex Imagen loads about 2.6k tokens when it runs. Until then it costs about 55 tokens; SKILL.md has 1,142 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~55
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from darkamenosa/codex-imagen at commit d25daed, republished under its MIT licence (© darkamenosa). 1,142 words, ~2,636 tokens.

Download SKILL.mdSave it as .claude/skills/codex-imagen/SKILL.md (or your agent's skills folder). This skill also uses 10 other files; get the full folder from GitHub.
name
codex-imagen
description
Generate or edit raster images by calling the ChatGPT/Codex hosted image_generation flow with local Codex or OpenClaw OAuth credentials, then save decoded image files for OpenClaw and other agent workflows.

Codex Imagen

Generate or edit images by calling the ChatGPT/Codex backend directly with OAuth credentials already stored on the machine. By default this follows Codex's current hosted image flow: POST /responses with the native image_generation tool. The standalone typed image endpoints can be probed with --backend images, but Codex source currently gates that path behind the under-development image-generation extension. It does not start codex app-server, does not need the Codex CLI binary, and does not require OPENAI_API_KEY.

Quick Start

Run the helper through Node for macOS, Linux, and Windows compatibility:

bash
node {baseDir}/scripts/codex-imagen.mjs --timeout 300 'generate image follow this prompt, no refine: "a cinematic fantasy city at sunrise"'

Normal generation prints one generated image path per line. Diagnostics and progress go to stderr.

Use --json when the caller needs machine-readable metadata:

bash
node {baseDir}/scripts/codex-imagen.mjs --json --timeout 300 --prompt 'generate a small blue lotus icon'

Ask for multiple outputs in the prompt. There is no --count flag:

bash
node {baseDir}/scripts/codex-imagen.mjs --timeout 300 -o out/ --prompt 'generate 3 images of a monk mage'

Use --verbose or --debug for request progress, raw Responses event names, and reference image details. Use --quiet when only stdout paths/JSON should be emitted.

Retry Behavior

The helper retries transient empty failures by default: network errors, HTTP 5xx responses, backend server_error / overloaded / unavailable responses, dropped/incomplete streams before any image is saved, and typed JSON responses without image data. Default is --retries 4, meaning 5 total attempts, matching Codex's request retry shape.

Retries are intentionally not used for usage errors, auth errors, policy/input errors, rate limits, generation timeouts, stream errors, or after an image has already been saved. If streaming saves partial images and then times out, the helper returns those saved paths instead of starting a duplicate generation. If the hosted Responses stream terminates or closes before response.completed, already completed images remain saved but the command exits with a stream error, matching Codex turn semantics. The --timeout value applies per generation attempt, so an outer OpenClaw exec.timeout must budget for retries when retries are enabled.

Use --no-retry or --retries 0 when an outer caller owns retry behavior.

Timeout Units

Use --timeout <seconds> for agent-facing calls. This intentionally matches OpenClaw's surrounding exec tool timeout value, which is also in seconds. For a 5 minute OpenClaw call, use --timeout 300.

--timeout-ms <milliseconds> remains available for compatibility and sub-second tests. Do not use --timeout-ms 300 when you mean 5 minutes; that is only 0.3 seconds. Use either --timeout, --timeout-seconds, or --timeout-ms, not more than one in the same command.

Generation Timing

Image generation can be slow, especially when the prompt asks for multiple images. For chat-facing OpenZalo/OpenClaw calls:

  • Use --timeout 300 for ordinary one-image requests.
  • For prompts that ask for 3 images, prefer --timeout 600, or ask for 2 images when the conversation should return quickly.
  • If a 3-image request reaches the timeout after saving 1 or 2 images, the helper returns those saved paths with timed_out: true; this is a usable partial success, not a hang.
  • The --timeout value applies per generation attempt. If default retries are enabled, set the outer OpenClaw exec.timeout higher than the helper timeout budget, or reduce retries with --retries 1 / --no-retry.

Auth Discovery

The CLI reads existing OAuth JSON and sends Authorization: Bearer <access>, ChatGPT-Account-Id, originator: codex_cli_rs, Codex-style request metadata, and a Codex-style user agent to https://chatgpt.com/backend-api/codex/responses by default.

The Responses model defaults to gpt-6-luna; the Images backend defaults to gpt-image-2.

Agent headers
http
originator: codex_cli_rs
version: 0.156.1
user-agent: codex_cli_rs/0.156.1 (<OS> <release>; <arch>) unknown

OS, release, and architecture are detected locally. CODEX_IMAGEN_CODEX_VERSION overrides the version in both headers. The installed Codex CLI and terminal environment do not change these defaults.

Run a local auth check without generating:

bash
node {baseDir}/scripts/codex-imagen.mjs --smoke

Auth lookup order:

  1. --auth
  2. CODEX_IMAGEN_AUTH_JSON, OPENCLAW_CODEX_AUTH_JSON, CODEX_AUTH_JSON
  3. OPENCLAW_AGENT_DIR/auth-profiles.json or PI_CODING_AGENT_DIR/auth-profiles.json
  4. OPENCLAW_AGENT_DIR/auth.json or PI_CODING_AGENT_DIR/auth.json
  5. ~/.openclaw/agents/main/agent/auth-profiles.json
  6. ~/.openclaw/agents/main/agent/auth.json
  7. ~/.openclaw/credentials/oauth.json
  8. CODEX_HOME/auth.json
  9. ~/.codex/auth.json

For OpenClaw, the current auth store is usually:

text
~/.openclaw/agents/main/agent/auth-profiles.json

Codex CLI is not required at runtime. The skill works with OAuth created by OpenClaw itself, for example openclaw onboard --auth-choice openai-codex or openclaw models auth login --provider openai-codex. It only needs an existing openai-codex OAuth profile; it does not perform the first browser login itself.

Profile selection follows OpenClaw first: explicit --auth-profile, CODEX_IMAGEN_AUTH_PROFILE / OPENCLAW_AUTH_PROFILE, OpenClaw config auth.order.openai-codex or configured auth.profiles, then sibling auth-state.json lastGood.openai-codex. Pass --auth-profile openai-codex:<id> when a specific OpenClaw profile should be used.

Show full SKILL.md (477 more words)Show less

Output Paths

Use --out-dir or -o/--output when the caller needs a specific artifact location:

bash
node {baseDir}/scripts/codex-imagen.mjs --out-dir ./openclaw-images --prompt 'generate three UI icon variants'
node {baseDir}/scripts/codex-imagen.mjs -o out/ --prompt 'generate 3 images of a monk mage'

--output image.png writes exactly that path for one image. If multiple images arrive, outputs are numbered as image-1.png, image-2.png, and so on. If --output has no extension or ends in /, it is treated as a directory. Without --output, automatic names use codex-imagen-<timestamp>-<optional-index>-<image-call-id>.png.

When --out-dir is not set, the script chooses the first available location:

  1. CODEX_IMAGEN_OUT_DIR
  2. OPENCLAW_OUTPUT_DIR
  3. OPENCLAW_AGENT_DIR/artifacts/codex-imagen
  4. OPENCLAW_STATE_DIR/artifacts/codex-imagen
  5. ./codex-imagen-output

Streaming is enabled by default and saves each image as soon as it arrives. If a run times out after partial results, already received images remain saved and are printed. If the stream breaks before response.completed, already completed images remain saved but the command fails with a stream error. Use --timeout 300 for chat-facing OpenClaw calls unless the user explicitly asks for a longer run, or --no-stream to request a non-streaming Responses response.

Reference Images

Attach reference images explicitly. Do not use positional image paths; positional arguments are reserved for prompt text.

bash
node {baseDir}/scripts/codex-imagen.mjs --input-ref ref1.png --input-ref ref2.jpg --prompt 'generate 3 images of him livestreaming in this world'
node {baseDir}/scripts/codex-imagen.mjs -i ref1.png -i ref2.jpg --prompt 'change the main character into a woman'
node {baseDir}/scripts/codex-imagen.mjs --image-url 'https://example.com/ref.png' --prompt 'use this image as the world reference'

Local images are converted to data:image/...;base64,... and sent as Responses input_image items by default. --input-ref accepts local paths, http(s) URLs, and data:image/... URLs. -i/--image is local-only, and --image-url is URL/data-URL only. Supported local formats are PNG, JPEG, GIF, and WebP. Use --image-detail auto|low|high|original when the model should receive lower or higher image detail; default is high. Use smaller JPEG references when high-fidelity pixel detail is not needed.

OAuth Refresh

The CLI refreshes expired or near-expiry OAuth tokens through https://auth.openai.com/oauth/token and writes the updated token back to the same auth file. The default OAuth refresh skew is 5 minutes, matching OpenClaw's OAuth usability margin. For OpenClaw auth-profiles.json, refresh uses OpenClaw-compatible cross-agent OAuth refresh locking, then locks the auth store before rereading and writing credentials. It also inherits a fresh matching profile from the main OpenClaw agent store when the current agent/workspace auth store is stale. This avoids refresh_token_reused races when multiple OpenClaw or agent processes share one openai-codex profile.

When auth is auto-discovered and the first auth file is irrecoverably stale, the CLI tries the next compatible auth source, such as CODEX_HOME/auth.json or ~/.codex/auth.json. Explicit --auth paths are not bypassed.

Use these controls when needed:

bash
node {baseDir}/scripts/codex-imagen.mjs --refresh-only --json
node {baseDir}/scripts/codex-imagen.mjs --force-refresh --smoke --json
node {baseDir}/scripts/codex-imagen.mjs --no-refresh --prompt 'generate one image'

For concurrent OpenClaw processes, prefer the active OpenClaw agent's auth-profiles.json so every caller uses the same profile identity. Use --no-refresh only when the caller already owns OAuth refresh and wants this helper to use the provided access token as-is.

Use --base-url only for a compatible Codex backend, and --refresh-url only for a compatible OAuth refresh endpoint.

Cross-Platform Notes

The helper is plain Node.js 22+ with no native dependencies. It uses os.homedir() and environment overrides for Windows, Linux, and macOS. In cmd.exe, single quotes are not shell quotes; use double quotes or write UTF-8 text to a file and use:

bash
node {baseDir}/scripts/codex-imagen.mjs --prompt-file prompt.txt

Use --cwd <path> when another agent launches this script from an unpredictable working directory.

© darkamenosa, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 10 other files (scripts) in the repository root of darkamenosa/codex-imagen.

  • SKILL.md
  • .github/workflows/ci.yml
  • .gitignore
  • CHANGELOG.md
  • LICENSE
  • README.md
  • agents/openai.yaml
  • bin/codex-imagen.js
  • package.json
  • scripts/codex-imagen.mjs
  • scripts/codex-imagen.test.mjs

Open the folder on GitHubat commit d25daed

Compare with similar skills

Codex Imagen next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Codex Imagen compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Codex Imagen this skilldarkamenosa/codex-imagen135—~2.6kAutomated safety check: PassMIT
Media Toolstherichardngai-code/gpt-image-2-pro-max101—~1.5kAutomated safety check: NotesMIT
Chatgpt CLIItamarZand88/CLI-Anything-WEB231—~781Automated safety check: PassMIT
Fish Audio APIwaker240/FullVideoProductionSkill201—~1.1kAutomated safety check: NotesApache-2.0
Gpt Image Genninehills/skills280—~1.8kAutomated safety check: NotesMIT
Nano Banana Antigravitysundial-org/awesome-openclaw-skills663—~559Automated safety check: PassNone

Similar skills

  • Media Tools

    therichardngai-code/gpt-image-2-pro-max

    Two CLI tools for image generation + vision analysis using goclaw's provider-chain pattern.

    101 GitHub stars~1.5k tokensUpdated 4 mo ago
    Media & CreativeAuto-check: notes
  • Chatgpt CLI

    ItamarZand88/CLI-Anything-WEB

    Drives ChatGPT from the terminal via cli-web-chatgpt — ask questions, generate and download images, list and view conversations, browse models, and manage OpenAI SSO auth.

    231 GitHub stars~781 tokensUpdated 9 days ago
    Media & CreativeAuto-check passed
  • Fish Audio API

    waker240/FullVideoProductionSkill

    Generate narration with the public Fish Audio REST API using environment credentials and a user-selected voice.

    201 GitHub stars~1.1k tokensUpdated 13 days ago
    Media & CreativeAuto-check: notes
  • Gpt Image Gen

    ninehills/skills

    生图 / 生成图片 / 画图 — 用 OpenAI gpt-image-2 生成图像。支持文生图、参考图生图 (img2img)、蒙版修补 (inpainting)。当用户要求用 GPT 画图、OpenAI 生图、gpt-image-2、文+图生图、参考图片生成、img2img、inpainting 时必加载此技能。Auth 自动继承 OPENAIAPIKEY / Codex OAuth…

    280 GitHub stars~1.8k tokensUpdated 3 mo ago
    Media & CreativeAuto-check: notes
  • Nano Banana Antigravity

    sundial-org/awesome-openclaw-skills

    Generate or edit images via Nano Banana Pro using Antigravity OAuth (no API key needed!)

    663 GitHub stars~559 tokensUpdated 7 mo ago
    Media & CreativeAuto-check passed
  • Codex API Image Generator

    yc-duan/api-image

    Replaces Codex's built-in image tool with provider-based generation and editing, fetching reference images first whenever visual accuracy actually matters.

    101 GitHub stars~4.9k tokensUpdated 5 mo ago
    Media & CreativeAuto-check passed

Works with

Questions about Codex Imagen

What does Codex Imagen do?

Generate or edit raster images by calling the ChatGPT/Codex hosted imagegeneration flow with local Codex or OpenClaw OAuth credentials, then save decoded image files for OpenClaw and other agent…. Codex Imagen is an agent skill from darkamenosa/codex-imagen. Generate or edit raster images by calling the ChatGPT/Codex hosted imagegeneration flow with local Codex or OpenClaw OAuth credentials, then save decoded image files for OpenClaw and other agent workflows.

When should I use Codex Imagen?

Codex Imagen fits situations like: tasks that involve Image generation; tasks that involve OAuth and OpenID Connect.

How do I install Codex Imagen in Claude Code?

Run `npx skills add darkamenosa/codex-imagen --skill codex-imagen -a claude-code`. Or copy the skill folder (the darkamenosa/codex-imagen repository) into .claude/skills/codex-imagen in your project. Claude Code loads it when a task matches its description.

How do I install Codex Imagen in Codex?

Run `npx skills add darkamenosa/codex-imagen --skill codex-imagen -a codex`. Or copy the skill folder (the darkamenosa/codex-imagen repository) into .agents/skills/codex-imagen in your project. Codex loads it when a task matches its description.

Can I use Codex Imagen in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add darkamenosa/codex-imagen --skill codex-imagen -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/codex-imagen, .gemini/skills/codex-imagen, .github/skills/codex-imagen and .opencode/skills/codex-imagen in your project.

What does Codex Imagen need to run?

Going by SKILL.md and its folder, Codex Imagen needs JavaScript for the scripts in its folder, the command-line tools its instructions call (node and codex) and credentials named OPENAI_API_KEY. Our summary lists: Node.js; A credential in OPENAI_API_KEY.

Does Codex Imagen access the network?

SKILL.md names 2 domains. In commands or code: chatgpt.com and auth.openai.com; the agent is likely to contact these when it follows the instructions. This is read from the text; nothing was executed.

Is Codex Imagen safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Codex Imagen use?

Codex Imagen is published under the MIT licence (from the LICENSE file in the skill folder). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Codex Imagen use?

About 2.6k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Codex Imagen?

Skills that share tags, products or a category with Codex Imagen: Media Tools (therichardngai-code/gpt-image-2-pro-max, 101 stars), Chatgpt CLI (ItamarZand88/CLI-Anything-WEB, 231 stars), Fish Audio API (waker240/FullVideoProductionSkill, 201 stars) and Gpt Image Gen (ninehills/skills, 280 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Codex Imagen?

darkamenosa (a GitHub user) maintains it in darkamenosa/codex-imagen, which has 135 GitHub stars. The repository was last updated on September 23, 2026.

Source: darkamenosa/codex-imagen on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.