Skip to content
Recipes

Test a model without credentials

Exercise the model loop with the public fauxModel helper.

A deterministic model helps test the orchestration around a provider. The public mule/testing helper supplies a Pi model and stream with queued replies, so the test makes no network request and needs no credential.

Install Mule in the ESM project from Quickstart:

TERMINAL
npm install @fungi.computer/mule
recipes/deterministic-model.ts
import { fauxAssistantMessage } from "@earendil-works/pi-ai/providers/faux";
import { mule } from "@fungi.computer/mule";
import { fauxModel } from "@fungi.computer/mule/testing";
/** Test the model-loop boundary without credentials or a network provider. */
export async function deterministicModelReply() {
const faux = fauxModel([fauxAssistantMessage("pong")]);
const outcome = await mule.run({
model: faux.model,
stream: faux.stream,
systemPrompt: "Reply once.",
messages: [{ role: "user", content: "ping", timestamp: 1 }],
});
return { outcome, calls: faux.state.callCount };
}

The result is one completed call containing pong. The package’s test/docs-model-example.test.ts runs this exact file and checks the reply and call count.

This exercises Mule’s model loop. It does not prove durable Session acceptance, restart recovery, billing or a real provider’s behavior. Those belong to the Shiitake host and provider tests. For the durable Session boundary, use the local Session quickstart with the public memoryHost helper.

For extension-owned behavior, start with Your first extension.