Skip to content

fix(image_gen/openai): support Codex auth fallback in OpenAI provider#14047

Closed
Hygaard wants to merge 1 commit into
NousResearch:mainfrom
Hygaard:fix/openai-image-provider-codex-auth
Closed

fix(image_gen/openai): support Codex auth fallback in OpenAI provider#14047
Hygaard wants to merge 1 commit into
NousResearch:mainfrom
Hygaard:fix/openai-image-provider-codex-auth

Conversation

@Hygaard

@Hygaard Hygaard commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • allow plugins/image_gen/openai to work when reusable ChatGPT/Codex auth exists but OPENAI_API_KEY is unset
  • keep the existing API-key images.generate() path unchanged when OPENAI_API_KEY is configured
  • add regression coverage for provider availability and the Codex-backed request shape

Changes

  • read existing Codex auth and treat it as a valid availability signal for the OpenAI image provider
  • add a Codex Responses image-generation path inside OpenAIImageGenProvider.generate() that extracts the returned image and saves it into Hermes' normal image cache
  • update the OpenAI image provider setup/manifest text so it no longer implies an API key is mandatory when Codex auth already exists
  • add focused tests covering availability, streamed image extraction, and the request shape sent to the Codex image-generation tool

Validation

  • pytest tests/plugins/image_gen/test_openai_provider_codex.py tests/plugins/image_gen/test_openai_provider.py -q -> 27 passed
  • manual smoke in a Codex-authenticated environment: OpenAIImageGenProvider.generate(...) returned a cached image with model=gpt-image-2-medium and auth_source=codex

Notes

  • when OPENAI_API_KEY is present, the existing API-key path remains preferred
  • this is scoped to the OpenAI image provider; it does not change FAL defaults

Closes #11195

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins tool/vision Vision analysis and image generation labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #14046 (Codex CLI backend) — different approach to same goal (#11195). This one reuses the OpenAI provider with Codex auth fallback; #14046 adds a standalone codex-cli provider.

@Hygaard

Hygaard commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

Related to #14046 (Codex CLI backend) — different approach to same goal (#11195). This one reuses the OpenAI provider with Codex auth fallback; #14046 adds a standalone codex-cli provider.

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.

teknium1 added a commit that referenced this pull request Apr 23, 2026
#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
@teknium1

Copy link
Copy Markdown
Contributor

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 (plugins/image_gen/openai-codex/) rather than an auth fallback inside the existing openai plugin.

Same gpt-image-2 tier catalog, same Codex Responses image_generation tool path, same reuse of _read_codex_access_token() / _codex_cloudflare_headers(). Keeping them as two independent providers means users can pick one or the other from hermes tools → Image Generation instead of one silently shadowing the other based on which auth happens to be present. Your PR was the basis for the implementation — credited in the commit body and PR description.

@teknium1 teknium1 closed this Apr 23, 2026
@Hygaard Hygaard deleted the fix/openai-image-provider-codex-auth branch April 23, 2026 06:27
ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
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
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
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
donald131 pushed a commit to donald131/hermes-agent that referenced this pull request May 2, 2026
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
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
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
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
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
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have tool/vision Vision analysis and image generation type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add Codex as an image generation backend

3 participants