Skip to content

Feat: Support image model middleware #11546

@codylittle

Description

@codylittle

Description

Image models are some of the most cost and time expensive models available on the market currently.

The support of native middleware on image models would allow for semantic caching of image prompts.

Our immediate use case however, is the introduction of consistent safety guardrails across multiple model providers. Image generation models can pose a large organisational reputational risk due to reproductions of copyrighted works, or generation of explicit content.

Currently we're prefixing and suffixing AI sdk calls with our safety system for prompt analysis, prompt rewrite, and safety checking. However, native middleware support would be an excellent addition.

I'm more than happy to create a PR replicating the implementations from LanguageModels and EmbeddingModels, but am interested in if this would align with direction of the project.

AI SDK Version

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions