Skip to main content
The generate() method provides complete control over text generation with detailed performance metrics and customizable options.

Basic Usage

Method Signature

Parameters

Returns

An LLMGenerationResult containing the response and metrics.

LLMGenerationResult

LLMGenerationOptions

Generation Parameters

Examples

Basic Generation

With Custom Options

With System Prompt

For Reasoning Models

Some models output their reasoning process. Extract it with thinkingContent:

Performance Monitoring

Structured Output

Generate type-safe structured output using the Generatable protocol:

Error Handling

Temperature Guide

generateStream()

Stream tokens in real-time →

System Prompts

Control model behavior →