Tutorials
Each tutorial in this section builds something complete and runnable. The focus is one real use case per page: the architecture, the code, a clean path to run it, and the SDK example numbers that back it. Pick the page closest to what you're building.
If you want the SDK basics first, start with Learn the SDK. If you want shorter pattern recipes without a full walkthrough, see Production patterns.
Available tutorials
Train your own model
Capture training data from a frontier LLM, fine-tune a 3B-parameter model on a free Colab T4 (or a $0.34/hr RunPod A10G), and deploy it via Ollama with no per-token API bill. The full path from "Anthropic raised prices" to "we own the model" — end-to-end in a weekend.
- Examples: 25, 36, 38, 38a, 44, 45, 47, 48
- See also: Training Loop
Moderation and classification
Community moderation, support-ticket triage, and sales-lead qualification — each with the same shape: a deterministic classifier ensemble inside an isolated sandbox, surfaced as MCP tools, with a cheap LLM judging the boundary cases. Full audit trail per decision.
- Examples: 42, 49
- See also: SDK
Memory and retrieval
Two patterns developers ask for by name. First, semantic checkpoint recall — vague references like "back to that earlier point" resolve into the right slice of prior context, even on a 7B Ollama model. Second, graph-backed retrieval for multi-hop reasoning across incident dependencies, where vector chunking falls short.
- Examples: 04, 29, 32, 37, 41
- See also: SDK
Production multitenancy
Run one platform for many customers without leaking credentials or work between tenants: per-CLI workload identity, scoped credentials injected into a containerised agent, cross-tenant isolation enforced by the dispatcher, and an audit trail across every boundary.
Observability and cost
Real telemetry into Grafana, a live dashboard with active agents on the graph, per-tenant cost tracking, and an OpenTelemetry pipeline you can swap into your existing stack. Five rows, fourteen panels, all driven by an actual run of the example — no canned data.
- Examples: 12, 34, 40, 43
- See also: Observatory
Inference deployment
Five inference paths (free Colab T4, Vast.ai bid market, RunPod reliable rental, Modal serverless, bring-your-own endpoint) plus the small-model deployment story (mlx-lm on Apple Silicon, Ollama everywhere else). Includes a decision table for picking the right path and snippets for plugging each into Sagewai.
- Examples: 18, 38, 38a, 44, 45, 46, 47, 48
- See also: Training Loop
What each tutorial page contains
Every tutorial follows the same structure:
- What you'll build — one paragraph naming the scenario and the outcome.
- Architecture — a Mermaid diagram of the moving parts.
- Run it — a clean-machine path and a full live path.
- Real-world context — three to five concrete examples of where this pattern appears in production.
- Companion examples — links to the runnable SDK examples that back the page, with READMEs on PyPI and GitHub.
- See also — sibling tutorials, prerequisite reading, and related platform docs.
Before you start
The tutorials assume you have:
- Python 3.10 or later
- Docker installed and running (most tutorials use the Docker sandbox)
- The Sagewai SDK installed:
pip install 'sagewai[fastapi]' - A working admin server — see Quickstart
Some tutorials need additional accounts (a HuggingFace token, a RunPod or Modal account, a Grafana endpoint). Each page lists its own prerequisites.
See also
- Learn the SDK — short, focused examples that introduce one SDK capability at a time.
- Production patterns — pattern recipes that sit between a single-feature example and a full tutorial.
- Quickstart — install the SDK and run your first agent in 15 minutes.