Skip to content

fix(codex): align image client version with model discovery - #3851

Open
Jordannst wants to merge 1 commit into
decolua:masterfrom
Jordannst:fix/codex-image-version-3846
Open

Jordannst wants to merge 1 commit into
decolua:masterfrom
Jordannst:fix/codex-image-version-3846

Conversation

@Jordannst

@Jordannst Jordannst commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Align the existing Codex image adapter's advertised client version with model
discovery. This fixes the reproducible GPT-5.6 image request version rejection
without changing the requested model, image tool payload, or authentication.

Related to #3846 and the requires a newer version of Codex error in #3829.
This does not claim to fix the separate gpt-image-2 account/model rejection.

Root cause

On master (eb712ca8, v0.5.69), model discovery already requests the Codex catalog
with client_version=0.144.6. Image requests independently hardcode both
version: 0.136.0 and user-agent: codex_cli_rs/0.136.0.

The official Codex manifest specifies minimal_client_version: 0.144.0 for
gpt-5.6-sol, gpt-5.6-terra, and gpt-5.6-luna:
pinned upstream manifest.

Thus discovery advertises newer models, but generation identifies itself as an
older client. Updating a user's locally installed Codex CLI cannot change those
hardcoded 9router request headers.

Changes

  • Move the existing discovery version 0.144.6 to open-sse/config/codexConstants.js.
  • Derive both image identity headers from that shared value.
  • Import the constant into model discovery without changing its effective URL/version.
  • Update the four parameterized image handler cases to check both headers;
    retain checks for bearer/account authentication, suffix removal, image tool
    payload, and SSE image extraction.

The version is the one master already uses for discovery, not an arbitrary
latest-version bump. A future update of the shared constant updates both paths.

Live A/B verification

Tested on 2026-09-07 using two authenticated Codex accounts and six requests.
Within each pair, the account, model, prompt, body, and all other headers were
identical. Only version and user-agent changed. The baseline used the current
adapter with its headers overridden to master's values; the patched arm used
the new values. Credentials remained in process memory and are not included in artifacts.

Prompt: Generate a solid green square. Output format: PNG.

Image alias Baseline 0.136.0 Patched 0.144.6
gpt-5.6-luna-image HTTP 400, newer Codex version required HTTP 200, decoded PNG 1254x1254
gpt-5.6-sol-image HTTP 400, newer Codex version required HTTP 200, decoded PNG 1254x1254
gpt-5.6-terra-image HTTP 400, newer Codex version required HTTP 200, decoded PNG 1254x1254

The image adapter's SSE parser extracted each image, then sharp
fully decoded it to raw pixels. Success was not inferred from HTTP 200 alone.
These probes exercised request construction and parsing directly, not the
dashboard, account failover, or the complete public HTTP route.

Separate gpt-image-2 check

With the patched 0.144.6 headers, gpt-image-2 returned HTTP 400 on both tested Codex accounts: "not supported when using Codex with a ChatGPT account". A control request using gpt-5.6-luna-image on the same account returned HTTP 200 with a fully decoded 1254x1254 PNG. This confirms a separate upstream rejection for the tested model/endpoint/account combination, not the client-version error fixed here; no gpt-image-2 remapping or support is claimed.

Automated verification

./tests/node_modules/.bin/vitest run --config tests/vitest.config.js \
  tests/unit/image-generation.test.js \
  tests/unit/codex-image-models.test.js \
  tests/unit/provider-test-models-routing.test.js
  • Before patch: updated image suite had 4 failures and 16 passes; failures showed
    the outbound 0.136.0 headers.
  • After patch: all three suites pass, 27/27.
  • ESLint on changed files: zero errors, one existing anonymous-default-export warning.
  • git diff --check: passed.

Scope and related work

@kienmatu

kienmatu commented Sep 8, 2026

Copy link
Copy Markdown

This is a critical fix, please prioritise it

@kuravista

Copy link
Copy Markdown

go merge it

Qurtison pushed a commit to Qurtison/9router that referenced this pull request Sep 8, 2026
@deadcoder0904

Copy link
Copy Markdown

Woud love this. Does this target gpt-image-2.5 too???

@Jordannst

Copy link
Copy Markdown
Contributor Author

This PR only fixes the Codex client version headers, it doesn’t explicitly select GPT-Image-2.5. Image generation works in my tests, but the responses don’t identify the image model, so I’m not able to confirm 2.5 support yet.

@deadcoder0904

Copy link
Copy Markdown

@Jordannst #3943 supports it now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants