vercel/ai/examples/next-fastapi

Vercel AI SDK's FastAPI template using Next

reactnexttailwindtypescriptai
Loading...
vercel

AI SDK, Next.js, and FastAPI Examples

These examples show you how to use the AI SDK with Next.js and FastAPI.

How to use

Execute create-next-app with npm, Yarn, or pnpm to bootstrap the example:

npx create-next-app --example https://github.com/vercel/ai/tree/main/examples/next-fastapi next-fastapi-app
yarn create next-app --example https://github.com/vercel/ai/tree/main/examples/next-fastapi next-fastapi-app
pnpm create next-app --example https://github.com/vercel/ai/tree/main/examples/next-fastapi next-fastapi-app

You will also need Python 3.6+ and virtualenv installed to run the FastAPI server.

To run the example locally you need to:

  1. Sign up at OpenAI's Developer Platform.
  2. Go to OpenAI's dashboard and create an API KEY.
  3. Set the required environment variables as shown in the example env file but in a new file called .env.local.
  4. virtualenv venv to create a python virtual environment.
  5. source venv/bin/activate to activate the python virtual environment.
  6. pip install -r requirements.txt to install the required python dependencies.
  7. pnpm install to install the required dependencies.
  8. pnpm dev to launch the development server.

Learn More

To learn more about the AI SDK, Next.js, and FastAPI take a look at the following resources: