The Vercel AI SDK is a development kit launched by Vercel, the front-end website development and hosting platform and the development team of Next.js. It can be used to quickly build AI chatbot web application programs and assist developers in building conversational AI user interfaces using JavaScript and TypeScript.
Features of Vercel AI SDK
- Supports front-end frameworks such as React/Next.js, Svelte/SvelteKit and Vue/Nuxt, as well as Node.js, Serverless and Edge Runtime.
- Built-in adapters for various AI models, supporting large language models provided by LangChain, OpenAI, Anthropic and Hugging Face.
- Provides an interactive online prompt playground, which contains 20 open-source and cloud LLMs. It can display the chat interfaces of different dialogue models in real time and quickly generate code.
- Provides multiple templates and examples of AI chatbots. You can clone/copy the initial templates of AI chatbots developed by Vercel based on different frameworks and models.
How to Use the Vercel AI SDK
- The prerequisite is to install Node.js version 18+ on your computer. If you want to develop a GPT chatbot based on OpenAI, you need to obtain an OpenAI API key.
- Create a brand-new project using frameworks such as Next.js (
pnpm dlx create-next-app my-ai-app
) or Svelte (pnpm create svelte@latest my-ai-app
), and navigate to the created directory (cd my-ai-app
).
- Install dependencies:
pnpm install ai openai-edge
.
- Configure the OpenAI API key. Create a file named
.env.local
in the root directory of the project and add your OpenAI API key to it.
- Create an API route and connect it to the UI. After completion, run the application by using
pnpm run dev
.