VercelLogotypeVercelLogotype
LoginSign Up

@mux/ai + Vercel Workflows Starter

A Next.js starter template demonstrating how to build durable video AI pipelines with @mux/ai and the Vercel Workflow DevKit.

DeployView Demo

@mux/ai + Vercel Workflows Starter

A Next.js starter template demonstrating how to build durable video AI pipelines with @mux/ai and the Vercel Workflow DevKit.

šŸš€ Deploy to Vercel

Three Integration Layers

LayerPatternExample
1. PrimitivesCall functions directlygetSummaryAndTags() — instant results
2. WorkflowsRun durably via Vercel WorkflowstranslateCaptions, translateAudio — retries, progress tracking
3. ConnectorsCompose with external toolsClip creation with Remotion — multi-step pipelines

Resumable workflows (try it)

This project showcases resumable, durable workflows out of the box:

  • Start a workflow (captions, dubbing, or summary).
  • Refresh the page, or navigate away and back.
  • You should see the workflow still running asynchronously, with status rehydrated from browser localStorage.

Quick Start

npm install
npm run dev

Inspect workflow runs locally:

npx workflow web

Rate Limiting

This demo includes IP-based rate limiting to protect against excessive API costs. Limits are automatically bypassed in development mode.

EndpointLimitWindow
translate-audio324h
translate-captions1024h
render624h
summary1024h
search501h

See DOCS/RATE-LIMITS.md for implementation details and maintenance.

Remotion support

Remotion is used within this example app for composing @mux/ai with video rendering.

Local Development

# Open the Remotion Studio for live preview and iteration
npm run remotion:studio
# Render a video locally (for testing)
# Pass the composition name as an argument
npm run remotion:render:local default-composition
# Optionally specify an output path
npm run remotion:render:local default-composition out/foo.mp4

Production Deployment

# Deploy Remotion site to AWS Lambda for serverless rendering
npm run remotion:deploy

Note: remotion:deploy bundles and deploys your Remotion site to AWS Lambda for production video rendering. This is not for development — use remotion:studio and remotion:render:local for local dev and testing.

Automated Deployment

Remotion is automatically deployed to AWS Lambda when changes to remotion/ are merged into main. See DOCS/AUTOMATED-REMOTION-DEPLOYMENTS.md for details.

Environment Variables

See AGENTS.md for the full list. At minimum you'll need:

# Mux credentials
MUX_TOKEN_ID=
MUX_TOKEN_SECRET=
# OpenAI (required for embeddings)
OPENAI_API_KEY=
# Database (PostgreSQL with pgvector) — required to store/search the Mux catalog metadata
DATABASE_URL=

Database setup + importing your Mux catalog

This project stores your Mux catalog metadata in Postgres and generates pgvector embeddings for semantic search. The database schema and migrations are managed with Drizzle (see db/schema.ts and db/migrations/), and the db:* scripts use Drizzle Kit.

1) Configure your database connection

Create a .env.local file (this is what both Drizzle and the import script load):

# Database (PostgreSQL + pgvector)
DATABASE_URL="postgresql://USER:PASSWORD@HOST:5432/DB_NAME"
# Mux (used by the import script)
MUX_TOKEN_ID="..."
MUX_TOKEN_SECRET="..."
# Embeddings (used by the import script)
OPENAI_API_KEY="..."

Your Postgres must support pgvector. The first migration will run CREATE EXTENSION IF NOT EXISTS vector;.

2) Run database migrations

Apply the migrations in db/migrations/ (creates tables + indexes and enables pgvector):

npm run db:migrate

3) Import Mux assets (and generate embeddings)

This fetches all ready Mux assets with playback IDs, upserts rows into videos, and writes embedding rows into video_chunks.

npm run import-mux-assets

To embed subtitles from a specific captions track language, pass --language (defaults to en). This should match the language of an existing captions track on the source Mux asset — it does not translate captions:

npm run import-mux-assets -- --language en

4) Understand the database scripts

  • npm run db:generate: Generates new migration files from db/schema.ts (use this after changing the schema).
  • npm run db:migrate: Applies migrations to the database defined by DATABASE_URL.
  • npm run db:studio: Opens Drizzle Studio to inspect tables/rows locally (also uses DATABASE_URL).

Media Detail Page Structure

The media detail page (/media/[slug]) is organized into co-located feature folders:

app/media/[slug]/
ā”œā”€ā”€ media-content.tsx
ā”œā”€ā”€ page.tsx
ā”œā”€ā”€ localization/
│ ā”œā”€ā”€ actions.ts (captions & audio translation)
│ ā”œā”€ā”€ constants.ts
│ └── ui.tsx
ā”œā”€ā”€ player/
│ ā”œā”€ā”€ context.ts
│ ā”œā”€ā”€ provider.tsx
│ ā”œā”€ā”€ ui.tsx
│ └── use-player.ts
ā”œā”€ā”€ social-clips/
│ ā”œā”€ā”€ actions.ts (clip creation & Remotion Lambda rendering)
│ ā”œā”€ā”€ constants.ts
│ ā”œā”€ā”€ preview.tsx (client-side Remotion Player preview)
│ └── ui.tsx
ā”œā”€ā”€ summarize-and-tag/
│ ā”œā”€ā”€ actions.ts (start/poll summary generation workflow)
│ └── ui.tsx
ā”œā”€ā”€ transcript/
│ ā”œā”€ā”€ actions.ts (semantic search within video transcript)
│ ā”œā”€ā”€ helpers.ts
│ └── ui.tsx
└── workflows-panel/
ā”œā”€ā”€ helpers.ts
└── ui.tsx (includes StatusBadge, StepProgress, etc.)

Learn More

  • context/application-explained.md — what the app does and why
  • context/design-explained.md — visual design and UX patterns
  • context/implementation-explained.md — routes, data model, and code patterns
  • AGENTS.md — guidance for AI coding assistants
  • DOCS/RATE-LIMITS.md — rate limiting configuration and maintenance

See Also

  • pgvector — vector embeddings and similarity search for Postgres
GitHub Repomuxinc/nextjs-video-ai-workflows
Use Cases
Starter
AI
Stack
Next.js
Tailwind
CMS
Mux

Related Templates

Get Started

  • Templates
  • Supported frameworks
  • Marketplace
  • Domains

Build

  • Next.js on Vercel
  • Turborepo
  • v0

Scale

  • Content delivery network
  • Fluid compute
  • CI/CD
  • Observability
  • AI GatewayNew
  • Vercel AgentNew

Secure

  • Platform security
  • Web Application Firewall
  • Bot management
  • BotID
  • SandboxNew

Resources

  • Pricing
  • Customers
  • Enterprise
  • Articles
  • Startups
  • Solution partners

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Community

Frameworks

  • Next.js
  • Nuxt
  • Svelte
  • Nitro
  • Turbo

SDKs

  • AI SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDK
  • Streamdown AINew

Use Cases

  • Composable commerce
  • Multi-tenant platforms
  • Web apps
  • Marketing sites
  • Platform engineers
  • Design engineers

Company

  • About
  • Careers
  • Help
  • Press
  • Legal
  • Privacy Policy

Community

  • Open source program
  • Events
  • Shipped on Vercel
  • GitHub
  • LinkedIn
  • X
  • YouTube

Loading status…

Select a display theme:
    • AI Cloud
      • AI Gateway

        One endpoint, all your models

      • Sandbox

        Isolated, safe code execution

      • Vercel Agent

        An agent that knows your stack

      • AI SDK

        The AI Toolkit for TypeScript

      • v0

        Build applications with AI

    • Core Platform
      • CI/CD

        Helping teams ship 6Ɨ faster

      • Content Delivery

        Fast, scalable, and reliable

      • Fluid Compute

        Servers, in serverless form

      • Workflow

        Long-running workflows at scale

      • Observability

        Trace every step

    • Security
      • Bot Management

        Scalable bot protection

      • BotID

        Invisible CAPTCHA

      • Platform Security

        DDoS Protection, Firewall

      • Web Application Firewall

        Granular, custom protection

    • Company
      • Customers

        Trusted by the best teams

      • Blog

        The latest posts and changes

      • Changelog

        See what shipped

      • Press

        Read the latest news

      • Events

        Join us at an event

    • Learn
      • Docs

        Vercel documentation

      • Academy

        Linear courses to level up

      • Knowledge Base

        Find help quickly

      • Community

        Join the conversation

    • Open Source
      • Next.js

        The native Next.js platform

      • Nuxt

        The progressive web framework

      • Svelte

        The web’s efficient UI framework

      • Turborepo

        Speed with Enterprise scale

    • Use Cases
      • AI Apps

        Deploy at the speed of AI

      • Composable Commerce

        Power storefronts that convert

      • Marketing Sites

        Launch campaigns fast

      • Multi-tenant Platforms

        Scale apps with one codebase

      • Web Apps

        Ship features, not infrastructure

    • Tools
      • Marketplace

        Extend and automate workflows

      • Templates

        Jumpstart app development

      • Partner Finder

        Get help from solution partners

    • Users
      • Platform Engineers

        Automate away repetition

      • Design Engineers

        Deploy for every idea

  • Enterprise
  • Pricing
Log InContact
Sign Up
Sign Up
DeployView Demo
AI Gateway

One endpoint, all your models

Sandbox

Isolated, safe code execution

Vercel Agent

An agent that knows your stack

AI SDK

The AI Toolkit for TypeScript

v0

Build applications with AI

CI/CD

Helping teams ship 6Ɨ faster

Content Delivery

Fast, scalable, and reliable

Fluid Compute

Servers, in serverless form

Workflow

Long-running workflows at scale

Observability

Trace every step

Bot Management

Scalable bot protection

BotID

Invisible CAPTCHA

Platform Security

DDoS Protection, Firewall

Web Application Firewall

Granular, custom protection

Customers

Trusted by the best teams

Blog

The latest posts and changes

Changelog

See what shipped

Press

Read the latest news

Events

Join us at an event

Docs

Vercel documentation

Academy

Linear courses to level up

Knowledge Base

Find help quickly

Community

Join the conversation

Next.js

The native Next.js platform

Nuxt

The progressive web framework

Svelte

The web’s efficient UI framework

Turborepo

Speed with Enterprise scale

AI Apps

Deploy at the speed of AI

Composable Commerce

Power storefronts that convert

Marketing Sites

Launch campaigns fast

Multi-tenant Platforms

Scale apps with one codebase

Web Apps

Ship features, not infrastructure

Marketplace

Extend and automate workflows

Templates

Jumpstart app development

Partner Finder

Get help from solution partners

Platform Engineers

Automate away repetition

Design Engineers

Deploy for every idea