Genkit JS API reference
    Preparing search index...

    Function echoModel

    • A mockModel preset for text paths: a zero-config model that echoes the rendered request back as text, for asserting prompt and message assembly (what the model would have seen). Supports the same inspection members as mockModel.

      const model = echoModel(ai);
      const res = await ai.generate({ model, system: 'Be terse', prompt: 'hi' });
      assert.match(res.text, /system: Be terse/);

      Because it returns text, it can't satisfy a structured output schema — Genkit derives output by parsing the response text and validating it, which prose can't pass. If the request carries an output schema, echoModel throws an explanatory error. For structured-output paths, use mockModel with a conforming response and assert assembly via MockModel.lastRequestText / MockModel.lastRequest instead.

      Parameters

      • registry: Registry | HasRegistry

        a Genkit instance (or anything holding a Registry).

      • Optionaloptions: EchoModelOptions

        model name and metadata.

      Returns MockModel