Skip to content

fix(image-gen): Codex-auth images use the native images endpoints, no pinned chat model (#105398, #107076) - #111000

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-7470d356
Sep 14, 2026
Merged

teknium1 merged 1 commit into
mainfrom
hermes/hermes-7470d356

Conversation

@teknium1

Copy link
Copy Markdown
Collaborator

Image generation via ChatGPT/Codex OAuth no longer depends on a pinned chat model: the openai-codex provider now posts straight to the Codex backend's native images/generations / images/edits endpoints, the same route the official Codex client uses.

Root cause

The provider sent a Responses call to /backend-api/codex/responses with model: "gpt-5.5" plus a hosted image_generation tool, and let that chat model decide to call the tool. The chat model was only there to host the tool call, and it was hardcoded.

Changes

  • plugins/image_gen/openai-codex/__init__.py: POST images/generations (text-to-image) or POST images/edits (with images[] inline data URLs) using the OAuth token and codex_cloudflare_headers; body mirrors the official client's ImageGenerationRequest / ImageEditRequest (codex-rs/codex-api/src/images.rs). Deleted: _CODEX_CHAT_MODEL, the SSE parser, partial-frame handling, the no-tool-call retry loop, the tool_choice workaround. 428 → 293 lines.
  • Remote source URLs are fetched client-side and inlined: the backend's own downloader returns 400 Error while downloading file for ordinary public images (probed live).
  • Result carries reported_quality, reported_size, pixel_size alongside the requested values, plus imagegen_request_id (from x-codex-imagegen-request-id) for OpenAI support tickets.
  • Tests rewritten against the new contract via httpx.MockTransport (request path, body, headers, edit inlining, error surfacing, empty data). 467 → 250 lines.
  • Docs: image-generation.md (Codex note rewritten; 2.5 stance), image-gen-provider-plugin.md, plugin.yaml.

What this fixes

Symptom Before After
Accounts that lost gpt-5.5 (#105398, #107076) every image call HTTP 404: The model gpt-5.5 does not exist no chat model in the request; works regardless of plan's chat roster
Host model answers in text instead of calling the tool empty_response after 1 retry, or a smeared partial frame not possible; endpoint returns b64_json or an error
Request not honoured by backend (#107233) result echoed the catalog tier as if confirmed reported_quality / reported_size show what the backend actually did

GPT Image 2.5 on this provider (#106708, #106717, #107174, #108175)

Deliberately not added. Live probes with a real ChatGPT OAuth token, Sep 14:

Route Sent Backend did
/responses hosted tool model=gpt-image-2.5-sunburst quality=max size=1536x1024 echoed model=gpt-image-2-codex quality=auto size=auto
/images/generations model=gpt-image-2.5-sunburst quality=high size=1536x1024 quality=low size=1254x1254, PNG C2PA softwareAgent gpt-image version 2.0
/images/generations model=totally-not-a-model HTTP 200, identical result to the row above

The official client also hardcodes IMAGE_MODEL = "gpt-image-2" and exposes no selector (codex-rs/ext/image-generation/src/tool.rs); OpenAI tracks this at openai/codex#43965. A 2.5 tier here would be a label with no effect. 2.5 stays on the OpenAI API-key provider and FAL (#105988).

Live verification (real provider class, temp HERMES_HOME, real OAuth token)

T2I : success=True model=gpt-image-2-medium pixel_size=1370x1148 reported_quality=medium imagegen_request_id=ea4426ea-…
EDIT: success=True input_image_count=1 pixel_size=1254x1254 reported_quality=low  imagegen_request_id=90f6dd72-…
NEG : success=False error_type=invalid_image_input  (no request sent)

Also probed live: 6 source images on images/edits → 200; malformed body → 400 Missing required parameter: 'prompt' surfaces verbatim. The generated bicycle image was inspected: complete, non-smeared.

scripts/run_tests.sh tests/plugins/image_gen/ tests/tools/test_image_generation_plugin_dispatch.py tests/tools/test_image_generate_schema.py → 236 passed.

Supersedes #106362 (host-model retargeting; the host model is gone). Related: #107240 (metadata honesty; covered by reported_*), #108171 / #108174 (aspect mismatch; reported_size + pixel_size).

Infographic

infographic

… chat host model

The openai-codex image provider rode a Responses call with a hosted
image_generation tool on a pinned chat model (gpt-5.5). Two failure
classes came with that shape: when OpenAI withdrew gpt-5.5 from an
account cohort every image call 404'd while chat kept working
(#105398, #107076), and the host model was free to answer in text
instead of calling the tool, so we streamed SSE, kept partial frames
and retried on empty streams.

Post to chatgpt.com/backend-api/codex/images/generations and
images/edits instead - the route the official Codex client uses
(codex-rs/ext/image-generation). No host model, no SSE, no
partial-frame handling; the response is a plain JSON body with
b64_json. Remote source URLs are fetched client-side and inlined as
data URLs because the backend's own downloader 400s on ordinary
public images.

The backend treats model/quality/size as advisory (#107233), so the
result now reports reported_quality/reported_size next to the
requested values plus the x-codex-imagegen-request-id for support.
GPT Image 2.5 is deliberately not added to this catalog: the backend
accepts any model id, including nonexistent ones, and generates with
its server-managed engine (C2PA reports gpt-image 2.0), so a 2.5 tier
here would be a label with no effect (#106708).
@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 3daf0a7 — fix(image_gen): Codex-auth images use the native images endp

⚠️ Warnings

OSV vulnerability scan · View job

76 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 5m47s vs 5m16s (+9.8%). 6 job(s) slower, 7 faster, 2 unchanged.

  • OS-specific tests / Windows-only tests: +46.0s
  • Python tests / Run tests: +35.0s
  • Detect affected areas: -14.0s
  • Python tests / e2e: -7.0s
  • OS-specific tests / macOS-only tests: +7.0s

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins tool/vision Vision analysis and image generation provider/openai OpenAI / Codex Responses API labels Sep 14, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Related: #84415 (earlier closed attempt at the same native images-endpoint approach), #49008 (tool_choice HTTP 400 on the Responses route this PR removes). Fixes #105398 and #107076.

@teknium1
teknium1 merged commit 3275ca8 into main Sep 14, 2026
39 checks passed
@teknium1
teknium1 deleted the hermes/hermes-7470d356 branch September 14, 2026 17:18
This was referenced Sep 14, 2026
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 provider/openai OpenAI / Codex Responses API tool/vision Vision analysis and image generation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants