Skip to main content
Generate text with detailed metrics including latency, token count, and generation speed.
options is the second positional parameter: generate(String prompt, [LLMGenerationOptions? options]).

LLMGenerationOptions

LLMGenerationOptions is a protoc-gen-dart message. It has no const constructor, so build it with the generated named-parameter constructor or with cascade setters:
Other fields on the message include seed, minP, frequencyPenalty, presencePenalty, repeatLastN, nThreads, grammar, jsonSchema, disableThinking, thinkingPattern, structuredOutput, and toolCalling.

LLMGenerationResult

Optional proto fields default to the zero value rather than null, so use the generated hasX() guards when the distinction matters.

Thinking Models

Some models emit “thinking” tokens for chain-of-thought reasoning. Declare support when you register the model:
Set LLMGenerationOptions.disableThinking = true to suppress the reasoning phase for a single call.

See Also

chat()

Simple one-liner

generateStream()

Stream tokens in real-time