---
title: "Cookbook"
description: "Practical recipes and examples for building with ai-query"
---

The cookbook contains practical, copy-paste recipes for common use cases. Each recipe is a complete, working example you can adapt for your projects.

<Info>
Looking for runnable code? Check out the [examples folder](https://github.com/Abdulmumin1/ai-query/tree/main/examples) on GitHub for complete, standalone scripts.
</Info>

## Core Patterns

<CardGroup cols={2}>
  <Card title="Stateless Generation" icon="function" href="/cookbook/stateless-generation">
    Use generate_text and stream_text directly for maximum flexibility
  </Card>
  <Card title="Multimodal Chatbot" icon="image" href="/cookbook/multimodal-chatbot">
    Handle images and files in conversations
  </Card>
  <Card title="Structured Output" icon="brackets-curly" href="/cookbook/structured-output">
    Get typed, structured JSON responses from AI models
  </Card>
</CardGroup>

## Agents & Servers

<CardGroup cols={2}>
  <Card title="Profile Research Agent" icon="user-secret" href="/cookbook/profile-research-agent">
    OSINT agent with durable SSE streaming and event replay
  </Card>
  <Card title="Persistent Chatbot" icon="database" href="/cookbook/persistent-chatbot">
    AI chatbot that remembers conversations across sessions
  </Card>
  <Card title="Per-User Assistant" icon="users" href="/cookbook/per-user-assistant">
    Create isolated AI assistants for each user
  </Card>
  <Card title="FastAPI Integration" icon="bolt" href="/cookbook/fastapi-integration">
    Custom HTTP endpoints and middleware
  </Card>
  <Card title="Serverless Agents" icon="cloud" href="/cookbook/serverless-agents">
    Deploy to AWS Lambda, Vercel, and Cloud Run
  </Card>
  <Card title="Cloudflare Durable Objects" icon="bolt" href="/guides/cloudflare-durable-objects">
    Run stateful agents at the edge with Python DOs
  </Card>
</CardGroup>

## Tools & Tasks

<CardGroup cols={2}>
  <Card title="Task Planner" icon="list-check" href="/cookbook/task-planner">
    AI-powered task breakdown and planning
  </Card>
  <Card title="RAG Agent" icon="search" href="/cookbook/rag-agent">
    Build a retrieval-augmented generation agent
  </Card>
  <Card title="Multi-Agent Workflow" icon="network-wired" href="/cookbook/multi-agent-workflow">
    Coordinate multiple specialized agents
  </Card>
  <Card title="MCP Agent" icon="plug" href="/cookbook/mcp-agent">
    Use tools from any MCP server
  </Card>
  <Card title="Code Executor" icon="code" href="/cookbook/code-executor">
    Execute Python code safely in a sandbox
  </Card>
  <Card title="Wikipedia Agent" icon="wikipedia-w" href="/cookbook/wikipedia-agent">
    Research agent that searches Wikipedia
  </Card>
</CardGroup>
