Skip to content
Quickstart

Quickstart

Effect-native Pi model and tool loop

This deterministic example uses the public testing helper. It makes no network request and needs no credential.

quickstart.ts
import { fauxAssistantMessage } from "@earendil-works/pi-ai/providers/faux";
import { mule } from "@fungi.computer/mule";
import { fauxModel } from "@fungi.computer/mule/testing";
const faux = fauxModel([fauxAssistantMessage("pong")]);
const outcome = await mule.run(
{
model: faux.model,
retryable: faux.retryable,
stream: faux.stream,
systemPrompt: "Reply once.",
messages: [{ role: "user", content: "ping", timestamp: 1 }],
},
() => {},
);
console.log(outcome.status);

The result is completed. No active stream remains when the awaited run settles. The test helper uses this provider and input shape, and facade tests compare Promise and Effect lifecycles. This fake provider checks orchestration rather than a real supplier.

For a real model, supply Pi’s Model<Api> and either its normal streamSimple or an explicit provider stream. The host supplies credentials and billing. Await the listener: its completion is part of the run’s lifecycle.