Optional groundingCitation verdicts after text completes, when enabled on a default-runtime session.
Async iterable that yields only raw text-delta strings (filters out non-text parts).
Async iterable that yields all StreamPart events in order.
Resolves to the assembled assistant reply when the stream completes: the text of the latest step that produced any. A stream that ends mid-step, on an error after output or because the consumer stopped reading, resolves to the text that step delivered.
Resolves to aggregated TokenUsage when the stream completes.
Provider-reported model id of the final step (may differ from the
requested/resolved id across aliases and fallback hops; spec batch-1
C1). Settles on every terminal path — normal completion, fallback,
error, early abandonment — and is undefined when no chunk reported a
model id. The existing model-related fields keep their meaning.
Provider-reported service tier the final step actually ran at (OpenAI;
spec batch-1 C2). Settles on every terminal path; undefined when no
chunk reported a tier.
Resolves to the ordered list of ToolCallRecords when the stream completes.
Resolves to the resolved provider id (e.g. openrouter, anthropic)
once the stream has started. Available eagerly because routing happens
before the first chunk; exposed as a Promise so the type lines up with
the rest of this contract and so callers don't see undefined while the
stream is still spinning up. Used by wilds-ai's [llm-call] telemetry
line for per-step latency attribution (production fix 2026-05-05:
narrator-stream rows were logging provider=unknown model=unknown,
which made model-routing audits significantly harder).
Resolves to the resolved model id once the stream has started.
Optional fallbackThe failover trail, resolved when the stream ends: fired is true when a
fallback leg served or was tried; finalProvider / finalModel name the
run that answered; undefined only when the stream ended before routing.
Optional in the type, so an object typed as StreamTextResult without it
still compiles; streamText always sets it.
Resolves to the reason the FINAL model step stopped emitting, on the same cadence as usage (when the stream completes):
'stop' — natural end of turn (or an unknown provider vocabulary).'length' — the provider's output token cap cut the text off; the
assembled reply is TRUNCATED mid-thought. Hosts that persist or
cache streamed prose as canonical should branch on this before
doing so (wilds-ai narrator truncation guard, 2026-07-08).'tool-calls' — the run ended with outstanding tool calls and no
final text (maxSteps exhaustion).'error' — the stream emitted an error part.Historically the streaming surface discarded the provider's reason
and fabricated 'stop'; the provider layer always had it (final
chunk choices[0].finishReason; Anthropic maps max_tokens →
length in its adapter). Settled via the generator's cleanup on
early abandonment too, so awaiting it after a partial consume does
not hang. On a stream the consumer abandoned it does not say why the
stream ended: it reports the latest step that finished. The
prompt-shim tool-emulation path reports 'stop' (its internal calls
do not thread per-step reasons).
Cache-diagnostics verdict of the FINAL step (Anthropic beta; see
GenerateTextOptions.cacheDiagnostics). Resolves when the stream
completes: null when the run did not opt in, when the provider sent no
verdict, or when the compared requests did not diverge; a populated
cacheMissReason names the earliest divergence. Settled in the
generator's cleanup too, so awaiting after early abandonment never hangs.
Provider message id (msg_...) of the FINAL step; null when the run
did not opt into cache diagnostics or the provider sent no id. Persist it
and pass it back as the next request's
cacheDiagnostics.previousMessageId to thread the comparison across
turns (the wilds-ai narrator threads it per session).
The object returned immediately by streamText.
Consumers iterate
textStreamfor raw token deltas orfullStreamfor all event types; the promise properties settle once that iteration has drained the stream, and awaiting one of them alone starts no request.