Skip to content

Quickstart

This deterministic example uses Pi’s faux provider, as the package tests do. It makes no network request and needs no credential.

import {
fauxAssistantMessage,
fauxProvider,
} from "@earendil-works/pi-ai/providers/faux";
import { mule } from "@fungi.computer/mule";
const faux = fauxProvider();
faux.setResponses([fauxAssistantMessage("pong")]);
const outcome = await mule.run(
{
model: faux.getModel(),
stream: (model, context, options) =>
faux.provider.streamSimple(model, context, options),
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.