Skip to main content

Genkit

The Genkit class encapsulates a single Genkit instance including the Registry, Reflection Server, and configuration.

Installation

Usage

genkit()

Initializes Genkit with a set of options. Signature:

Parameters

GenkitOptions
Configuration options for the Genkit instance

Returns

Genkit
A configured Genkit instance

Class: Genkit

generate()

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

Parameters

string | Part[] | GenerateOptions
The input prompt - can be a simple string, array of parts, or full options object

Returns

GenerateResponse
The generation response containing:
  • text: The generated text
  • output(): Parsed output according to schema
  • messages: Full conversation history
  • usage: Token usage information

Example

generateStream()

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

Returns

GenerateStreamResponse
An object containing:
  • response: Promise that resolves to the final response
  • stream: Channel of response chunks

Example

defineFlow()

Defines and registers a flow function. Signature:

Parameters

FlowConfig | string
required
Flow configuration or name string
FlowFn<I, O, S>
required
The flow implementation function

Example

defineTool()

Defines and registers a tool that can be used by models. Signature:

Parameters

ToolConfig
required
Tool configuration
ToolFn<I, O>
required
Tool implementation function

Example

definePrompt()

Defines and registers a prompt based on a function or template. Signature:

Example

run()

A flow step that executes the provided function. Each run step is recorded separately in the trace. Signature:

Example

See Also