lite library

A lightweight entry point for Genkit.

Use this library for simple scripts or applications that need to perform generation tasks (using generate or generateStream) without setting up the full Genkit framework or reflection server.

This is useful for quick prototyping or simple LLM interactions.

Classes

$BaseDataPoint
$Candidate
$CustomPart
$DataPart
$DocumentData
$Embedding
$EmbedRequest
$EmbedResponse
$EvalFnResponse
$EvalRequest
$GenerateActionOptions
$GenerateActionOutputConfig
$GenerateRequest
$GenerateResponse
$GenerateResumeOptions
$GenerationUsage
$Media
$MediaPart
$Message
$MiddlewareRef
$ModelInfo
$ModelRequest
$ModelResponse
$ModelResponseChunk
$Operation
$OutputConfig
$Part
$ReasoningPart
$ResourcePart
$RuntimeError
$Score
$TextPart
$ToolDefinition
$ToolRequest
$ToolRequestPart
$ToolResponse
$ToolResponsePart
ActionStream<Chunk, Response>
A stream of chunks emitted by an action, which also resolves to a final response.
BaseDataPoint
CancellationController
The writable side of a cancellation.
CancellationToken
A read-only view of a cancellation request.
Candidate
CustomPart
DataPart
DocumentData
Embedding
EmbedRequest
EmbedResponse
EvalFnResponse
EvalFnResponseEvaluation
EvalRequest
GenerateActionOptions
GenerateActionOutputConfig
GenerateActionOutputConfigInstructions
GenerateRequest
GenerateResponse
GenerateResponseChunk<Output>
A chunk of a response from a generate action: the model's chunk plus the partially parsed output and the chunks streamed before it.
GenerateResult<Output>
The result of generate: the final model response plus the parsed output, the full conversation messages, and the originating request.
GenerateResumeOptions
GenerationUsage
Interrupt<Input, Output>
A special kind of Tool that always interrupts the generation loop.
InterruptResponse
A response to an interrupted tool request.
Media
MediaPart
Message
MiddlewareRef
ModelInfo
ModelRequest
ModelResponse
ModelResponseChunk
Operation
OutputConfig
Part
ReasoningPart
ResourcePart
RuntimeError
Score
ScoreScore
TextPart
Tool<Input, Output>
ToolDefinition
ToolFnArg<Input>
Arguments passed to a tool function execution.
ToolInterruptResult<Output>
An interrupt result that bubbles the tool request back to the caller with an optional data payload.
ToolRequest
ToolRequestPart
ToolResponse
ToolResponsePart
ToolResponseResult<Output>
A normal tool response carrying structured output and optional multipart parts and metadata.
ToolResult<Output>
The result returned by a tool's implementation function.

Functions

generate<Output, C>({String? system, String? prompt, List<Part>? promptParts, List<Message>? messages, required Model<C> model, C? config, List<Tool>? tools, List<String>? toolNames, ToolChoice? toolChoice, bool? returnToolRequests, int? maxTurns, SchemanticType<Output>? outputSchema, String? outputFormat, bool? outputConstrained, String? outputInstructions, bool? outputNoInstructions, String? outputContentType, Map<String, dynamic>? context, StreamingCallback<GenerateResponseChunk<Output>>? onChunk, List<GenerateMiddleware>? use, CancellationToken? cancel, List<InterruptResponse>? interruptRespond, List<ToolRequestPart>? interruptRestart}) → Future<GenerateResult<Output>>
Generates a response from model.
generateStream<Output, C>({required Model<C> model, String? system, String? prompt, List<Part>? promptParts, List<Message>? messages, C? config, List<Tool>? tools, List<String>? toolNames, ToolChoice? toolChoice, bool? returnToolRequests, int? maxTurns, SchemanticType<Output>? outputSchema, String? outputFormat, bool? outputConstrained, String? outputInstructions, bool? outputNoInstructions, String? outputContentType, Map<String, dynamic>? context, List<GenerateMiddleware>? use, CancellationToken? cancel, List<InterruptResponse>? interruptRespond, List<ToolRequestPart>? interruptRestart}) → ActionStream<GenerateResponseChunk<Output>, GenerateResult<Output>>
Streams a response from model; see generate.
remoteModel({required String name, required String url, FutureOr<Map<String, String>?> headers(Map<String, dynamic> context)?, ModelInfo? info, Client? httpClient}) → Model
Defines a remote Genkit model.

Typedefs

StreamingCallback<Chunk> = void Function(Chunk chunk)
ToolFn<Input, Output> = FutureOr<ToolResult<Output>> Function(Input input, ToolFnArg<Input> context)
A function that implements a tool.