---
title: "Express + AI SDK"
description: "Using AI SDK in an Express app."
url: "https://vercel.com/templates/other/express-ai-sdk"
links:
  repository: "https://github.com/vercel/ai/tree/main/examples/express"
  demo: "https://express-ai-sdk-demo.vercel.app/"
  deploy: "https://vercel.com/new/clone?demo-title=Express+%2B+AI+SDK&demo-description=Using+AI+SDK+in+an+Express+app.&demo-url=https%3A%2F%2Fexpress-ai-sdk-demo.vercel.app%2F&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F132HjcyT8l5S9tFuaVi22U%2Fa9dac19302af240cd2b0bc44f09b002e%2FFlagsmith_Dark__4_.png&project-name=Express+%2B+AI+SDK&repository-name=express-ai-sdk&repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fai%2Ftree%2Fmain%2Fexamples%2Fexpress&from=templates&skippable-integrations=1&root-directories=List+of+directory+paths+for+the+directories+to+clone+into+projects&project-names=Comma+separated+list+of+project+names%2Cto+match+the+root-directories"
---

# Express + AI SDK

Using AI SDK in an Express app.

# Express.js + AI SDK Example

You can use the AI SDK in an [Express.js](https://expressjs.com/) 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):

```sh
OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
```

2. Run the following commands from the root directory of the AI SDK repo:

```sh
pnpm install
pnpm build
```

3. Run the following command:

```sh
pnpm dev
```

4. Test the endpoint with Curl:

```sh
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

### [Hono + AI SDK](https://vercel.com/templates/hono/hono-ai-sdk)

Using AI SDK with a Hono backend

### [Express.js on Vercel](https://vercel.com/templates/other/express-js-on-vercel)

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

---

## Additional documentation

The [Vercel Knowledge Base](https://vercel.com/kb) contains guides and answers to common questions about Vercel, including deployment, framework configuration, domains, caching, and troubleshooting.
