Skip to content
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Passport
  • Connect
  • eve
Core Platform
  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • Workflows
  • CI/CD
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
  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • Workflows
  • CI/CD
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

Jev x AI SDK Form Router

Three forms use Jev and AI SDK to route submissions by context.

DeployView Demo
Template Thumbnail

Three forms use Jev to route submissions by context, with openai/gpt-5.6-luna-fast handling uncertain or failed evaluations. Includes editable samples, routing details, and optional email delivery.

Tech Stack

TechnologyPurpose
Next.js 16 and React 19App Router, shared form UI, and Server Actions
AI SDK 7 and Vercel AI GatewayTyped model calls and provider access
shadcn/ui, Base UI, and Tailwind CSS 4Components and styling
React Email and ResendEmail previews and optional delivery

Getting Started

Prerequisites

  • Node.js 22+
  • pnpm package manager

1. Clone and install

git clone https://github.com/vercel-labs/jev-ai-sdk-form-router.git
cd jev-ai-sdk-form-router
pnpm install

2. Configure AI Gateway

Routing a submission, including a sample, makes live model calls and requires AI Gateway access to both typesafe-ai/jev and openai/gpt-5.6-luna-fast. Choose one of the authentication options below, or skip this step to explore the forms and load sample inputs without generating routing results.

API Key

Copy the environment example:

cp .env.example .env.local

Create a Vercel AI Gateway key and set AI_GATEWAY_API_KEY in .env.local.

Vercel OIDC

Vercel deployments use automatic OIDC authentication through the SDK, without an API key. To use OIDC locally, install the Vercel CLI if needed, then link the project and pull its environment variables:

npm install --global vercel
vercel link
vercel env pull .env.local

3. Start the app

pnpm dev

Open localhost:3000. The home page redirects to /leads.

ExampleRouteRoutes to
Lead/leadsStartup, growth, enterprise, or sales teams
Contact/contactBilling, support, or general inquiries
Issue Report/issuesFrontend, platform, infrastructure, identity, or engineering teams

How Routing Works

  1. Zod validates the submission against the fields in lib/examples.ts.
  2. Jev evaluates the complete submission using AI SDK’s experimental_evaluate and selects an allowed team/specialty combination.
  3. The app accepts Jev’s choice when its confidence is at least 95%.
  4. If confidence is lower, missing, or invalid, or Jev fails, openai/gpt-5.6-luna-fast independently evaluates the same submission and criteria using generateText and Output.object. Its choice becomes final.
  5. The result includes the destination, deciding model, Jev statistics, model timings, and an email preview.

Confidence and selected-option probability are separate metrics. The threshold uses the unrounded value of providerMetadata.typesafe.confidence.destination. Jev’s displayed statistics remain attached to its original evaluation when the fallback model makes the final decision.

Provider calls have bounded timeouts and one transient retry. If both models fail, the app returns a retryable error and sends no email.

Optional email delivery

Set up Resend through Vercel Marketplace

The Resend Marketplace integration creates a Resend account and connects it to your Vercel project. During setup, you can select an existing Vercel domain or purchase one.

  1. If you haven't already, install the Vercel CLI and link the project:

    npm install --global vercel
    vercel link
  2. Start the integration setup:

    vercel i resend
  3. Select an existing domain or purchase one through Vercel, then choose a plan and connect your project. Complete onboarding in Resend, choose Auto configure to add the DNS records, and wait for domain verification.

  4. Pull the integration's environment variables for local development:

    vercel env pull .env.local
  5. Confirm RESEND_API_KEY is present and set RESEND_FROM in .env.local to a sender address on your verified domain.

If you already have a Resend account, you can instead set RESEND_API_KEY and RESEND_FROM directly using your existing API key and a verified domain.

Configure receiving inboxes

In lib/recipients.ts, replace null with a valid inbox for every destination on the form you want to enable. Multiple destinations can share an inbox.

An unchecked Email the receiving team checkbox appears on configured forms.

Recipient keys are derived from the destination registry and checked by TypeScript. Addresses stay server-side. The validated submitter email becomes replyTo. Forms with unconfigured inboxes continue to provide previews.

Email failures preserve the routing result. Resend acceptance does not confirm inbox delivery. If a connection drops after an opted-in submission, check Resend before resubmitting.

Customization

FileWhat to change
lib/examples.tsForm fields, samples, destinations, and routing criteria
lib/router.tsModels, confidence threshold, timeouts, and fallback policy
lib/recipients.tsReceiving inboxes
lib/submission.tsValidation, email rendering, and delivery workflow
components/router-form.tsx and components/routing-result.tsxShared form and result UI
emails/routed-submission.tsxEmail design

Keep the experimental AI SDK version pinned and rerun the checks when upgrading it.

Checks

pnpm fix # Format and apply lint fixes
pnpm validate # Lint, type check, Knip, and tests
pnpm build # Production build

Tests mock the model providers and Resend. They make no external calls. Coverage includes confidence thresholds, fallback decisions, validation, recipient configuration, and delivery retries.

Resources

  • Jev documentation
  • Jev and AI SDK guide
  • AI SDK evaluation
  • React Email
GitHub
Ownervercel-labs
Repositoryjev-ai-sdk-form-router
LicenseView License
Use Cases
Starter
AI
CDN
Stack
Next.js
Tailwind
CSS

Related Templates

eve Incident Response Agent

sre investigates production issues using a hypothesis-driven approach and outputs verifiable evidence from connected sources.
eve Incident Response Agent thumbnail

eve Software Factory

Software factory built on eve: AI agents work each stage of the development loop, and people make the judgment calls.
eve Software Factory thumbnail

Claude Managed Agents with Chat SDK

Ship a Slack research bot built on Claude Managed Agents and Chat SDK.
Claude Managed Agents with Chat SDK thumbnail

Agent Stack

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

Core Platform

  • CI/CD
  • Content Delivery
  • Fluid Compute
  • Observability

Security

  • Platform Security
  • WAF
  • Bot Management
  • BotID

Tools

  • Vercel DropNew
  • Vercel Agent
  • Vercel PluginNew
  • Agent Skills
  • Domains
  • v0

Frameworks

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

SDKs

  • Vercel SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDKNew
  • Queues SDKNew
  • 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
DeployView Demo

Loading status…

Select a display theme: