feat(ai): image model middleware#11547
Merged
lgrammel merged 4 commits intovercel:mainfrom Jan 6, 2026
Merged
Conversation
lgrammel
reviewed
Jan 6, 2026
| @@ -0,0 +1,6 @@ | |||
| --- | |||
| '@ai-sdk/provider': patch | |||
Collaborator
There was a problem hiding this comment.
ugh. changing the provider package is potentially problematic. since this is file-additive it might be fine, but we need to watch for versioning issues in the coming days.
cc @gr2m
Contributor
Author
There was a problem hiding this comment.
Cheers for approving, just for future reference, why is this problematic? We have another feature branch we're working on which proposes some changes to the provider package.
Collaborator
There was a problem hiding this comment.
In the past there have been issues when people had multiple @ai-sdk/provider packages with different versions installed. I will keep an eye out for that, if it happens again we may need to freeze any changes to @ai-sdk/provider in a given major release.
lgrammel
approved these changes
Jan 6, 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.
Background
The ability to run middleware on ImageModels to support semantic caching or safety guardrails without requiring adhoc implementations is desirable. Extend wrapProvider to accept newly created ImageModelMiddleware for consistent implementation as LanguageModelMiddleware
Summary
Added ImageModelV3Middleware to @ai-sdk/provider (packages/provider/src/image-model-middleware/v3/image-model-v3-middleware.ts)
Added wrapImageModel to ai (packages/ai/src/middleware/wrap-image-model.ts) and ImageModelMiddleware alias (packages/ai/src/types/image-model-middleware.ts).
Extended middleware plumbing to support images in wrapProvider (packages/ai/src/middleware/wrap-provider.ts) and createProviderRegistry (packages/ai/src/registry/provider-registry.ts).
Tests: new wrapImageModel suite (packages/ai/src/middleware/wrap-image-model.test.ts) + updated registry/provider wrapper tests.
Docs: added Image Middleware section (content/docs/03-ai-sdk-core/35-image-generation.mdx), new reference page (content/docs/07-reference/01-ai-sdk-core/61-wrap-image-model.mdx)
Manual Verification
Manually built and implemented migrated our existing middleware approach to use new middleware implementation
Checklist
pnpm changesetin the project root)Future Work
Create a
defaultImageSettingsMiddlewareto be used for reference implementation.Extend wrapProvider to accept wrapping embedding models too
Related Issues
Resolves #11546