Add image generation support to OpenRouterProvider#333
Merged
pushpak1300 merged 3 commits intolaravel:0.xfrom May 1, 2026
Merged
Add image generation support to OpenRouterProvider#333pushpak1300 merged 3 commits intolaravel:0.xfrom
pushpak1300 merged 3 commits intolaravel:0.xfrom
Conversation
08c9a96 to
39f4b8a
Compare
Member
|
Can you fix merge conflicts and refactor to new namespace we have. i'm marking this draft once ready please mark this for review. |
OpenRouter's API supports image generation via chat/completions with the modalities parameter, but OpenRouterProvider only implemented EmbeddingProvider and TextProvider. This adds: - OpenRouterImageGateway: calls /api/v1/chat/completions with modalities: ["image", "text"] and parses base64 data URI responses - ImageProvider implementation on OpenRouterProvider with support for aspect_ratio via image_config - Tests for the gateway covering generation, aspect ratio, attachments, multiple images, and empty response handling Fixes laravel#330
39f4b8a to
ad23bdd
Compare
pushpak1300
approved these changes
May 1, 2026
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
This PR adds
ImageProvidersupport toOpenRouterProvider, allowing image generation through OpenRouter's unified API.OpenRouter supports image generation via the
/api/v1/chat/completionsendpoint using themodalitiesparameter (docs), butOpenRouterProvideronly implementedEmbeddingProviderandTextProvider, causing aLogicExceptionwhen attemptingImage::of()->generate(provider: Lab::OpenRouter).Changes
OpenRouterImageGateway— New gateway that sends image generation requests to OpenRouter's chat completions endpoint withmodalities: ["image", "text"], parses base64 data URI image responses, and maps them toGeneratedImageinstances.OpenRouterProvider— Now implementsImageProviderusing theGeneratesImagesandHasImageGatewaytraits. AddsdefaultImageModel()(google/gemini-2.5-flash-image),defaultImageOptions()(maps size toimage_config.aspect_ratio), andimageGateway().Usage
Fixes #330