Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
A Next.js chatbot using the Vercel AI SDK's streamText function to automatically handle multiple tool call roundtrips.
This example demonstrates how to use the Vercel AI SDK with Next.js and the streamText function to automatically handle multiple tool steps. This template provides a Next.js chatbot that leverages the Vercel AI SDK for advanced AI interactions, specifically focusing on managing complex conversational flows that require multiple tool calls.
You can deploy this template directly to Vercel by clicking the "Deploy" button on the template page or by cloning the repository. You will need an OpenAI API key.
To run the example locally, follow these steps:
Bootstrap the example using create-next-app with your preferred package manager:
npx create-next-app --example https://github.com/vercel-labs/ai-sdk-preview-roundtrips ai-sdk-preview-roundtrips-exampleyarn create next-app --example https://github.com/vercel-labs/ai-sdk-preview-roundtrips ai-sdk-preview-roundtrips-examplepnpm create next-app --example https://github.com/vercel-labs/ai-sdk-preview-roundtrips ai-sdk-preview-roundtrips-exampleSign up for AI provider accounts (e.g., OpenAI, Anthropic) and obtain their respective API keys.
Set environment variables: Create a new file named .env in the project root and populate it with the required API keys, following the structure of .env.example. For instance, OPENAI_API_KEY=your_openai_api_key_here.
Install dependencies: Run npm install (or yarn install, pnpm install) to install all necessary project dependencies.
Launch development server: Execute npm run dev (or yarn dev, pnpm dev) to start the local development server.