Genkit JS API reference
    Preparing search index...

    Interface MockModelOptions

    Options for mockModel.

    interface MockModelOptions {
        info?: {
            configSchema?: Record<string, any>;
            label?: string;
            stage?: "stable" | "unstable" | "featured" | "legacy" | "deprecated";
            supports?: {
                constrained?: "all" | "none" | "no-tools";
                contentType?: string[];
                context?: boolean;
                media?: boolean;
                multiturn?: boolean;
                output?: string[];
                systemRole?: boolean;
                toolChoice?: boolean;
                tools?: boolean;
            };
            versions?: string[];
        };
        name?: string;
        respond?: MockRespond;
    }
    Index

    Properties

    Properties

    info?: {
        configSchema?: Record<string, any>;
        label?: string;
        stage?: "stable" | "unstable" | "featured" | "legacy" | "deprecated";
        supports?: {
            constrained?: "all" | "none" | "no-tools";
            contentType?: string[];
            context?: boolean;
            media?: boolean;
            multiturn?: boolean;
            output?: string[];
            systemRole?: boolean;
            toolChoice?: boolean;
            tools?: boolean;
        };
        versions?: string[];
    }

    Model metadata (e.g. supports, versions).

    supports.constrained defaults to 'all' (native constrained generation), so a generate with an output.schema reaches respond with that schema on request.output.schema. Pass supports: { constrained: 'none' } to instead exercise the framework's simulated path, where the schema is injected into the prompt (and thus visible in lastRequestText) and stripped from what respond sees.

    name?: string

    Registered model name. Defaults to 'mockModel'.

    respond?: MockRespond

    What to respond with on each generate call. Defaults to empty text.

    • A single response (string / object) is returned on every call.
    • A callback (request, { sendChunk }) => response is invoked once per call, so you can branch on request history (for tool loops) and stream via sendChunk.
    • An array is a queue consumed one item per call, with the last item repeating once exhausted — handy for scripted multi-turn tests. A queued Error is thrown when reached, to inject a failure on a given turn. (Queued items are static, so streaming needs the callback form.)
    mockModel(ai, { respond: 'always this' });
    mockModel(ai, { respond: ['first', 'second'] });
    mockModel(ai, { respond: ['ok', new Error('rate limited')] });