Genkit
TheGenkit 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 textoutput(): Parsed output according to schemamessages: Full conversation historyusage: Token usage information
Example
generateStream()
Streaming version ofgenerate() that returns chunks as they are generated.
Signature:
Returns
GenerateStreamResponse
An object containing:
response: Promise that resolves to the final responsestream: 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