Public
Remixed
16 typed Jev judgments per keystroke, via Vercel AI Gateway
ai-agentdemotypesafeai-gatewayvercel
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

TypeSafe Typewriter — Jev on Vercel AI Gateway

16 typed questions about whatever you're typing, re-asked on every keystroke.

Try it

A fork of stevekrouse/typesafe-typewriter with two changes:

UpstreamThis fork
How it calls JevTypeSafe's own POST https://api.typesafe.ai/v1/systemone, hand-rolled, keyed by TYPESAFE_API_KEYtypesafe-ai/jev through Vercel AI Gateway, via the AI SDK's experimental_evaluate, keyed by AI_GATEWAY_API_KEY
What caps itA $2.00 lifetime budget ledger in SQLiteNothing. Jev is free on the gateway, so there is no spend to cap

Everything else — the 16 questions, the one-call fan-out, the 120ms debounce, the plain black-bar design — is unchanged.

Jev is TypeSafe's "System One" evaluation model. You send it a piece of state and a map of typed questions, and it returns typed answers:

QuestionSDK nameReturns
choicechoiceone option from a list you define, plus a probability for every option
scorescorea position along an ordered rubric you define, plus the distribution
noulbooleanthe probability that a statement is true

No text generation, no parsing, no recovering a value from prose. Every answer is constrained to the options you supplied, and comes back with a probability distribution your code can threshold, sort, or route on. TypeSafe calls the yes/no primitive a noul; the AI SDK calls it a boolean and puts the answer in probability. jev.ts is the only place that rename lives.

The interesting property is that it's fast — fast enough to sit inside a UI loop. So this demo asks all 16 questions in a single API call and re-asks them on every keystroke.

What it demonstrates

  • Fan-out is nearly free. All 16 questions go out in one request. Adding questions barely moves the response time, because each one is evaluated in parallel against the same state.
  • The distribution is the product. The bars aren't decoration — they're the full probability vector. A score answer of 2.77 means "77% Warm, 23% Neutral", and the panel shows exactly that.
  • Code owns the rendering. The model returns numbers. The bars are CSS. There is no prompt that says "output a chart".
  • Speed changes the design. At a few hundred milliseconds this is a live instrument panel, not a form you submit. A keystroke re-asks all 16 questions.

How it works

Rendering mermaid diagram...

The client debounces 120ms, cancels the pending request when you type again (AbortController), and keeps showing the previous answers while the next batch is in flight — so the panel never flickers to empty.

The questions

Three groups, all defined in questions.ts:

  • What it is — asks a question, asks for action, makes a promise, states an opinion, checkable claim, names specifics
  • How it lands — reads AI-written, passive-aggressive, expresses emotion, would start an argument, would get a reply, tone, conviction, urgency
  • Who it's for — audience, formality

Adding one is a single entry in that file. The browser renders whatever the API reports, so there's nothing else to update.

Files

See AGENTS.md for the file map.

Cost and caps

Jev is listed at $0 on AI Gateway (Vercel calls it promotional pricing), so the upstream demo's $2 lifetime budget has nothing to protect. That ledger — budget.ts, one row of SQLite, reserve-then-reconcile on every call — is gone, along with the budget field in the API response, its footer line, and the "budget spent" notice. Nothing on the client stops asking any more, because there's nothing to run out of.

rate-limit.ts stays, because free isn't the same as unlimited: it's burst control (600/min per IP, 6000/min globally, best-effort in memory) so one tab can't hammer the gateway a few hundred times a minute. A human typist never comes close.

If Jev ever starts billing, put a cap back rather than trusting the rate limiter. Upstream's budget.ts is the reference implementation, and AI Gateway also enforces spend limits at the team level.

Environment variables

VarWhat it's for
AI_GATEWAY_API_KEYrequiredAuthenticates the gateway. The model page's own "Get API key" link opens the create-key modal on your team.
JEV_MODELoptionalOverrides typesafe-ai/jev without a deploy.

Without a key the page says so up front — /api/questions reports whether one exists, so the panel shows what's missing and asks nothing, instead of failing on the first keystroke. Nothing about the key's value crosses the wire.

Notes

  • Text is capped at 4000 characters.
  • The AI SDK's evaluation API is experimental, so the import is pinned to npm:ai@7. It needs AI SDK 7.0.105 or later for experimental_evaluate.
  • The model ID in the gateway is typesafe-ai/jev; the response reports the resolved version behind that alias, which is what the footer shows.
  • TypeSafe's separate confidence statistic doesn't arrive on the answer. It comes out of band, at providerMetadata.typesafe.confidence[questionId], and jev.ts folds it back onto each choice and score answer.
  • tests/gateway.ts checks the wiring: with no key it still probes model resolution and reports what the SDK says, and with a key it makes one real 16-question call and prints every answer.