Vercel AI SDK
Launch Express provides seamless integration with the Vercel AI SDK, allowing you to easily incorporate various AI models into your NextJS application. This guide will walk you through the process of setting up and using the Vercel AI SDK in your project.
Prerequisites
- API keys for the AI services you plan to use (e.g., OpenAI, Anthropic, Google, etc.)
Setup
- Add the API keys to your environment variables
- The boilerplate already includes the necessary configuration for the Vercel AI SDK in
src/lib/ai/ai-sdk
. This file initializes the Vercel AI SDK with your API keys.
Usage
To use the Vercel AI SDK in your application, you can create an API route that interacts with the AI models provided by the SDK. This route can be used to generate images, text, and more using the AI models provided by the various services.
Create a new file in your API routes directory (e.g., app/api/ai-sdk/route.ts
). This file will contain the logic for interacting with the Vercel AI SDK.
Here’s an example of how to set up a route that uses the OpenAI model:
Model Selection
The Vercel AI SDK provides access to various AI models from different services. You can use these models to generate text, images, and more. Here are some of the models available in the Vercel AI SDK:
- Anthropic
- Fireworks
- Google Generative AI
- Groq
- Mistral
- OpenAI
- Perplexity
- Vertex AI
Was this page helpful?