Vercel AI SDK's FastAPI template using Next
These examples show you how to use the AI SDK with Next.js and FastAPI.
uvloop, which does not support native Windows)This example depends on local AI SDK workspace packages, so run it from a clone of the AI SDK repository instead of using create-next-app.
Clone the repository, or use an existing checkout:
git clone https://github.com/vercel/ai.git
cd ai
From the repository root, install dependencies and build the workspace packages:
pnpm install
pnpm build:packages
Change to the example directory:
cd examples/next-fastapi
Copy the example environment file and add an OpenAI API key:
cp .env.local.example .env.local
Create and activate a Python virtual environment:
python3 -m venv venv
source venv/bin/activate
Start the Next.js and FastAPI development servers:
pnpm dev
To learn more about the AI SDK, Next.js, and FastAPI take a look at the following resources: