fix(image_gen/openai): support Codex auth fallback in OpenAI provider#14047
fix(image_gen/openai): support Codex auth fallback in OpenAI provider#14047Hygaard wants to merge 1 commit into
Conversation
Oh, that’s funny — looks like we both landed on the same gap at the same time (one minute apart on PR). From what I can tell, 14046 adds a standalone Codex CLI image backend that depends on a local Codex CLI install and local Codex login state. Mine takes a different route: it extends Hermes’ existing OpenAI image provider so reusable ChatGPT/Codex auth can work there directly, without requiring a separate Codex CLI binary or a new backend. |
#14317) New built-in image_gen backend at plugins/image_gen/openai-codex/ that exposes the same gpt-image-2 low/medium/high tier catalog as the existing 'openai' plugin, but routes generation through the ChatGPT/ Codex Responses image_generation tool path. Available whenever the user has Codex OAuth signed in; no OPENAI_API_KEY required. The two plugins are independent — users select between them via 'hermes tools' → Image Generation, and image_gen.provider in config.yaml. The existing 'openai' (API-key) plugin is unchanged. Reuses _read_codex_access_token() and _codex_cloudflare_headers() from agent.auxiliary_client so token expiry / cred-pool / Cloudflare originator handling stays in one place. Inspired by #14047 by @Hygaard, but re-implemented as a separate plugin instead of an in-place fork of the openai plugin. Closes #11195
|
Thanks for the contribution and research here — closed in favor of #14317, which ships the Codex image-gen path as a separate built-in plugin ( Same gpt-image-2 tier catalog, same Codex Responses |
NousResearch#14317) New built-in image_gen backend at plugins/image_gen/openai-codex/ that exposes the same gpt-image-2 low/medium/high tier catalog as the existing 'openai' plugin, but routes generation through the ChatGPT/ Codex Responses image_generation tool path. Available whenever the user has Codex OAuth signed in; no OPENAI_API_KEY required. The two plugins are independent — users select between them via 'hermes tools' → Image Generation, and image_gen.provider in config.yaml. The existing 'openai' (API-key) plugin is unchanged. Reuses _read_codex_access_token() and _codex_cloudflare_headers() from agent.auxiliary_client so token expiry / cred-pool / Cloudflare originator handling stays in one place. Inspired by NousResearch#14047 by @Hygaard, but re-implemented as a separate plugin instead of an in-place fork of the openai plugin. Closes NousResearch#11195
NousResearch#14317) New built-in image_gen backend at plugins/image_gen/openai-codex/ that exposes the same gpt-image-2 low/medium/high tier catalog as the existing 'openai' plugin, but routes generation through the ChatGPT/ Codex Responses image_generation tool path. Available whenever the user has Codex OAuth signed in; no OPENAI_API_KEY required. The two plugins are independent — users select between them via 'hermes tools' → Image Generation, and image_gen.provider in config.yaml. The existing 'openai' (API-key) plugin is unchanged. Reuses _read_codex_access_token() and _codex_cloudflare_headers() from agent.auxiliary_client so token expiry / cred-pool / Cloudflare originator handling stays in one place. Inspired by NousResearch#14047 by @Hygaard, but re-implemented as a separate plugin instead of an in-place fork of the openai plugin. Closes NousResearch#11195
NousResearch#14317) New built-in image_gen backend at plugins/image_gen/openai-codex/ that exposes the same gpt-image-2 low/medium/high tier catalog as the existing 'openai' plugin, but routes generation through the ChatGPT/ Codex Responses image_generation tool path. Available whenever the user has Codex OAuth signed in; no OPENAI_API_KEY required. The two plugins are independent — users select between them via 'hermes tools' → Image Generation, and image_gen.provider in config.yaml. The existing 'openai' (API-key) plugin is unchanged. Reuses _read_codex_access_token() and _codex_cloudflare_headers() from agent.auxiliary_client so token expiry / cred-pool / Cloudflare originator handling stays in one place. Inspired by NousResearch#14047 by @Hygaard, but re-implemented as a separate plugin instead of an in-place fork of the openai plugin. Closes NousResearch#11195
NousResearch#14317) New built-in image_gen backend at plugins/image_gen/openai-codex/ that exposes the same gpt-image-2 low/medium/high tier catalog as the existing 'openai' plugin, but routes generation through the ChatGPT/ Codex Responses image_generation tool path. Available whenever the user has Codex OAuth signed in; no OPENAI_API_KEY required. The two plugins are independent — users select between them via 'hermes tools' → Image Generation, and image_gen.provider in config.yaml. The existing 'openai' (API-key) plugin is unchanged. Reuses _read_codex_access_token() and _codex_cloudflare_headers() from agent.auxiliary_client so token expiry / cred-pool / Cloudflare originator handling stays in one place. Inspired by NousResearch#14047 by @Hygaard, but re-implemented as a separate plugin instead of an in-place fork of the openai plugin. Closes NousResearch#11195
NousResearch#14317) New built-in image_gen backend at plugins/image_gen/openai-codex/ that exposes the same gpt-image-2 low/medium/high tier catalog as the existing 'openai' plugin, but routes generation through the ChatGPT/ Codex Responses image_generation tool path. Available whenever the user has Codex OAuth signed in; no OPENAI_API_KEY required. The two plugins are independent — users select between them via 'hermes tools' → Image Generation, and image_gen.provider in config.yaml. The existing 'openai' (API-key) plugin is unchanged. Reuses _read_codex_access_token() and _codex_cloudflare_headers() from agent.auxiliary_client so token expiry / cred-pool / Cloudflare originator handling stays in one place. Inspired by NousResearch#14047 by @Hygaard, but re-implemented as a separate plugin instead of an in-place fork of the openai plugin. Closes NousResearch#11195
NousResearch#14317) New built-in image_gen backend at plugins/image_gen/openai-codex/ that exposes the same gpt-image-2 low/medium/high tier catalog as the existing 'openai' plugin, but routes generation through the ChatGPT/ Codex Responses image_generation tool path. Available whenever the user has Codex OAuth signed in; no OPENAI_API_KEY required. The two plugins are independent — users select between them via 'hermes tools' → Image Generation, and image_gen.provider in config.yaml. The existing 'openai' (API-key) plugin is unchanged. Reuses _read_codex_access_token() and _codex_cloudflare_headers() from agent.auxiliary_client so token expiry / cred-pool / Cloudflare originator handling stays in one place. Inspired by NousResearch#14047 by @Hygaard, but re-implemented as a separate plugin instead of an in-place fork of the openai plugin. Closes NousResearch#11195
Summary
plugins/image_gen/openaito work when reusable ChatGPT/Codex auth exists butOPENAI_API_KEYis unsetimages.generate()path unchanged whenOPENAI_API_KEYis configuredChanges
OpenAIImageGenProvider.generate()that extracts the returned image and saves it into Hermes' normal image cacheValidation
pytest tests/plugins/image_gen/test_openai_provider_codex.py tests/plugins/image_gen/test_openai_provider.py -q-> 27 passedOpenAIImageGenProvider.generate(...)returned a cached image withmodel=gpt-image-2-mediumandauth_source=codexNotes
OPENAI_API_KEYis present, the existing API-key path remains preferredCloses #11195