Examples Playbook
Real-world examples covering every feature of confused-ai. Pick your level.
Full framework map (start here)
For a single narrative that walks every capability area—NorthPeak StoreOps Copilot, import cheat-sheets, architecture diagram, and links back to these tutorials—see 17 · Full framework showcase.
Runnable counterparts in the repo:
bun run example:showcase— LLM, sessions, workflows, pipeline, health, metrics, optional HTTP.bun run example:potential— chunking, circuit breaker, rate limiter, artifacts, profiles, eval metrics, config (no LLM calls).bun run example:meridian— full role intelligence platform: 6 personas, handoff, router, supervisor, consensus, RAG, HTTP server.bun run example:reasoning— chain-of-thought incident triage withReasoningManager.bun run example:scheduled— nightly market digest cron withScheduleManager.bun run example:code-review— three-agent PR review pipeline withbare(),compose(),pipe().bun run example:eval— CI eval regression guard withrunEvalSuite+InMemoryEvalStore.
Skill Levels
| Label | Who it's for |
|---|---|
| 🟢 Beginner | Never used an AI framework. First time here. |
| 🟡 Intermediate | Built basic agents, want real-world patterns. |
| 🔴 Advanced | Production systems, orchestration, resilience. |
All Examples
| # | Example | Level | What you learn |
|---|---|---|---|
| 01 | Hello World | 🟢 | Create and run your first agent |
| 02 | First Custom Tool | 🟢 | Build a tool that calls a real API |
| 03 | Tool with Approval | 🟢 | Ask human before executing risky actions |
| 04 | Extend & Wrap Tools | 🟡 | Add middleware, caching, auth to any tool |
| 05 | RAG Knowledge Base | 🟡 | Answer questions from your own documents |
| 06 | Persistent Memory | 🟡 | Remember users and conversations |
| 07 | Storage Patterns | 🟡 | Cache, state, and config in agents |
| 08 | Multi-Agent Team | 🔴 | Specialized agents working together |
| 09 | Supervisor Workflow | 🔴 | One agent delegates to many |
| 10 | Database Analyst | 🔴 | Query a SQL database with natural language |
| 11 | Customer Support Bot | 🔴 | Full bot: sessions + guardrails + handoff |
| 12 | Observability & Hooks | 🟡 | Log, trace, and measure every agent step |
| 13 | Production Resilience | 🔴 | Circuit breakers, retries, fallbacks |
| 14 | MCP Filesystem Agent | 🔴 | Use Model Context Protocol tools |
| 15 | Full-Stack App | 🔴 | Complete app: HTTP API + agent + RAG + storage |
| 16 | Intelligent LLM Router | 🟡 | Auto-route requests to the right model by task, cost & speed |
| 17 | Full framework showcase | 🔴 | Coverage map: one real-world story + every module / import path + links to 01–16 |
| 18 | Meridian — Role Intelligence Platform | 🔴 | Full platform demo: 6 role personas, triage handoff, router, supervisor, consensus, compose/pipe, workflows, RAG, guardrails, resilience, health, HTTP runtime |
| 19 | Incident Triage Bot | 🔴 | Chain-of-thought reasoning, ReasoningManager, event streaming, NextAction loop |
| 20 | Scheduled Agent Jobs | 🔴 | Cron scheduling, ScheduleManager, handler registry, run history, enable/disable |
| 21 | Code Review Pipeline | 🔴 | bare(), compose(), pipe(), conditional when hand-off, lifecycle hooks |
| 22 | Eval Regression Guard | 🟡 | runEvalSuite, EvalStore, custom scorer, baseline saving, CI exit code |
Quick Start (30 seconds)
bash
npm install confused-aits
import { createAgent } from 'confused-ai';
const agent = createAgent({
name: 'my-first-agent',
model: 'gpt-4o-mini',
instructions: 'You are a helpful assistant.',
});
const result = await agent.run('What is 2 + 2?');
console.log(result.text); // "4"Environment Variables
Most examples need these in a .env file:
bash
OPENAI_API_KEY=sk-... # required for OpenAI models
ANTHROPIC_API_KEY=sk-... # optional, for Claude models
GOOGLE_AI_API_KEY=... # optional, for Gemini models