
Template details
Jev x AI SDK Form Router
Next.js 16 starter with three forms that route submissions to the right team using Jev, with a GPT fallback model for low-confidence cases.
About this template
Jev x AI SDK Form Router is a Next.js 16 starter template from Vercel Labs that takes a form submission, evaluates its context with the Jev model (typesafe-ai/jev), and routes it to a matching team or specialty, falling back to openai/gpt-5.6-luna-fast when confidence is low.
What is Jev x AI SDK Form Router?
Jev x AI SDK Form Router is an open-source Next.js application template that classifies form submissions and sends each one to the correct internal destination. It runs on Next.js 16 and React 19 with the App Router and Server Actions, shipped by Vercel Labs. Submissions enter through one of three forms — Lead, Contact, or Issue Report — and come back out as a routing decision with the destination, the model that decided it, Jev confidence statistics, model timings, and an optional email preview.
What makes Jev x AI SDK Form Router stand out?
- Two-model routing with a confidence gate — Jev evaluates the full submission using AI SDK's
experimental_evaluate; the app accepts its choice only when confidence is at least 95%, otherwiseopenai/gpt-5.6-luna-fastre-evaluates the same criteria withgenerateTextandOutput.object, and its choice becomes final. - Three prebuilt routing forms — Lead at
/leadsroutes to startup, growth, enterprise, or sales teams; Contact at/contactroutes to billing, support, or general inquiries; Issue Report at/issuesroutes to frontend, platform, infrastructure, identity, or engineering teams. - Zod validation layer — every submission is validated against the field definitions in
lib/examples.tsbefore any model call is made. - Editable samples — each form ships with sample inputs you can load without AI Gateway credentials, so the UI can be explored without generating routing results.
- Optional email delivery — React Email templates render a preview, and Resend sends the routed submission to configured inboxes when the receiving team is checked on the form.
- Tech stack — Next.js 16, React 19, AI SDK 7 with the Vercel AI Gateway, shadcn/ui, Base UI, Tailwind CSS 4, React Email, and Resend.
- Bounded provider calls — provider requests use timeouts plus a single transient retry; if both models fail the app returns a retryable error and sends no email.
- Mocked test suite — tests stub the model providers and Resend, make no external calls, and cover confidence thresholds, fallback decisions, validation, recipient configuration, and delivery retries.
How does the routing work?
After Zod validates the submission, Jev evaluates it and selects an allowed team/specialty combination. The 95% threshold uses the unrounded value of providerMetadata.typesafe.confidence.destination, not Jev's displayed selected-option probability, and Jev's statistics stay attached to its original evaluation even when the fallback model makes the final call.
Who should use this template?
- SaaS teams triaging inbound leads: route demo requests to sales, growth, or enterprise owners without building a custom classifier.
- Support organizations: send billing, support, and general contact messages to the right queue from a single form.
- Engineering teams running an issue intake page: separate frontend, platform, infrastructure, and identity reports before they hit a tracker.
- Developers evaluating Jev or AI SDK evaluation APIs: the router, confidence threshold, and fallback policy are all configurable in
lib/router.ts.
What can you do with it?
- Deploy to Vercel: the repository deploys with a single click and uses automatic OIDC authentication for AI Gateway, so no API key needs to be stored manually.
- Swap in your own taxonomy: edit
lib/examples.tsto change form fields, samples, destinations, and routing criteria. - Turn on email notifications: configure inboxes in
lib/recipients.ts, setRESEND_FROMon a verified domain, and an "Email the receiving team" checkbox appears on the form. - Tune the models: change model IDs, the confidence threshold, timeouts, and fallback policy in
lib/router.ts.
FAQ
What do I need to run this template locally?
Node.js 22 or newer and pnpm. Clone the repository, run pnpm install, optionally set AI_GATEWAY_API_KEY in .env.local (or link the project with the Vercel CLI for OIDC), then run pnpm dev and open localhost port 3000, which redirects to /leads.
Can I use the forms without AI Gateway access?
Yes. Skipping the AI Gateway configuration step lets you explore the forms and load sample inputs, but submitting a form makes live model calls, so no routing result is produced without access to typesafe-ai/jev and openai/gpt-5.6-luna-fast.
How is the 95% confidence threshold calculated?
The threshold uses the unrounded value of providerMetadata.typesafe.confidence.destination, which is a separate metric from Jev's displayed selected-option probability. If confidence is lower, missing, invalid, or Jev fails outright, the fallback model's decision becomes final.
Does the template require Resend to work?
No. Email delivery is optional, and forms with unconfigured inboxes still show routing results and email previews. Email failures preserve the routing result, and Resend acceptance does not confirm inbox delivery.
Which files do I edit to customize routing?
lib/examples.ts holds form fields, samples, destinations, and criteria; lib/router.ts holds models, threshold, timeouts, and fallback policy; lib/recipients.ts holds inboxes; lib/submission.ts holds validation and delivery; and the UI lives in components/router-form.tsx, components/routing-result.tsx, and emails/routed-submission.tsx.















