API Reference
ModelClient
Defined in: model.types.ts:148
The single LLM boundary the loop depends on.
Remarks
The loop never talks to a provider directly — it only depends on this interface, so any backend (mock, OpenAI-compatible, Anthropic, raw fetch) can be plugged in by implementing stream.
Example
const echo: ModelClient = {
async *stream(request) {
const message: AssistantMessage = { role: Role.Assistant, content: "hi" };
yield { type: StreamEventType.TextDelta, text: "hi" };
yield { type: StreamEventType.Done, message };
},
};Methods
stream()
stream(request): ModelStream;Defined in: model.types.ts:155
Begin a streaming completion. Implementations MUST stream by default.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | ModelRequest | The system prompt, history, and tools for this turn. |
Returns
An async iterable of StreamEvents for the assistant turn.