Genkit JS API reference
    Preparing search index...

    Interface GenerateMiddleware<ConfigSchema, PluginOptions>

    Defines a Genkit Generate Middleware instance, which can be configured and registered. When invoked with an optional configuration, it returns a reference suitable for inclusion in a GenerateOptions.use array.

    interface GenerateMiddleware<
        ConfigSchema extends z.ZodTypeAny = z.ZodTypeAny,
        PluginOptions = void,
    > {
        configSchema?: ConfigSchema;
        description?: string;
        instantiate: (
            options: MiddlewareFnOptions<ConfigSchema, PluginOptions>,
        ) => GenerateMiddlewareDef;
        metadata?: Record<string, any>;
        name: string;
        plugin: (pluginOptions: PluginOptions) => GenkitPluginV2;
        toJson: () => {
            configSchema?: Record<string, any>
            | null;
            description?: string;
            metadata?: Record<string, any> | null;
            name: string;
        };
        (config?: z.TypeOf<ConfigSchema>): any;
    }

    Type Parameters

    Hierarchy (View Summary)

    • Configures the middleware, returning a MiddlewareRef for usage in generate({use: [...]}).

      Parameters

      Returns any

    Index

    Properties

    configSchema?: ConfigSchema

    An optional Zod schema for validating the middleware's configuration.

    description?: string

    An optional description of what the middleware does.

    instantiate: (
        options: MiddlewareFnOptions<ConfigSchema, PluginOptions>,
    ) => GenerateMiddlewareDef

    Factory function that receives the validated configuration and creates a GenerateMiddlewareDef holding the active hooks.

    metadata?: Record<string, any>

    Metadata describing this middleware.

    name: string

    The unique name of this middleware.

    plugin: (pluginOptions: PluginOptions) => GenkitPluginV2

    Optional plugin wrapper exposing this middleware for framework-level registration.

    toJson: () => {
        configSchema?: Record<string, any>
        | null;
        description?: string;
        metadata?: Record<string, any> | null;
        name: string;
    }

    Generates a JSON-compatible representation of the middleware metadata.