feat: support image generation via OpenRouter's dedicated image API#3786
feat: support image generation via OpenRouter's dedicated image API#3786Robinnnnn wants to merge 2 commits into
Conversation
Adds an image-model factory to the OpenRouter provider so the Image Creator can generate images through OpenRouter. Bumps @openrouter/ai-sdk-provider to ^2.10.0, whose OpenRouterImageModel uses the dedicated POST /api/v1/images endpoint (image-generation requests were previously routed through /chat/completions). - OpenRouter model class: implement getImageModel() so paint() works - Provider defaults: list current image-capable OpenRouter models - useImageModelGroups: surface OpenRouter image models (default + user-added type=image models) in the Image Creator model picker
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Broaden the out-of-box image model set from 3 to 8 flagship models spanning the major image providers on OpenRouter (Google, OpenAI, ByteDance, Black Forest Labs, Sourceful, Recraft). Users can still add any other OpenRouter image model manually via provider settings.
|
@themez @cherishh @ryanwangtian would appreciate a review! 🙏 This adds image generation via OpenRouter's dedicated image API ( I also pushed a follow-up commit expanding the default image model set from 3 to 8 flagship models across the major providers (Google, OpenAI, ByteDance, Black Forest Labs, Sourceful, Recraft); users can still add any other OpenRouter image model manually. Tests green, biome clean, and typecheck is clean on the changed files. Happy to adjust the curated list if you'd prefer a different default set. |
What
Enables image generation through OpenRouter in the Image Creator.
src/shared/providers/definitions/models/openrouter.ts— implementgetImageModel()on the OpenRouter model class (same pattern as the OpenAI/Azure providers), so the base classpaint()works instead of throwing "Provider doesnt support image generation".package.json/pnpm-lock.yaml— bump@openrouter/ai-sdk-providerfrom^2.0.0(lockfile resolved 2.1.1) to^2.10.0. Since 2.5.0, the SDK'sOpenRouterImageModelcalls OpenRouter's dedicated image endpoint (POST /api/v1/images) instead of wrapping/chat/completions, which gives correct image-generation routing/usage semantics, multiple images per call, and reference-image (image-to-image) support. Lockfile diff is kept minimal (only this package changed).src/shared/providers/definitions/openrouter.ts— add the currently image-capable OpenRouter models (type: 'image') to the provider defaults.src/renderer/hooks/useImageModelGroups.ts— surface OpenRouter in the Image Creator model picker: default image models plus any user-addedtype: 'image'models, following the existing OpenAI/Gemini group logic.src/shared/providers/definitions/models/openrouter.test.ts— new unit tests covering the image path (asserts the dedicated/api/v1/imagesendpoint is called and data URLs are produced).Why
Chatbox users with an OpenRouter key currently have no way to generate images, even though OpenRouter serves image models (Gemini image models, GPT image models, etc.) and the already-bundled
@openrouter/ai-sdk-providerexposesprovider.imageModel(). The OpenRouter provider class was the only image-capable provider without agetImageModel()override.How tested
pnpm test— full suite passes (93 files, 1092 tests).npx tsc --noEmit— clean.biome checkon touched files — no new warnings.new OpenRouter(...).paint(...)with a real OpenRouter API key, redacted) againstgoogle/gemini-2.5-flash-image. Confirmed the request went toPOST https://openrouter.ai/api/v1/imagesand a valid PNG was returned and decoded: