Open Agent Loops
API Reference

ModelClient

@open-agent-loops/core


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

ParameterTypeDescription
requestModelRequestThe system prompt, history, and tools for this turn.

Returns

ModelStream

An async iterable of StreamEvents for the assistant turn.

On this page