Skip to main content
Early Beta — The Web SDK is in early beta. APIs may change between releases.

Overview

The generate() 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.

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.
See System Prompts for more details.

Examples

Full Example with Metrics

Thinking Models

Some models support “thinking” or reasoning before responding:

Cancellation

Cancel an ongoing generation:

Simple Generation

Quick generation interface

Streaming

Real-time token streaming

System Prompts

Control AI behavior

Best Practices

Optimization tips