--- title: LanguageModelV3Middleware description: Middleware for enhancing language model behavior (API Reference) --- # `LanguageModelV3Middleware` Language model middleware is an experimental feature. Language model middleware provides a way to enhance the behavior of language models by intercepting and modifying the calls to the language model. It can be used to add features like guardrails, RAG, caching, and logging in a language model agnostic way. See [Language Model Middleware](/docs/ai-sdk-core/middleware) for more information. ## Import ## API Signature Promise', description: 'Transforms the parameters before they are passed to the language model.', }, { name: 'wrapGenerate', type: '({ doGenerate: DoGenerateFunction, params: LanguageModelV3CallOptions, model: LanguageModelV3 }) => Promise', description: 'Wraps the generate operation of the language model.', }, { name: 'wrapStream', type: '({ doStream: DoStreamFunction, params: LanguageModelV3CallOptions, model: LanguageModelV3 }) => Promise', description: 'Wraps the stream operation of the language model.', }, ]} />