Recipes

Build specific AI features faster.

Focused, production-ready recipes with runnable examples — from structured extraction to durable agents. Each recipe ships complete client and server code.

Guides

RAG Agent

Learn how to build a RAG Agent with the AI TOOLKIT and Next.js

24 minragchatbot
Guides

Multi-Modal Agent

Learn how to build a multi-modal agent that can process images and PDFs with the AI TOOLKIT.

9 minmulti-modalagent
Guides

Slackbot Agent Guide

Learn how to use the AI TOOLKIT to build an AI Agent in Slack.

11 minagentschatbot
Guides

Natural Language Postgres

Learn how to build a Next.js app that lets you talk to a PostgreSQL database in natural language.

20 minagentsnext
Guides

Get started with Computer Use

Get started with Claude's Computer Use capabilities with the AI TOOLKIT

7 mincomputer-usetools
Guides

Get started with Gemini 3

Get started with Gemini 3 using the AI TOOLKIT.

6 mingetting-started
Guides

Get started with Claude 4

Get started with Claude 4 using the AI TOOLKIT.

7 mingetting-started
Guides

OpenAI Responses API

Get started with the OpenAI Responses API using the AI TOOLKIT.

7 mingetting-startedagents
Guides

Google Gemini Image Generation

Generate and edit images with Google Gemini 2.5 Flash Image using the AI TOOLKIT.

2 minimage-generationgoogle
Guides

Get started with Claude 3.7 Sonnet

Get started with Claude 3.7 Sonnet using the AI TOOLKIT.

5 mingetting-started
Guides

Get started with Llama 3.1

Get started with Llama 3.1 using the AI TOOLKIT.

12 mingetting-started
Guides

Get started with GPT-5

Get started with GPT-5 using the AI TOOLKIT.

8 mingetting-started
Guides

Get started with OpenAI o1

Get started with OpenAI o1 using the AI TOOLKIT.

8 mingetting-startedreasoning
Guides

Get started with OpenAI o3-mini

Get started with OpenAI o3-mini using the AI TOOLKIT.

7 mingetting-startedreasoning
Guides

Get started with DeepSeek R1

Get started with DeepSeek R1 using the AI TOOLKIT.

7 mingetting-startedreasoning
Guides

Get started with DeepSeek V3.2

Get started with DeepSeek V3.2 using the AI TOOLKIT.

6 mingetting-startedagents
Next.js

Generate Text

Learn how to generate text using the AI TOOLKIT and Next.js.

2 minnext
Next.js

Generate Text with Chat Prompt

Learn how to generate text with chat prompt using the AI TOOLKIT and Next.js

2 minnextstreaming
Next.js

Generate Image with Chat Prompt

Learn how to generate an image with a chat prompt using the AI TOOLKIT and Next.js

3 minnextstreaming
Next.js

Caching Middleware

Learn how to create a caching middleware with Next.js and KV.

4 minnextstreaming
Next.js

Stream Text

Learn how to stream text using the AI TOOLKIT and Next.js

2 minnextstreaming
Next.js

Stream Text with Chat Prompt

Learn how to generate text using the AI TOOLKIT and Next.js

2 minnextstreaming
Next.js

Stream Text with Image Prompt

Learn how to stream text with an image prompt using the AI TOOLKIT and Next.js

2 minnextstreaming
Next.js

Chat with PDFs

Learn how to build a chatbot that can understand PDFs using the AI TOOLKIT and Next.js

3 minnextpdf
Next.js

streamText Multi-Step Cookbook

Learn how to create several streamText steps with different settings

2 minnextstreaming
Next.js

Markdown Chatbot with Memoization

Build a chatbot that renders and memoizes Markdown responses with Next.js and the AI TOOLKIT.

4 minnextstreaming
Next.js

Generate Object

Learn how to generate object using the AI TOOLKIT and Next.js

3 minnextstructured data
Next.js

Generate Object with File Prompt through Form Submission

Learn how to generate object with file prompt through form submission using the AI TOOLKIT and Next.js

2 minnextmulti-modal
Next.js

Stream Object

Learn how to stream object using the AI TOOLKIT and Next.js

5 minnextstreaming
Next.js

Call Tools

Learn how to call tools using the AI TOOLKIT and Next.js

3 minnexttool use
Next.js

Call Tools in Multiple Steps

Learn how to call tools in multiple steps using the AI TOOLKIT and Next.js

3 minnextstreaming
Next.js

Model Context Protocol (MCP) Tools

Learn how to use MCP tools with the AI TOOLKIT and Next.js

4 minnexttool use
Next.js

Share useChat State Across Components

Learn how to share a chat instance across multiple components with useChat and easily reset the chat.

3 minnextuseChat
Next.js

Human-in-the-Loop Agent with Next.js

Add a human approval step to your agentic system with Next.js and the AI TOOLKIT

15 minnextagents
Next.js

Track Agent Token Usage

Learn how to track the active context window with ToolLoopAgent.

6 minnext
Next.js

Send Custom Body from useChat

Learn how to send a custom body from the useChat hook using the AI TOOLKIT and Next.js

3 minnextchat
Next.js

Streaming with Custom Format

Build a custom format to stream LLM responses

3 minnextstreaming
Next.js

Render Visual Interface in Chat

Learn how to render visual interfaces in chat using the AI TOOLKIT and Next.js

4 minnextgenerative user interface
Node.js

Generate Text

Learn how to generate text using the AI TOOLKIT and Node

1 minnode
Node.js

Retrieval Augmented Generation

Learn how to use retrieval augmented generation using the AI TOOLKIT and Node

2 minnode
Node.js

Knowledge Base Agent

Build an AI agent that can read from and write to a knowledge base using Upstash Search and the AI TOOLKIT

5 minnoderetrieval
Node.js

Generate Text with Chat Prompt

Learn how to generate text with chat prompt using the AI TOOLKIT and Node

1 minnodechat
Node.js

Generate Text with Image Prompt

Learn how to generate text with image prompt using the AI TOOLKIT and Node

1 minnodemultimodal
Node.js

Stream Text

Learn how to stream text using the AI TOOLKIT and Node

2 minnodestreaming
Node.js

Stream Text with Chat Prompt

Learn how to stream text with chat prompt using the AI TOOLKIT and Node

1 minnodestreaming
Node.js

Stream Text with Image Prompt

Learn how to stream text with image prompt using the AI TOOLKIT and Node

1 minnodestreaming
Node.js

Stream Text with File Prompt

Learn how to stream text with file prompt using the AI TOOLKIT and Node

1 minnodestreaming
Node.js

Generate Object with a Reasoning Model

Learn how to generate structured data with a reasoning model using the AI TOOLKIT and Node

2 minnodestructured data
Node.js

Generate Object

Learn how to generate structured data using the AI TOOLKIT and Node

1 minnodestructured data
Node.js

Stream Object

Learn how to stream structured data using the AI TOOLKIT and Node

1 minnodestreaming
Node.js

Stream Object with Image Prompt

Learn how to stream structured data with an image prompt using the AI TOOLKIT and Node

2 minnodestreaming
Node.js

Record Token Usage After Streaming Object

Learn how to record token usage when streaming structured data using the AI TOOLKIT and Node

2 minnodestreaming
Node.js

Record Final Object after Streaming Object

Learn how to record the final object after streaming an object using the AI TOOLKIT and Node

2 minnodestreaming
Node.js

Call Tools

Learn how to call tools using the AI TOOLKIT and Node

3 minnodetool use
Node.js

Call Tools in Parallel

Learn how to call tools in parallel using the AI TOOLKIT in Node.js

2 minnodetool use
Node.js

Call Tools with Image Prompt

Learn how to call tools with image prompt using the AI TOOLKIT and Node

1 minnodetool use
Node.js

Call Tools in Multiple Steps

Learn how to call tools with multiple steps using the AI TOOLKIT and Node

1 minnodetool use
Node.js

Model Context Protocol (MCP) Tools

Learn how to use MCP tools with the AI TOOLKIT and Node

2 minnodetool use
Node.js

Manual Agent Loop

Learn how to create your own agentic loop with full control over tool execution

4 minnodeagent
Node.js

Web Search Agent

Learn how to build an agent that has access to web with the AI TOOLKIT and Node

8 minnodetool use
Node.js

Model Context Protocol (MCP) Elicitation

Learn how to handle elicitation requests from MCP servers with the AI TOOLKIT

3 minnodemcp
Node.js

Embed Text

Learn how to embed text using the AI TOOLKIT and Node

1 minnodeembedding
Node.js

Embed Text in Batch

Learn how to embed multiple text using the AI TOOLKIT and Node

1 minnodeembedding
Node.js

Intercepting Fetch Requests

Learn how to intercept fetch requests using the AI TOOLKIT and Node

1 minnode
Node.js

Local Caching Middleware

Learn how to create a caching middleware for local development.

5 minstreamingcaching
Node.js

Repair Malformed JSON with jsonrepair

Learn how to use the jsonrepair library to automatically fix truncated or malformed JSON output from language models.

2 minerror-handlingjson
Node.js

Dynamic Prompt Caching

Learn how to reduce API costs by implementing dynamic prompt caching for Anthropic models using cache control directives.

4 mincachingcost-optimization
API Servers

Node.js HTTP Server

Learn how to use the AI TOOLKIT in a Node.js HTTP server

2 minapi serversstreaming
API Servers

Express

Learn how to use the AI TOOLKIT in an Express server

2 minapi serversstreaming
API Servers

Hono

Example of using the AI TOOLKIT in a Hono server.

2 minapi serversstreaming
API Servers

Fastify

Learn how to use the AI TOOLKIT in a Fastify server

2 minapi serversstreaming
API Servers

Nest.js

Learn how to use the AI TOOLKIT in a Nest.js server

2 minapi serversstreaming
React Server Components

Generate Text

Learn how to generate text using the AI TOOLKIT and React Server Components.

2 minrsc
React Server Components

Generate Text with Chat Prompt

Learn how to generate text with chat prompt using the AI TOOLKIT and React Server Components.

2 minrscchat
React Server Components

Stream Text

Learn how to stream text using the AI TOOLKIT and React Server Components.

2 minrscstreaming
React Server Components

Stream Text with Chat Prompt

Learn how to stream text with chat prompt using the AI TOOLKIT and React Server Components.

2 minrscchat
React Server Components

Generate Object

Learn how to generate object using the AI TOOLKIT and React Server Components.

2 minrscstructured data
React Server Components

Stream Object

Learn how to stream object using the AI TOOLKIT and React Server Components.

3 minrscstreaming
React Server Components

Call Tools

Learn how to call tools using the AI TOOLKIT and React Server Components.

2 minrsctool use
React Server Components

Call Tools in Parallel

Learn how to tools in parallel text using the AI TOOLKIT and React Server Components.

2 minrsctool use
React Server Components

Save Messages To Database

Learn how to save messages to an external database using the AI TOOLKIT and React Server Components

3 minrsctool use
React Server Components

Restore Messages From Database

Learn how to restore messages from an external database using the AI TOOLKIT and React Server Components

3 minrsctool use
React Server Components

Render Visual Interface in Chat

Learn how to generate text using the AI TOOLKIT and React Server Components.

3 minrscgenerative user interface
React Server Components

Stream Updates to Visual Interfaces

Learn how to generate text using the AI TOOLKIT and React Server Components.

2 minrscstreaming
React Server Components

Record Token Usage after Streaming User Interfaces

Learn how to record token usage after streaming user interfaces using the AI TOOLKIT and React Server Components

3 minrscusage