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

A Next.js starter template demonstrating how to build durable video AI pipelines with @mux/ai and the Vercel Workflow DevKit.
| Layer | Pattern | Example |
|---|---|---|
| 1. Primitives | Call functions directly | getSummaryAndTags() β instant results |
| 2. Workflows | Run durably via Vercel Workflows | translateCaptions, translateAudio β retries, progress tracking |
| 3. Connectors | Compose with external tools | Clip creation with Remotion β multi-step pipelines |
This project showcases resumable, durable workflows out of the box:
localStorage.npm installnpm run dev
Inspect workflow runs locally:
npx workflow web
This demo includes IP-based rate limiting to protect against excessive API costs. Limits are automatically bypassed in development mode.
| Endpoint | Limit | Window |
|---|---|---|
translate-audio | 3 | 24h |
translate-captions | 10 | 24h |
render | 6 | 24h |
summary | 10 | 24h |
search | 50 | 1h |
See DOCS/RATE-LIMITS.md for implementation details and maintenance.
Remotion is used within this example app for composing @mux/ai with video rendering.
# Open the Remotion Studio for live preview and iterationnpm run remotion:studio# Render a video locally (for testing)# Pass the composition name as an argumentnpm run remotion:render:local default-composition# Optionally specify an output pathnpm run remotion:render:local default-composition out/foo.mp4
# Deploy Remotion site to AWS Lambda for serverless renderingnpm run remotion:deploy
Note:
remotion:deploybundles and deploys your Remotion site to AWS Lambda for production video rendering. This is not for development β useremotion:studioandremotion:render:localfor local dev and testing.
Remotion is automatically deployed to AWS Lambda when changes to remotion/ are merged into main. See DOCS/AUTOMATED-REMOTION-DEPLOYMENTS.md for details.
See AGENTS.md for the full list. At minimum you'll need:
# Mux credentialsMUX_TOKEN_ID=MUX_TOKEN_SECRET=# OpenAI (required for embeddings)OPENAI_API_KEY=# Database (PostgreSQL with pgvector) β required to store/search the Mux catalog metadataDATABASE_URL=
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.
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 runCREATE EXTENSION IF NOT EXISTS vector;.
Apply the migrations in db/migrations/ (creates tables + indexes and enables pgvector):
npm run db:migrate
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
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).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.)
context/application-explained.md β what the app does and whycontext/design-explained.md β visual design and UX patternscontext/implementation-explained.md β routes, data model, and code patternsAGENTS.md β guidance for AI coding assistantsDOCS/RATE-LIMITS.md β rate limiting configuration and maintenancepgvector β vector embeddings and similarity search for Postgres