Skip to content

[codex] fix Codex image generation transport#3383

Draft
cyeinfpro wants to merge 1 commit into
Wei-Shaw:mainfrom
cyeinfpro:codex/fix-codex-image2-direct
Draft

[codex] fix Codex image generation transport#3383
cyeinfpro wants to merge 1 commit into
Wei-Shaw:mainfrom
cyeinfpro:codex/fix-codex-image2-direct

Conversation

@cyeinfpro

Copy link
Copy Markdown

What changed

This PR routes OpenAI OAuth image generation/edit requests through ChatGPT's dedicated Codex images endpoints instead of the Responses API image tool path.

  • Use /backend-api/codex/images/generations and /backend-api/codex/images/edits for OAuth image accounts.
  • Preserve native image request fields such as size, quality, background, output_format, output_compression, and n.
  • Normalize Codex image responses back into the existing OpenAI Images API shape.
  • Convert URL-only upstream image outputs to b64_json when requested by downstream clients.
  • Preserve synthetic SSE compatibility for downstream stream: true callers.

Why

The previous OAuth image path wrapped image requests inside the Responses API image-generation tool. That path did not reliably preserve native gpt-image-2 behavior, especially large output sizes such as 3840x2160, and it made multi-image n handling depend on the Responses tool wrapper.

The dedicated Codex images endpoint accepts the native image payload directly, so gpt-image-2 2K/4K requests and n are passed to the upstream service without being translated into tool arguments.

Validation

  • go test -tags unit ./internal/service -run 'TestOpenAIGatewayServiceForwardImages|TestOpenAIGatewayServiceParseOpenAIImagesRequest|TestBuildOpenAIImagesURL'
  • Live deployment smoke tested separately with gpt-image-2 4K generation returning 3840x2160.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement (CLA).

To sign, please reply with the following comment:

I have read the CLA Document and I hereby sign the CLA

You only need to sign once — it will be valid for all your future contributions to this project.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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.

1 participant