Skip to main content

Models API

The Models API provides functions for interacting with generative AI models.

generate()

Generate calls a generative model based on the provided prompt and configuration. Signature:

Parameters

GenerateOptions
required
Generation options

Returns

GenerateResponse<O>
Generation response object

Example

generateStream()

Streaming version of generate() that yields response chunks as they are generated. Signature:

Parameters

Accepts the same GenerateOptions as generate(), plus:
StreamingCallback
Callback invoked for each chunk:

Returns

GenerateStreamResponse
Streaming response object

Example

modelRef()

Creates a reference to a model by name. Signature:

Parameters

object
required

Returns

ModelReference
A reference object that can be passed to generate() or other model functions

Example

Types

GenerateRequest

The raw request object sent to a model.

GenerateResponse

The response from a model.

Part

Content part within a message.

MessageData

A message in the conversation.

See Also