feat(images): support JSON edit requests#222
Merged
Merged
Conversation
Mount the image generation and edit paths Codex appends to its configured model-provider base. Reuse the public generation handler and translate Codex's JSON multi-image edit request into the shared multipart image-edit execution path. Preserve original request bytes for dump capture, validate the Codex edit envelope and base64 image URLs, and document the namespaced route surface with pinned Codex sources.
Accept Codex edit inputs from inline or remote image URLs, validate their actual raster format, and reuse the hosted image shim's edit transcoding path. This keeps standalone and hosted image edits aligned while preserving the provider-relative JSON adapter.
Avoid copying complete image buffers in the provider-relative edit adapter and tighten the route contract descriptions.
Canonicalize supported MIME aliases during edit preparation and carry only prepared PNG, JPEG, or WebP sources into multipart construction. Model generation and edit calls as distinct requests so raw image sources cannot reach the edit wire builder.
Keep MIME canonicalization and transcoding-deduplication tests with the shared edit-source module, and keep its MIME helper private to that module.
9 tasks
Treat the current application/json Images Edits request as a first-class public wire shape alongside multipart uploads. Preserve JSON image_url, file_id, and mask references through provider dispatch, and mount the same generation and edit handlers under the Codex provider base.
Normalize JSON references and multipart uploads into a homogeneous Images Edits request. Providers now choose JSON for image_url/file_id references and multipart for uploaded files, preserving Codex wire behavior without downloading URLs or base64-encoding binary uploads.
Preserve unknown JSON-reference fields, model upload parameters as scalar values, and type hosted edit sources after MIME preparation. Keep request builders private and verify their observable provider requests through integration tests.
Separate scalar upload parameters from opaque JSON parameters, preserve unknown reference fields and nullable wire values, and keep post-materialization hosted-tool state typed. Serialize single uploads with the canonical image field while retaining image[] for multiple uploads.
Decode base64 data URLs into the upload source variant and keep one semantic truth per image. Providers prefer multipart for upload-only requests, use JSON for references, and encode uploads from bytes only when a mixed request requires JSON.
Represent uploaded files, inline data URLs, and external references as separate single-truth IR variants. The shared OpenAI serializer emits multipart for upload-like scalar requests and JSON for reference or mixed requests, decoding or encoding only at the provider wire boundary.
Choose multipart only after every source and parameter is known to be form-safe. Preserve inline reference extensions through JSON and defer base64 decoding until the complete request qualifies for multipart.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
application/jsonImages Edits request alongside multipart uploads at the public/images/editsroutes/azure-api.codexRollout order
Merge and deploy this PR before #223. This PR adds the server surface that the generated
requires_openai_auth = trueconfiguration activates.Test plan
pnpm run test(352 test files, 4314 tests)pnpm run lintpnpm run typecheck