fix(baoyu-image-gen): align OpenRouter image generation with current API#101
fix(baoyu-image-gen): align OpenRouter image generation with current API#101JimLiu merged 4 commits intoJimLiu:mainfrom
OpenRouter image generation with current API#101Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1af984a64f
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efb7a1917a
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96ef6e2251
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e43eec260a
ℹ️ 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".
| function getModalities(model: string): string[] { | ||
| return isGeminiImageModel(model) ? ["image", "text"] : ["image"]; |
There was a problem hiding this comment.
Recognize non-Gemini OpenRouter models that need text output
getModalities() now treats every non-Gemini model as image-only. The skill explicitly accepts arbitrary OpenRouter model IDs (skills/baoyu-image-gen/SKILL.md:258-263), and OpenRouter's openai/gpt-5-image quickstart documents that model as requiring modalities: ["image", "text"]. In that scenario this provider will send modalities: ["image"], so requests for GPT-5 Image (and similar non-Gemini multimodal image models) can be rejected before any image is returned.
Useful? React with 👍 / 👎.
| const inferred = inferAspectRatio(args.size); | ||
| if (!inferred || !getSupportedAspectRatios(model).has(inferred)) { | ||
| return null; |
There was a problem hiding this comment.
Fail when
--size maps to an unsupported OpenRouter ratio
getAspectRatio() now drops any inferred ratio that is not in the supported set, but buildRequestBody() still forwards the inferred image_size. For inputs like --size 1000x500, that means the request keeps image_size: "1K" while omitting aspect_ratio, and OpenRouter falls back to its default 1:1 output instead of anything close to the requested landscape size. This silently turns an explicit size request into the wrong dimensions; if a ratio cannot be represented, the CLI should error or map it to a supported ratio instead of discarding it.
Useful? React with 👍 / 👎.
Summary
Fix OpenRouter image generation in
baoyu-image-gento match the current OpenRouter API.Changes
imageGenerationOptionstoimage_configcontentfor text-only image generationcontentwhen reference images are providedfinish_reasonin no-image errors for easier debuggingWhy
The previous OpenRouter request format could return
No image in OpenRouter responsefor image-capable models such asgoogle/gemini-3.1-flash-image-preview.Verification
node --import tsx --test "skills/baoyu-image-gen/scripts/providers/*.test.ts"All provider tests passed locally.