What are Flows?
A Flow is an observable, streamable, (optionally) strongly typed function. Every flow execution is automatically traced, and flows can be deployed as HTTP endpoints or called locally.Why Use Flows?
Flows provide several key benefits:1. Automatic Tracing
Every flow execution is traced end-to-end, capturing:- Input and output at each step
- Timing information for performance analysis
- Model calls and their responses
- Tool invocations and results
- Errors and stack traces
2. Developer UI Integration
Flows appear in the Genkit Developer UI, where you can:- Browse all defined flows
- Run flows with test inputs
- View execution traces
- Inspect intermediate results
- Debug failures
3. Deployability
Flows can be deployed as HTTP endpoints:4. Streaming Support
Flows can stream responses in real-time:Flow Execution Traces
When you run a flow, Genkit creates a detailed trace:Flow Steps with run()
You can organize flows into named steps for better observability:
run() call creates its own span in the trace, making it easy to see which steps take the most time or where errors occur.
Multi-Step Agentic Flows
Flows are perfect for building agentic workflows with tool calling:- The initial model call
- Tool invocations (weather check, restaurant search)
- The model’s follow-up response
- Final output
Deploying Flows
Flows are designed to be deployed as HTTP endpoints:Built-in Flow Server
The simplest way - all flows are automatically exposed:Framework Integration
For more control, integrate with your web framework:Deployment Targets
Flows can be deployed anywhere:- Cloud Run: Serverless, auto-scaling HTTP endpoints
- Firebase Functions: Integrated with Firebase services
- Express/Flask/FastAPI: Any Node.js or Python web server
- Kubernetes: Containerized deployments
- AWS Lambda: Serverless on AWS
- Azure Functions: Serverless on Azure
Best Practices
1. Use Input/Output Schemas
Always define schemas for type safety and validation:2. Break Down Complex Flows
Userun() to create named steps:
3. Handle Errors Gracefully
Flows should handle expected errors:4. Use Flows for All AI Logic
Even simple operations benefit from tracing:Next Steps
- Learn about Models - working with AI models in flows
- Explore Tools - extending flows with custom functions
- Understand Prompts - managing prompt templates
- See Observability - monitoring flow execution