📄 ai-sdk/docs/advanced/vercel-deployment-guide

File: vercel-deployment-guide.md | Updated: 11/15/2025

Source: https://ai-sdk.dev/docs/advanced/vercel-deployment-guide

AI SDK

Menu

v5 (Latest)

AI SDK 5.x

AI SDK by Vercel

AI SDK 6 Beta

Foundations

Overview

Providers and Models

Prompts

Tools

Streaming

Getting Started

Navigating the Library

Next.js App Router

Next.js Pages Router

Svelte

Vue.js (Nuxt)

Node.js

Expo

Agents

Agents

Building Agents

Workflow Patterns

Loop Control

AI SDK Core

Overview

Generating Text

Generating Structured Data

Tool Calling

Model Context Protocol (MCP) Tools

Prompt Engineering

Settings

Embeddings

Image Generation

Transcription

Speech

Language Model Middleware

Provider & Model Management

Error Handling

Testing

Telemetry

AI SDK UI

Overview

Chatbot

Chatbot Message Persistence

Chatbot Resume Streams

Chatbot Tool Usage

Generative User Interfaces

Completion

Object Generation

Streaming Custom Data

Error Handling

Transport

Reading UIMessage Streams

Message Metadata

Stream Protocols

AI SDK RSC

Advanced

Prompt Engineering

Stopping Streams

Backpressure

Caching

Multiple Streamables

Rate Limiting

Rendering UI with Language Models

Language Models as Routers

Multistep Interfaces

Sequential Generations

Vercel Deployment Guide

Reference

AI SDK Core

AI SDK UI

AI SDK RSC

Stream Helpers

AI SDK Errors

Migration Guides

Troubleshooting

Copy markdown

Vercel Deployment Guide

============================================================================================================

In this guide, you will deploy an AI application to Vercel using Next.js (App Router).

Vercel is a platform for developers that provides the tools, workflows, and infrastructure you need to build and deploy your web apps faster, without the need for additional configuration.

Vercel allows for automatic deployments on every branch push and merges onto the production branch of your GitHub, GitLab, and Bitbucket projects. It is a great option for deploying your AI application.

Before You Begin


To follow along with this guide, you will need:

  • a Vercel account
  • an account with a Git provider (this tutorial will use Github )
  • an OpenAI API key

This guide will teach you how to deploy the application you built in the Next.js (App Router) quickstart tutorial to Vercel. If you haven’t completed the quickstart guide, you can start with this repo .

Commit Changes


Vercel offers a powerful git-centered workflow that automatically deploys your application to production every time you push to your repository’s main branch.

Before committing your local changes, make sure that you have a .gitignore. Within your .gitignore, ensure that you are excluding your environment variables (.env) and your node modules (node_modules).

If you have any local changes, you can commit them by running the following commands:

git add .git commit -m "init"

Create Git Repo


You can create a GitHub repository from within your terminal, or on github.com . For this tutorial, you will use the GitHub CLI (more info here ).

To create your GitHub repository:

  1. Navigate to github.com

  2. In the top right corner, click the "plus" icon and select "New repository"

  3. Pick a name for your repository (this can be anything)

  4. Click "Create repository"

Once you have created your repository, GitHub will redirect you to your new repository.

  1. Scroll down the page and copy the commands under the title "...or push an existing repository from the command line"
  2. Go back to the terminal, paste and then run the commands

Note: if you run into the error "error: remote origin already exists.", this is because your local repository is still linked to the repository you cloned. To "unlink", you can run the following command:

rm -rf .gitgit initgit add .git commit -m "init"

Rerun the code snippet from the previous step.

Import Project in Vercel


On the New Project page, under the Import Git Repository section, select the Git provider that you would like to import your project from. Follow the prompts to sign in to your GitHub account.

Once you have signed in, you should see your newly created repository from the previous step in the "Import Git Repository" section. Click the "Import" button next to that project.

Add Environment Variables

Your application stores uses environment secrets to store your OpenAI API key using a .env.local file locally in development. To add this API key to your production deployment, expand the "Environment Variables" section and paste in your .env.local file. Vercel will automatically parse your variables and enter them in the appropriate key:value format.

Deploy

Press the Deploy button. Vercel will create the Project and deploy it based on the chosen configurations.

Enjoy the confetti!

To view your deployment, select the Project in the dashboard and then select the Domain. This page is now visible to anyone who has the URL.

Considerations


When deploying an AI application, there are infrastructure-related considerations to be aware of.

Function Duration

In most cases, you will call the large language model (LLM) on the server. By default, Vercel serverless functions have a maximum duration of 10 seconds on the Hobby Tier. Depending on your prompt, it can take an LLM more than this limit to complete a response. If the response is not resolved within this limit, the server will throw an error.

You can specify the maximum duration of your Vercel function using route segment config . To update your maximum duration, add the following route segment config to the top of your route handler or the page which is calling your server action.

export const maxDuration = 30;

You can increase the max duration to 60 seconds on the Hobby Tier. For other tiers, see the documentation for limits.

Security Considerations


Given the high cost of calling an LLM, it's important to have measures in place that can protect your application from abuse.

Rate Limit

Rate limiting is a method used to regulate network traffic by defining a maximum number of requests that a client can send to a server within a given time frame.

Follow this guide to add rate limiting to your application.

Firewall

A firewall helps protect your applications and websites from DDoS attacks and unauthorized access.

Vercel Firewall is a set of tools and infrastructure, created specifically with security in mind. It automatically mitigates DDoS attacks and Enterprise teams can get further customization for their site, including dedicated support and custom rules for IP blocking.

Troubleshooting


On this page

Vercel Deployment Guide

Before You Begin

Commit Changes

Create Git Repo

Import Project in Vercel

Add Environment Variables

Deploy

Enjoy the confetti!

Considerations

Function Duration

Security Considerations

Rate Limit

Firewall

Troubleshooting

Deploy and Scale AI Apps with Vercel.

Vercel delivers the infrastructure and developer experience you need to ship reliable AI-powered applications at scale.

Trusted by industry leaders:

  • OpenAI
  • Photoroom
  • leonardo-ai Logoleonardo-ai Logo
  • zapier Logozapier Logo

Talk to an expert