Skip to Content

Jev x AI SDK Form Router

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

Tech Stack

Technology

Purpose

Next.js 16 and React 19

Components and styling

App Router, shared form UI, and Server Actions

shadcn/ui, Base UI, and Tailwind CSS 4

React Email and Resend

AI SDK 7 and Vercel AI Gateway

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.

Typed model calls and provider access

Email previews and optional delivery

Getting Started

Prerequisites


1. Clone and install

3

pnpminstall

2 cd jev-ai-sdk-form-router

2. Configure AI Gateway

  • Node.js 22+
  • pnpm package manager

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

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:

1 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:

2 vercel link

3. Start the app

3 vercel env pull .env.local

You can reach our customer support team by emailing info@yourcompany.example.com, calling +1 555-555-5556, or using the live chat on our website. Our dedicated team is available 24/7 to assist with any inquiries or issues.

We’re committed to providing prompt and effective solutions to ensure your satisfaction.

We offer a 30-day return policy for all products. Items must be in their original condition, unused, and include the receipt or proof of purchase. Refunds are processed within 5-7 business days of receiving the returned item.

Example

Lead

Route

/leads

Routes to

Startup, growth, enterprise, or sales teams

Contact

Issue Report

/contact

/issues

Billing, support, or general inquiries

Frontend, platform, infrastructure, identity, or engineering teams

  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.

Customization

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.

Set up Resend through Vercel Marketplace


File

lib/examples.ts


What to change

Receiving inboxes

Form fields, samples, destinations, and routing criteria

Models, confidence threshold, timeouts, and fallback policy

Validation, email rendering, and delivery workflow

Shared form and result UI

Checks

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


3 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.

2 pnpm validate # Lint, type check, Knip, and tests

1 pnpm fix # Format and apply lint fixes