plugin library
Core APIs and types for authoring Genkit plugins.
This library exports the primitives necessary for creating custom models,
embedders, tools, middleware, and other Genkit integrations. It is intended
for package authors extending Genkit functions. End-users building Genkit
applications should import package:genkit/genkit.dart instead.
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
-
Action<
Input, Output, Chunk, Init> -
ActionFnArg<
Chunk, Input, Init> - The per-invocation context handed to an action's implementation function.
-
ActionMetadata<
Input, Output, Chunk, Init> -
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
-
Embedder<
CustomOptions> -
EmbedderRef<
CustomOptions> - Embedding
- EmbedRequest
- EmbedResponse
- EvalFnResponse
- EvalFnResponseEvaluation
- EvalRequest
- Evaluator
- GenerateActionOptions
- GenerateActionOutputConfig
- GenerateActionOutputConfigInstructions
- GenerateMiddleware
- Middleware for the processing of a Generation request.
- GenerateMiddlewareContext
- Ambient dependencies handed to a middleware factory at instantiation time.
-
GenerateMiddlewareDef<
CustomOptions> -
A named, configurable middleware, built with generateMiddleware or
ai.defineGenerateMiddleware. -
GenerateMiddlewareRef<
CustomOptions> - 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
- GenerateTurnState
- The state of one turn of the generate tool loop, as seen by GenerateMiddleware.generate.
- GenerationUsage
- GenkitAI
- Encapsulates Genkit's AI APIs.
- GenkitPlugin
- A plugin for Genkit.
-
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
-
Model<
CustomOptions> - ModelInfo
-
ModelRef<
CustomOptions> - ModelRequest
- ModelResponse
- ModelResponseChunk
- Operation
- OutputConfig
- Part
- ReasoningPart
- Registry
- Holds the actions, plugins, and named values of a Genkit instance.
- ResourceAction
- ResourceInput
- ResourceOutput
- ResourcePart
-
RunResult<
Output> - 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.
Enums
- StatusCode
- Canonical status codes for Genkit operations.
Extension Types
- ActionType
-
Well-known action type identifiers used as the
actionTypeof an Action and as the first segment of its registry key (/$actionType/$name). - EvalStatus
- FinishReason
- Role
- ToolChoice
Extensions
- MessageExtension on Message
- ModelResponseChunkExtension on ModelResponseChunk
- ModelResponseExtension on ModelResponse
- PartExtension on Part
- Extension methods for Part.
- ToolRequestPartExtension on ToolRequestPart
- Extension methods for ToolRequestPart.
Constants
- genkitVersion → const String
Functions
-
createResourceMatcher(
{required String? uri, required String? template}) → bool Function(ResourceInput input) -
Builds the
matchespredicate for a ResourceAction from exactly one of a fixedurior a simple URItemplate(e.g.file://{path}). -
embedderMetadata(
String name, {SchemanticType? customOptions}) → ActionMetadata -
embedderRef<
CustomOptions> (String name, {SchemanticType< CustomOptions> ? customOptions}) → EmbedderRef<CustomOptions> -
generateMiddleware<
CustomOptions> ({required String name, required GenerateMiddleware create(CustomOptions? config, GenerateMiddlewareContext ctx), SchemanticType< CustomOptions> ? configSchema}) → GenerateMiddlewareDef<CustomOptions> -
Builds a middleware definition without registering it. For plugin authors:
return it from
GenkitPlugin.middleware. -
getConfigVar(
String name) → String? -
getPlatformLanguageVersion(
) → String -
middlewareRef<
CustomOptions> ({required String name, CustomOptions? config}) → GenerateMiddlewareRef< CustomOptions> -
modelMetadata(
String name, {ModelInfo? info, SchemanticType? customOptions}) → ActionMetadata -
modelRef<
CustomOptions> (String name, {SchemanticType< CustomOptions> ? customOptions, CustomOptions? config}) → ModelRef<CustomOptions>
Typedefs
-
ActionFn<
Input, Output, Chunk, Init> = Future< Output> Function(Input input, ActionFnArg<Chunk, Input, Init> context) -
RawActionFn<
Input, Output, Chunk, Init> = Future< Output> Function(Input? input, ActionFnArg<Chunk, Input, Init> context) - The low-level implementation function stored by Action.
-
ResourceFn
= Future<
ResourceOutput> Function(ResourceInput input, ActionFnArg<void, ResourceInput, void> ctx) -
StreamingCallback<
Chunk> = void Function(Chunk chunk) -
ToolFn<
Input, Output> = FutureOr< ToolResult< Function(Input input, ToolFnArg<Output> >Input> context) - A function that implements a tool.
- TraceStartCallback = void Function({required String spanId, required String traceId})
Exceptions / Errors
- CancelledException
- Thrown when an operation is aborted via a CancellationToken.
- GenkitException
- Exception thrown for errors encountered during Genkit flow operations.