GenkitAI class base

Encapsulates Genkit's AI APIs.

GenkitAI exposes the model-orchestration veneer (generate, generateStream, embed, embedMany, run) on top of a Registry. It only requires a registry to operate, making it cheap to create ephemeral, throwaway instances (the registry holds all the state). The full framework entry point Genkit extends this class to add plugin loading, the reflection server, and the various define* methods.

Implementers
Available extensions

Constructors

GenkitAI(Registry registry)

Properties

hashCode int
The hash code for this object.
no setterinherited
registry Registry
The action registry backing this instance.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

embed<CustomOptions>({required EmbedderRef<CustomOptions> embedder, DocumentData? document, List<DocumentData>? documents, CustomOptions? options}) Future<List<Embedding>>
Embeds a single document or a list of documents.
embedMany<CustomOptions>({required EmbedderRef<CustomOptions> embedder, required List<DocumentData> documents, CustomOptions? options}) Future<List<Embedding>>
Embeds multiple documents using the specified embedder.
generate<CustomOptions, Output>({String? system, String? prompt, List<Part>? promptParts, List<Message>? messages, ModelRef<CustomOptions>? model, CustomOptions? config, List<Tool>? tools, List<String>? toolNames, String? 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<GenerateMiddlewareRef>? use, CancellationToken? cancel, List<InterruptResponse>? interruptRespond, List<ToolRequestPart>? interruptRestart}) Future<GenerateResponseHelper<Output>>
Generates a response using the specified model and context.
generateBidi({required String model, dynamic config, List<Tool>? tools, List<String>? toolNames, String? system, CancellationToken? cancel}) Future<GenerateBidiSession>

Available on GenkitAI, provided by the GenkitBidi extension

Starts a bi-directional (live) generator session.
generateStream<CustomOptions, Output>({String? system, String? prompt, List<Part>? promptParts, List<Message>? messages, ModelRef<CustomOptions>? model, CustomOptions? config, List<Tool>? tools, List<String>? toolNames, String? toolChoice, bool? returnToolRequests, int? maxTurns, SchemanticType<Output>? outputSchema, String? outputFormat, bool? outputConstrained, String? outputInstructions, bool? outputNoInstructions, String? outputContentType, Map<String, dynamic>? context, List<GenerateMiddlewareRef>? use, CancellationToken? cancel, List<InterruptResponse>? interruptRespond, List<ToolRequestPart>? interruptRestart}) ActionStream<GenerateResponseChunk<Output>, GenerateResponseHelper<Output>>
Streams a response from the specified model.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run<Output>(String name, Future<Output> fn()) Future<Output>
Runs an AI operation within a new trace span.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited