generate

abstract fun generate(prompt: String? = null, messages: List<ModelMessage> = emptyList(), options: TContext? = null, abortSignal: AbortSignal = AbortSignalNever): Flow<GenerateResult<TOutput>>(source)

One-shot generation. Either prompt or messages (or both) must be supplied. When both are present, prompt is appended as a trailing user message.

To observe lifecycle events, collect ToolLoopAgent.events (a Flow<AgentEvent>) — there is no callback parameter.

Cold flow: no model call or tool execution starts until collected. Each collection reruns the full generation from the beginning; for tool-loop agents that includes tool executions and their side effects, and every collection may incur provider cost/billing. One-shot callers should collect exactly one value, usually with .first().

Since

0.3.0-beta01