AI on Vercel: tools, templates, and stack choices

Vercel has become a common home for AI experiments and production deployments alike, with projects ranging from a Stable Diffusion search engine to AI-powered visual editing tools. Whether you're new to machine learning or shipping it at scale, the platform's templates and managed infrastructure are designed to get AI apps running quickly.

Note: Guidance in this article reflects practices from 2023. For current AI deployments, Vercel recommends using Vercel Functions with Fluid compute and streaming responses.

Choosing your AI building blocks

A headless stack on Vercel lets you connect data and integrate AI capabilities into any framework you already use. The main decisions come down to which model, how to run it, and which front-end framework fits your workflow.

OpenAI models

ChatGPT is a natural language processing model built for conversational context and sentiment analysis. For other text generation tasks, OpenAI offers GPT-3 variants—DaVinci, Curie, Babbage, and Ada—each tuned for specific tasks. You can compare them side by side in the AI Playground or stress test DaVinci with the Twitter Bio Generator and GPT-3 Chatbot templates.

Whisper, also from OpenAI, handles speech recognition. Trained on over 680,000 hours of audio across 97 languages, it transcribes speech to text and can translate between languages, handling accents and background noise. DALL·E 2 generates images from natural language and supports outpainting to let existing images influence the output. It can also refine existing images for digital art workflows.

DALL·E 2 competes with Midjourney and Stable Diffusion, but results differ noticeably between these text-to-image models. The DALL·E 2 Art Generator and Inpainting with Stable Diffusion templates demonstrate those differences.

Running models in the cloud

Replicate, itself deployed on Vercel, runs open-source machine learning models on its own GPUs and exposes them through a cloud API. That setup lets teams experiment at scale without maintaining their own server infrastructure. Replicate's catalog includes in-app demos, sample code, and full API documentation for each model.

Framework considerations

Next.js and SvelteKit are both solid choices for AI front ends. Several features matter particularly for AI workloads:

  • API routes: Next.js lets you create an API route by adding a file to pages/api; SvelteKit uses a +server.js file anywhere in the project. This keeps AI API code separate and provides a safe location for environment variables.
  • Code splitting: Both frameworks split large apps into smaller bundles loaded on demand or in parallel, cutting page-load downloads and keeping AI applications responsive as they scale.
  • TypeScript integration: TypeScript improves readability and extensibility for complex AI APIs through tighter IDE integration, and enables in either framework during installation.
  • Hot Module Replacement: Both frameworks support HMR, showing local changes without a page refresh and speeding up iteration.

Deploying either framework on Vercel requires just a git commit, with infrastructure management and scaling handled by the platform. That's particularly useful for AI startups that need to focus resources on product development.

Jasper, an AI writing assistant built with Next.js on Vercel, generates posts, tweets, stories, and other content from user input. The company acquired Outwrite to build an extension that works within Microsoft Word, Google Docs, social media, and other text fields online. A partnership with Surfer adds AI-generated SEO optimization advice.

Infrastructure for long-running AI requests

AI APIs often take time to complete roundtrips, which means long-running requests need infrastructure that can stream responses while the model processes. For current projects, Vercel Functions with Fluid compute support streaming, longer durations, and efficient concurrency. Choosing a function region close to the upstream AI provider can also reduce latency, per the Configuring Function regions documentation.

Collaboration workflows

Comments on Preview Deployments allow teams to review applications from a user's perspective, leaving feedback attached to the visual context where a fix is needed. For AI applications, which can grow complex enough that tracking issues becomes difficult, this keeps iteration fast and teams aligned on user-facing changes.

Viable applies AI to customer feedback, surfacing insights for businesses to improve products and services. The company processes millions of data points for clients including Latch, Uber, and AngelList, with just six engineers. Viable has used Vercel since its 2020 founding, building its product with Next.js to scale infrastructure alongside customer demand. More detail is available in the Viable case study.

Ready-made AI templates

Vercel maintains an expanding AI template collection for hands-on experimentation.

Twitter Bio Generator uses the OpenAI GPT-3 API (text-davinci-003), constructing a prompt from form input, sending it to the model, and streaming the response back through a Vercel Function. For long AI responses, see Streaming Functions and Fluid compute.

AI Room Generator applies the ControlNet model to generate variations of real rooms. Users upload a photo, add a prompt, and get a transformed version of the space. The model runs on Replicate, with image storage through Upload.

Photo Restorer restores old face photos using GFPGAN, an applied research model from the Applied Research Center, hosted on Replicate. Uploads go through a Next.js API route to the model, and the restored photo is returned to the browser.