Examples¶
Run curated, copy‑paste examples (5–15 minutes end‑to‑end). Requires Python 3.10+ and pip install alloy-ai (or -e '.[dev]' for the repo). Set a provider key; ALLOY_BACKEND=fake is optional for offline demos.
Quick Decision Guide¶
"I want to…"
- Try Alloy interactively → Exploration
- Create reusable AI functions → Commands
- Get structured data → Commands
- Add local capabilities → Tools
- Build multi-step workflows → Workflows
- Integrate with my app → Integration
Run¶
- Each example is a standalone script:
python examples/<category>/<file>.py - Offline mode:
export ALLOY_BACKEND=fakefor deterministic demo outputs.
Browse by Category¶
- Exploration:
examples/00-explore/ - Commands:
examples/10-commands/ - Typed outputs:
examples/20-typed/ - Tools:
examples/30-tools/ - Contracts:
examples/40-contracts/ - Composition:
examples/50-composition/ - Integration:
examples/60-integration/ - Providers:
examples/70-providers/ - Patterns:
examples/80-patterns/ - Advanced:
examples/90-advanced/
Selected Links (GitHub)¶
Browse on GitHub¶
- All examples
- 00-explore
- 10-commands
- 20-typed
- 30-tools
- 40-contracts
- 50-composition
- 60-integration
- 70-providers
- 80-patterns
- 90-advanced
Tips¶
- Read the Common Pitfalls for quick wins (streaming limits, typed outputs, tool loops).