Skip to content

Petal Flow Examples

These examples demonstrate production-ready patterns for building AI workflows with Petal Flow. Each example includes complete, runnable code with proper error handling and real-world use cases.

Each example is a complete Go program. To run any example:

Terminal window
# Clone the examples repository
git clone https://github.com/petal-labs/petalflow-examples
cd petalflow-examples
# Set up your API keys (for LLM-powered examples)
iris keys set openai
# Run an example
go run support-router/main.go

All examples follow consistent patterns for production readiness:

  • Error propagation — Errors bubble up through the graph with context
  • Context cancellation — All nodes respect context deadlines and cancellation
  • Event hooks — Runtime events for logging, metrics, and debugging
  • Testable structure — Nodes can be tested in isolation