Petal Flow Examples
Examples
Section titled “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.
Workflow Examples
Section titled “Workflow Examples” Customer Support Router Triage inbound requests using LLM classification and route to appropriate teams based on intent, urgency, and customer tier.
RAG Workflow End-to-end retrieval-augmented generation with vector search, context assembly, and grounded answer synthesis using Iris providers.
Data Enrichment Multi-stage pipeline that validates, transforms, and enriches data with branching logic and error recovery.
Human Review Loop Human-in-the-loop approval gates with timeout handling, escalation paths, and audit logging.
Observability Capture runtime events, execution metrics, and trace spans from workflow runs for monitoring and debugging.
Running the Examples
Section titled “Running the Examples”Each example is a complete Go program. To run any example:
# Clone the examples repositorygit clone https://github.com/petal-labs/petalflow-examplescd petalflow-examples
# Set up your API keys (for LLM-powered examples)iris keys set openai
# Run an examplego run support-router/main.goCommon Patterns
Section titled “Common Patterns”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
Next Steps
Section titled “Next Steps” Getting Started New to Petal Flow? Start here.
Concepts Learn the core primitives.
Graph Design Best practices for workflow design.
Iris Integration Power nodes with LLM providers.