generateStream method

Stream<GenerationEvent> generateStream(
  1. String prompt, {
  2. LlmOptions? options,
})

Stream a completion for prompt token by token.

When options puts tools in play the turn arrives as a single token event: the tool-execution loop has no incremental native stream.

await for (final e in RunAnywhere.llm.generateStream('Say hello')) {
  if (e is GenerationToken) stdout.write(e.text);
}

Throws SDKException into the consumer when generation fails.

Implementation

Stream<GenerationEvent> generateStream(
  String prompt, {
  LlmOptions? options,
}) => _stream(() => _request(prompt: prompt, options: options));