# OpenAI/Codex image generation in Hermes

Session-proven setup for using ChatGPT/Codex OAuth as the Hermes `image_gen` backend.

## When to use

Use this when the user wants image generation through their existing ChatGPT/Codex account rather than a separate OpenAI API key or local ComfyUI model.

This is useful for cloud-side keyframes, thumbnails, concept images, and visual tests. It does not consume local/remote GPU VRAM, so it can run alongside a local Wan/ComfyUI video pipeline operationally, as long as jobs are still coordinated sensibly.

## Configuration

```bash
hermes config set image_gen.provider openai-codex
hermes config set image_gen.model gpt-image-2-medium
```

Useful model tiers:

```bash
hermes config set image_gen.model gpt-image-2-low     # fast/cheap iteration
hermes config set image_gen.model gpt-image-2-medium  # default balance
hermes config set image_gen.model gpt-image-2-high    # final keyframes/assets
```

The provider uses Hermes-managed Codex/ChatGPT OAuth. If auth is missing, sign in via the Hermes auth/setup flow for Codex/OpenAI Codex rather than asking for an `OPENAI_API_KEY` first.

## Verification

A quick provider probe from the Hermes repo can verify registration and auth without generating an image:

```bash
python - <<'PY'
from hermes_cli.plugins import _ensure_plugins_discovered
from agent.image_gen_registry import get_provider
_ensure_plugins_discovered(force=True)
p = get_provider('openai-codex')
print('provider_registered =', bool(p))
print('provider_available =', bool(p and p.is_available()))
print('default_model =', p.default_model() if p else None)
PY
```

Expected when ready:

```text
provider_registered = True
provider_available = True
default_model = gpt-image-2-medium
```

## Runtime behavior

The standard Hermes `image_generate` tool then routes to `openai-codex` and saves outputs under:

```text
~/.hermes/cache/images/
```

The generated image result can be delivered in Telegram with `MEDIA:/absolute/path/to/image.png`.

## Pipeline notes

For AutoShortsBot/Retention-Studio style workflows:

```text
script idea → GPT Image 2 keyframe/concept → human review → Wan/ComfyUI I2V or local renderer → deterministic captions/overlays
```

Do not rely on baked image text for final captions, numbers, labels, risk meters, or audit-sensitive facts. Add those later with the deterministic renderer.