How-to

Vercel and OpenAI Integration

Integrate your Vercel project with OpenAI's powerful suite of models.
Table of Contents

Vercel integrates with OpenAI to enable developers to build fast, scalable, and secure AI applications.

You can integrate with any OpenAI model through its REST API or JavaScript SDK, including the following OpenAI models:

  • GPT-3.5: Understand and generate natural language or code
  • GPT-4: An advanced model for natural language processing
  • DALL·E: Generate and edit images from natural language
  • Whisper: Convert audio to text
  • Embeddings: Convert term into vectors

To help you get started, we have built a variety of AI templates integrating OpenAI with Vercel.

Before you begin, ensure you have an OpenAI account. Once registered:

  1. Log into your OpenAI Dashboard and view API keys.

  2. Click on Create new secret key. Copy the generated API key securely.

    Always keep your API keys confidential. Do not expose them in client-side code. Use Vercel Environment Variables for safe storage and do not commit these values to git.

  3. Finally, add the OPENAI_API_KEY environment variable in your project:

    .env.local
    OPENAI_API_KEY='sk-...3Yu5'

Integrating OpenAI into your Vercel project is seamless with the Vercel AI SDK.

Install the Vercel AI SDK in your project with your favorite package manager:

pnpm
yarn
npm
pnpm i ai

You can use the SDK to build AI applications with React (Next.js), Vue (Nuxt), Svelte (SvelteKit), and Solid (SolidStart).

The Vercel AI SDK also has experimental support for OpenAI Functions.

Learn more about using OpenAI Functions with the AI SDK.

Last updated on July 31, 2024