Skip to content

Conversation

christian-bromann
Copy link
Member

backported from #8879

- Add support for OpenRouter's image generation API response format
- Extract images from OpenRouter's `choices[0].message.images` array
- Convert images to LangChain's Multimodal.Image content blocks
- Add unit tests for single image, multiple images, and text-only responses
- Use proper TypeScript types for content blocks

OpenRouter returns generated images in a separate `images` array rather than
within the message content. This fix ensures these images are properly
extracted and converted to LangChain's standard multimodal message format.

Fixes: #8791
Copy link

changeset-bot bot commented Sep 8, 2025

⚠️ No Changeset found

Latest commit: 13603a9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Sep 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
langchainjs-docs Ready Ready Preview Comment Sep 9, 2025 5:35pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langchainjs-api-refs Ignored Ignored Sep 9, 2025 5:35pm

@christian-bromann christian-bromann changed the title fix(openai): handle OpenRouter image generation responses fix(openai/0.x): handle OpenRouter image generation responses Sep 8, 2025
Copy link
Member

@hntrl hntrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything but the standard type change should be relevant for this PR also:

#8879 (review)

@christian-bromann
Copy link
Member Author

Updated PR in the same way as #8879

@christian-bromann christian-bromann merged commit 76400ae into main Sep 9, 2025
36 checks passed
@christian-bromann christian-bromann deleted the cb/openai-router-image-response-support-v0.x branch September 9, 2025 18:25
hntrl added a commit that referenced this pull request Oct 14, 2025
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.

2 participants