Defining a flow
- TypeScript
- Go
- Python
inputSchema and outputSchema are Zod schemas. Genkit validates inputs and outputs against them automatically.Calling a flow
Flows are callable like regular functions. They return the output value defined by the output schema.- TypeScript
- Go
- Python
Named steps with run
Use ai.run() (TypeScript) or genkit.Run() (Go) to give individual steps within a flow their own trace spans. This makes it easy to pinpoint exactly where time is spent in the Dev UI.
- TypeScript
- Go
Flows as HTTP endpoints
Flows can be exposed as HTTP endpoints so that any HTTP client can invoke them. The request body is the flow’s input and the response body is its output.- TypeScript
- Python
- Go
Use Or serve all registered flows with Genkit’s built-in flow server:
onFlow from @genkit-ai/firebase or wrap the flow in an Express/Cloud Functions handler:Observability
Every flow run creates a trace that records:- Flow input and output
- Every named
run()step - Model calls, including prompts and responses
- Tool calls and their outputs
- Latency at each level
The Dev UI starts automatically when you run
genkit start (TypeScript/Python) or set GENKIT_ENV=dev (Go). Flows and their traces appear in the Flows and Traces panels.Background flows
Some operations—like video generation or long-running batch jobs—take too long to return synchronously. Genkit supports background flows (also called operations) that return immediately with an operation handle. The caller can then poll the handle to check on progress.Next steps
Models
Learn how to call AI models from within flows.
Tools
Give models the ability to call your functions.
Streaming
Stream responses token-by-token from flows.
Dev Tools
Inspect flow traces and replay runs in the Dev UI.
