Overview
Thegenerate() method provides full control over text generation with customizable options and detailed performance metrics. Use this for production applications where you need fine-grained control.
Basic Usage
API Reference
Parameters
Returns
Generation Options
Temperature
Controls randomness in the output. Lower values make output more focused and deterministic.| Temperature | Use Case |
|---|---|
| 0.0–0.3 | Factual, deterministic responses |
| 0.4–0.7 | Balanced, general-purpose |
| 0.8–1.2 | Creative, varied outputs |
| 1.3–2.0 | Very creative, experimental |
Max Tokens
Limits the length of the generated response.Stop Sequences
Stop generation when specific sequences are encountered.System Prompts
Define the AI’s behavior and persona.Examples
Full Example with Metrics
React Hook
useGenerate.ts