Pi extension that exposes the local Codex CLI's built-in image generation capability as a Pi tool named codex_image.
This package is designed to reduce the two biggest failure modes we hit in practice:
- execution drift — the extension now sends the prompt to
codex execover stdin, which matches the current Codex CLI behavior - discoverability drift — the extension explicitly bridges user phrasing like
pi-codex-image,use Codex, orask Codex to generate an imageto the canonical Pi tool namecodex_image
It also adds:
- startup preflight checks
- argument normalization (
input_images,output_path,references, etc.) - a
/codex-image-doctorcommand - stronger single-image behavior when
outputPathis set
When Pi calls codex_image, the extension:
- checks that Codex is installed and logged in
- creates a temporary
CODEX_HOME - copies your Codex auth into that temp home
- runs
codex execnon-interactively withimage_generationenabled - collects generated image file(s)
- returns the image(s) back to Pi
- optionally copies the single output image to a requested path
This extension does not call an image API directly. It is a thin bridge from Pi to the local codex CLI.
- Pi
- local
codexCLI installed and onPATH - Codex logged in with ChatGPT (
~/.codex/auth.jsonpresent)
pi install git:github.com/tmustier/pi-codex-imagepi install ~/.pi/agent/extensions/pi-codex-imagepi -e git:github.com/tmustier/pi-codex-imageThese are all intended to resolve to the same extension-backed capability:
use pi-codex-imageask Codex to generate an imageuse Codex for this diagramedit this image with Codex
The canonical callable Pi tool remains:
codex_image
Parameters:
prompt— required text promptinputImages— optional array of local image pathsoutputPath— optional exact file path for the final imageoverwrite— optional boolean for replacingoutputPathmodel— optional Codex model overridetimeoutSec— optional timeout, default180
The tool also normalizes common argument variants such as:
input_imagesoutput_pathreferencesrequestinstructionstimeout
Checks whether the extension is ready to register and run, including:
codexavailability onPATH- auth file presence
- required
codex execflags
outputPathonly works when Codex produces exactly one image- the extension asks Codex for a single final image by default unless the user explicitly requests variants
- the extension runs Codex with a temporary
CODEX_HOMEand removes it afterward
MIT