Skip to content
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Passport
  • Connect
  • eve
Core Platform
  • Build and deploy
  • Vercel CI
  • Fluid Compute
  • Content Delivery
  • Observability
  • Workflows
  • Security
Tools
  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Open Source
  • Domains↗
  • v0↗
Learn
  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base
Build
  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
Explore
  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community↗
EnterprisePricing
Contact
Log InSign Up
Dashboard

Products
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Passport
  • Connect
  • eve
Core Platform
  • Build and deploy
  • Vercel CI
  • Fluid Compute
  • Content Delivery
  • Observability
  • Workflows
  • Security
Tools
  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Open Source
  • Domains↗
  • v0↗
Resources
Learn
  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base
Build
  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
Explore
  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community↗
Enterprise
Pricing
Sign UpLog In
Contact
Templates
Template name

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • ConnectNew
  • PassportNew
  • eveNew

Core Platform

  • Build and deploy
  • Vercel CINew
  • Fluid Compute
  • Content Delivery
  • Observability

Security

  • Platform Security
  • WAF
  • Bot Management
  • BotID

Tools

  • Vercel Drop
  • Vercel Agent
  • Vercel Plugin
  • Agent Skills
  • Domains
  • v0

Frameworks

  • eveNew
  • Next.js
  • Nuxt
  • SvelteKit
  • Nitro
  • Turborepo
  • Tanstack Start
  • FastAPI
  • All frameworks

SDKs

  • Vercel SDK
  • Workflow SDK
  • Flags SDK
  • Chat SDK
  • Queues SDK
  • Streamdown

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
  • Platform Engineers
  • Design Engineers

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Articles
  • Community
  • Is Agentic

Explore

  • Customers
  • Marketplace
  • Templates
  • Partner Finder
  • Vercel + AWS

Company

  • About
  • Careers
  • Press
  • Events
  • Startups
  • Shipped on Vercel
  • Open Source Program
  • Enterprise
  • Pricing
  • Help

Legal & Trust

  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • DPA
  • Acceptable Use Policy
  • Legal (all documents)
  • Trust Center
  • Status

Social

  • GitHub
  • X
  • LinkedIn
  • YouTube
  • Instagram
  • VercelVercel
Templates
Template name

Loading status…

Select a display theme:
Templates

Express + AI SDK

Using AI SDK in an Express app.

DeployView Demo
Owner
  • vercel
Repository
  • ai
Use Cases
  • AI
  • Backend
Stack
  • Other
  • None
DeployView Demo

Express.js + AI SDK Example

You can use the AI SDK in an Express.js server to generate and stream text and objects.

Usage

  1. Create .env file with the following content (and more settings, depending on the providers you want to use):
OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
  1. Run the following commands from the root directory of the AI SDK repo:
pnpm install
pnpm build
  1. Run the following command:
pnpm dev
  1. Test the endpoint with Curl:
curl -X POST http://localhost:8080
curl -X POST http://localhost:8080/custom-data-parts
curl -i http://localhost:8080/chat \
-H "Content-Type: application/json" \
--data '{ "messages":[{"role":"user","id":"msg1","parts":[{"type":"text","text":"what happened yesterday in tech?"}]}]}'

Related Templates

  • Express.js on Vercel thumbnail

    Express.js on Vercel

    Simple Express.js + Vercel example that serves html content, JSON data and simulates an API route.

  • Hono + AI SDK thumbnail

    Hono + AI SDK

    Using AI SDK with a Hono backend

License
  • View License