Repository navigation
Images API client and imagegen CLI (gpt-image-2.5) - #41
Conversation
Generate, edit (multipart) and batch via the OpenAI Images API with open model names (gpt-image-2.5-sunburst/flare, gpt-image-2), size validation, the model/quality/transparency rules, usage, typed errors with x-request-id, and a header reader for pixel size and alpha. The imagegen executable mirrors Codex's image_gen.py. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 81463873f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
I ran the live check on
I also ran these offline with
|
odrobnik
left a comment
There was a problem hiding this comment.
Follow-up review of b7077e9. I read the diff only and did not build or run anything. CI is green. I did not have the earlier review's findings, so I could not check each one individually. Instead I reviewed the new head as a whole, and the batch path claims, the 16-image edit cap and the dry-run validation look sound. One small correctness gap remains in size validation.
Findings:
- 🔵 Low
Sources/Providers/API/OpenAI/Image Generation/Images API/ImageSize.swift—ImageSize.dimensionslowercases the text and parses it withInt(...), sovalidate()accepts2048X1152and+1024x+1024. But the request sendsrawValueverbatim, becauseencode(to:)andformFields()do not normalise it. A size that passed client-side validation therefore reaches the API in a non-canonical form. The API may reject it with a server error, which defeats the 'no request is sent on a violation' guarantee. The test2048X1152even asserts that the uppercase form parses. Fix: require ASCII digits and a lowercasexindimensions, or normaliserawValuetoWxHoninit.
To unblock the merge, address every finding: react with 👍 if it is accurate (👎 if not), reply with a brief comment on what was fixed, and mark the item as resolved.
Reviewed by Claude
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
odrobnik
left a comment
There was a problem hiding this comment.
Follow-up review of 6806ff5. I read the diff only and did not build or run anything. CI is green, and the operator's live check is on the PR.
The 'canonical WxH sizes' commit closes the gap raised last round. ImageSize.dimensions now accepts only ASCII digits, a lowercase x and digits, with no empty parts. 2048X1152, +1024x+1024 and 1024x1024x2 all return nil, so validate() rejects them and no non-canonical size is sent. A combining-mark character that slips through the "0"..."9" range check still fails Int(...), which returns nil, so it is rejected too. The tests now assert these cases.
This commit does not touch the batch dry-run validation, the path claims from rejected batch plans, --json for batch dry runs or the 16-image edit cap. I did not re-inspect them this round. I found no regressions in what changed, and nothing here loses data or leaves unrecoverable state.
👍 No findings.
Reviewed by Claude
Resolves #40.
What
Image Generationcode:OpenAI.generateImages(_:)(/v1/images/generations),editImages(_:)(/v1/images/edits, multipart,image[]+ optional mask, neverinput_fidelity) andgenerateImageBatch(_:concurrency:)(JSONL jobs, bounded concurrency, a result per job).ImageModel(gpt-image-2.5-sunburstdefault,gpt-image-2.5-flare,gpt-image-2; unknown names pass through),ImageSize(auto/WxH, validated: multiples of 16, longest side ≤ 3840, aspect 1:3–3:1, 655,360–8,294,400 px; above 2560×1440 allowed with an "experimental" note), openImageQuality(xhigh/maxonly on 2.5), transparency rules (2.5 only, not jpeg), compression (jpeg/webp, 0–100).b64_json,usageand the echoed size/quality/background/output_format; API errors becomeImageGenerationError.api(ImageAPIError)carryingx-request-id.ImageInforeads real pixel size and alpha from PNG/JPEG/WebP headers (no AppKit);MultipartFormDatalives in Providers. Foundation-only, so it builds on every platform.OpenAI(credential:)); the client never reads files or the environment.generateImage(prompt:model:)still compiles and is deprecated in favour ofgenerateImages(_:).imagegenexecutable (Examples/ImageGen, ArgumentParser, Providers only) withgenerate,edit,generate-batch;--dry-run,--json,--force,--npath suffixes,--api-key-file, size presets (1080p→1920x1088,1440p,4k, each-portrait).Dry run
Verification
swift build --build-testsand the fullswift testpass locally (322 + 8 tests); SwiftLint--strictis clean.usage, error mapping withx-request-id, batch concurrency, and header parsing.OPENAI_API_KEYin this environment, soImagesLiveTests(low generate on flare and sunburst at 1536x864, plus a transparent png checking alpha) have not run. The operator needs to run them; they use at most threelowimages.🤖 Generated with Claude Code
Added the Images API client (generate, edit, batch, validation, usage, typed errors) to Providers and an
imagegenCLI next to Coder. Offline tests and lint pass locally. The live tests were skipped because there was no OPENAI_API_KEY, so the operator needs to run them.