Skip to main content
The cookbook contains practical, copy-paste recipes for common use cases. Each recipe is a complete, working example you can adapt for your projects.
Looking for runnable code? Check out the examples folder on GitHub for complete, standalone scripts.

Core Patterns

Stateless Generation

Use generate_text and stream_text directly for maximum flexibility

Multimodal Chatbot

Handle images and files in conversations

Structured Output

Get typed, structured JSON responses from AI models

Agents & Servers

Profile Research Agent

OSINT agent with durable SSE streaming and event replay

Persistent Chatbot

AI chatbot that remembers conversations across sessions

Per-User Assistant

Create isolated AI assistants for each user

FastAPI Integration

Custom HTTP endpoints and middleware

Serverless Agents

Deploy to AWS Lambda, Vercel, and Cloud Run

Cloudflare Durable Objects

Run stateful agents at the edge with Python DOs

Tools & Tasks

Task Planner

AI-powered task breakdown and planning

RAG Agent

Build a retrieval-augmented generation agent

Multi-Agent Workflow

Coordinate multiple specialized agents

MCP Agent

Use tools from any MCP server

Code Executor

Execute Python code safely in a sandbox

Wikipedia Agent

Research agent that searches Wikipedia