CH Imagegen
Use this skill for local codex-helper image generation. It calls the proxy's
OpenAI-compatible /v1/images/generations endpoint, or /v1/images/edits when
reference images are passed with --image, saves the returned base64 image, and
validates only the newly written file.
Rules
- Do not use the system
.system/imagegen workflow for requests that explicitly ask for
ch-imagegen or local codex-helper image generation.
- Require a running codex-helper proxy that exposes
/v1/images/generations; reference-image
mode additionally requires /v1/images/edits.
- Do not ask the user to paste provider API keys. Upstream credentials belong in codex-helper
config or environment variables.
- Treat
scripts/generate_image.py exit code and stdout JSON as the source of truth.
- If the script exits non-zero, report the error and stop. Do not infer success from older files.
- Default Image API model intent:
gpt-image-2.
- Default Responses wrapper model:
gpt-5.5, sent as the helper-only responses_model
JSON field so the local bridge uses /v1/responses hosted image_generation through the
same kind of mainline model path as Codex's built-in imagegen tool.
- Default resolution:
2k; default aspect ratio: 16:9; default output format: png;
default quality: high.
- Use
4k only when the user explicitly needs final-resolution output. Set a tool/shell timeout
longer than the script timeout plus retry buffer; do not use a 120s shell timeout for 4K images.
- Treat stdout JSON as authoritative for both success and failure. On failure the script prints
ok:false with error.status, error.classification, error.request_id,
error.failure_hint, error.retryable, error.attempts, and error.suggested_action.
- If
error.classification is image_generation_route_failed and error.failure_hint is
all_upstreams_failed or route_unavailable, report that the configured codex-helper route
did not have a currently usable image-capable upstream for the requested model. Do not present
that as a prompt, reference image, or resolution problem unless the error says so explicitly.
- Do not automatically fall back to the system
.system/imagegen workflow after local proxy
failure. It may use a different account/path; ask or use it only when the user explicitly
approves that bypass.
- Save final outputs under
output/imagegen/ unless the user specifies another directory.
Command
python "${CODEX_HOME:-$HOME/.codex}/skills/ch-imagegen/scripts/generate_image.py" \
--prompt "<user prompt>" \
--aspect "16:9" \
--resolution "2k"
Reference image mode:
python "${CODEX_HOME:-$HOME/.codex}/skills/ch-imagegen/scripts/generate_image.py" \
--prompt "<user prompt>" \
--image "/path/to/reference.png" \
--aspect "3:4" \
--resolution "2k"
Useful overrides:
--base-url "http://127.0.0.1:3211/v1/images/generations"
--edits-base-url "http://127.0.0.1:3211/v1/images/edits"
--responses-model "gpt-5.5" to choose the hosted image_generation wrapper model used
by codex-helper's /v1/responses bridge
--image "reference.png"; may be repeated; accepts local image paths, data:image/...,
HTTP(S) URLs, and file_id values
--input-fidelity "high" for reference-image edits
--aspect "4:3" or --aspect "9:16"
--resolution "4k" for explicit final output
--resolution "2k"
--fallback-resolution "2k" when trying 4K but willing to retry smaller after route/provider
failures
--size "3840x2160"
--quality "medium"
--retries 2
--retry-delay 30
--output-format "webp"
--title "short-slug"
--out-dir "output/imagegen"
--dry-run
Size behavior
4k and 2k are pixel-budget presets. The script computes a valid model size from the
requested aspect ratio.
- Explicit sizes are clamped to
gpt-image-2 limits: max edge 3840, total pixels no more than
8,294,400, long-to-short ratio no more than 3:1, and 16-pixel alignment.
- Use explicit
3840x2160 for 4K landscape or 2160x3840 for 4K portrait.
Validation
After generation, report:
- endpoint used;
- Image API model intent and Responses wrapper model;
- requested size and actual local image size;
- reference image count when present;
- output path;
- revised prompt if present.
If generation fails, report the structured error block from stdout, especially
classification, failure_hint, request_id, retryable, and suggested_action.
Never scan old output files to guess that generation succeeded.
1---2name: ch-imagegen3description: Generate or reference-edit raster images through a running local codex-helper proxy using its OpenAI-compatible `/v1/images/generations` and JSON `/v1/images/edits` bridges. Use when Codex should create bitmap images via the user's local relay/provider chain, when the built-in imagegen tool is unstable with the relay, or when the user asks for `ch-imagegen`, codex-helper image generation, OpenAI Images API generation, reference image generation, gpt-image-2 images, 2K/4K image outputs, or local proxy image generation.4---56# CH Imagegen78Use this skill for local codex-helper image generation. It calls the proxy's9OpenAI-compatible `/v1/images/generations` endpoint, or `/v1/images/edits` when10reference images are passed with `--image`, saves the returned base64 image, and11validates only the newly written file.1213## Rules1415- Do not use the system `.system/imagegen` workflow for requests that explicitly ask for16 `ch-imagegen` or local codex-helper image generation.17- Require a running codex-helper proxy that exposes `/v1/images/generations`; reference-image18 mode additionally requires `/v1/images/edits`.19- Do not ask the user to paste provider API keys. Upstream credentials belong in codex-helper20 config or environment variables.21- Treat `scripts/generate_image.py` exit code and stdout JSON as the source of truth.22- If the script exits non-zero, report the error and stop. Do not infer success from older files.23- Default Image API model intent: `gpt-image-2`.24- Default Responses wrapper model: `gpt-5.5`, sent as the helper-only `responses_model`25 JSON field so the local bridge uses `/v1/responses` hosted `image_generation` through the26 same kind of mainline model path as Codex's built-in `imagegen` tool.27- Default resolution: `2k`; default aspect ratio: `16:9`; default output format: `png`;28 default quality: `high`.29- Use `4k` only when the user explicitly needs final-resolution output. Set a tool/shell timeout30 longer than the script timeout plus retry buffer; do not use a 120s shell timeout for 4K images.31- Treat stdout JSON as authoritative for both success and failure. On failure the script prints32 `ok:false` with `error.status`, `error.classification`, `error.request_id`,33 `error.failure_hint`, `error.retryable`, `error.attempts`, and `error.suggested_action`.34- If `error.classification` is `image_generation_route_failed` and `error.failure_hint` is35 `all_upstreams_failed` or `route_unavailable`, report that the configured codex-helper route36 did not have a currently usable image-capable upstream for the requested model. Do not present37 that as a prompt, reference image, or resolution problem unless the error says so explicitly.38- Do not automatically fall back to the system `.system/imagegen` workflow after local proxy39 failure. It may use a different account/path; ask or use it only when the user explicitly40 approves that bypass.41- Save final outputs under `output/imagegen/` unless the user specifies another directory.4243## Command4445```bash46python "${CODEX_HOME:-$HOME/.codex}/skills/ch-imagegen/scripts/generate_image.py" \47 --prompt "<user prompt>" \48 --aspect "16:9" \49 --resolution "2k"50```5152Reference image mode:5354```bash55python "${CODEX_HOME:-$HOME/.codex}/skills/ch-imagegen/scripts/generate_image.py" \56 --prompt "<user prompt>" \57 --image "/path/to/reference.png" \58 --aspect "3:4" \59 --resolution "2k"60```6162Useful overrides:6364- `--base-url "http://127.0.0.1:3211/v1/images/generations"`65- `--edits-base-url "http://127.0.0.1:3211/v1/images/edits"`66- `--responses-model "gpt-5.5"` to choose the hosted `image_generation` wrapper model used67 by codex-helper's `/v1/responses` bridge68- `--image "reference.png"`; may be repeated; accepts local image paths, `data:image/...`,69 HTTP(S) URLs, and `file_id` values70- `--input-fidelity "high"` for reference-image edits71- `--aspect "4:3"` or `--aspect "9:16"`72- `--resolution "4k"` for explicit final output73- `--resolution "2k"`74- `--fallback-resolution "2k"` when trying 4K but willing to retry smaller after route/provider75 failures76- `--size "3840x2160"`77- `--quality "medium"`78- `--retries 2`79- `--retry-delay 30`80- `--output-format "webp"`81- `--title "short-slug"`82- `--out-dir "output/imagegen"`83- `--dry-run`8485## Size behavior8687- `4k` and `2k` are pixel-budget presets. The script computes a valid model size from the88 requested aspect ratio.89- Explicit sizes are clamped to `gpt-image-2` limits: max edge 3840, total pixels no more than90 8,294,400, long-to-short ratio no more than 3:1, and 16-pixel alignment.91- Use explicit `3840x2160` for 4K landscape or `2160x3840` for 4K portrait.9293## Validation9495After generation, report:9697- endpoint used;98- Image API model intent and Responses wrapper model;99- requested size and actual local image size;100- reference image count when present;101- output path;102- revised prompt if present.103104If generation fails, report the structured `error` block from stdout, especially105`classification`, `failure_hint`, `request_id`, `retryable`, and `suggested_action`.106107Never scan old output files to guess that generation succeeded.