Skip to content

feat: support image generation via OpenRouter's dedicated image API#3786

Open
Robinnnnn wants to merge 2 commits into
chatboxai:mainfrom
Robinnnnn:openrouter-images-endpoint
Open

feat: support image generation via OpenRouter's dedicated image API#3786
Robinnnnn wants to merge 2 commits into
chatboxai:mainfrom
Robinnnnn:openrouter-images-endpoint

Conversation

@Robinnnnn

Copy link
Copy Markdown

What

Enables image generation through OpenRouter in the Image Creator.

  • src/shared/providers/definitions/models/openrouter.ts — implement getImageModel() on the OpenRouter model class (same pattern as the OpenAI/Azure providers), so the base class paint() works instead of throwing "Provider doesnt support image generation".
  • package.json / pnpm-lock.yaml — bump @openrouter/ai-sdk-provider from ^2.0.0 (lockfile resolved 2.1.1) to ^2.10.0. Since 2.5.0, the SDK's OpenRouterImageModel calls 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-added type: '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/images endpoint 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-provider exposes provider.imageModel(). The OpenRouter provider class was the only image-capable provider without a getImageModel() override.

How tested

  • pnpm test — full suite passes (93 files, 1092 tests).
  • npx tsc --noEmit — clean.
  • biome check on touched files — no new warnings.
  • Live end-to-end verification: exercised the exact changed code path (new OpenRouter(...).paint(...) with a real OpenRouter API key, redacted) against google/gemini-2.5-flash-image. Confirmed the request went to POST https://openrouter.ai/api/v1/images and a valid PNG was returned and decoded:
[fetch] POST https://openrouter.ai/api/v1/images
images returned: 1
data url prefix: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABAAA | length: 2740274

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
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 157e428c-3090-4424-a6de-054203b39fbe

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.
@Robinnnnn

Copy link
Copy Markdown
Author

@themez @cherishh @ryanwangtian would appreciate a review! 🙏

This adds image generation via OpenRouter's dedicated image API (POST /api/v1/images) — OpenRouter is already a chat provider here, this just implements the getImageModel() override (the only image-capable provider that was missing it) plus the Image Creator picker wiring, following the existing OpenAI/Gemini pattern.

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.

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