@tanstack/ai-typesafe
TypeSafe Jev adapter for TanStack AI. Call Jev with
decide() and typed questions. This package talks HTTP with fetch. It
does not add a TypeSafe SDK.
Install
pnpm add @tanstack/ai @tanstack/ai-typesafe
Setup
Get an API key from TypeSafe and set it as an environment variable:
export TYPESAFE_API_KEY="..."
Usage
import { boolean, choice, decide, score } from '@tanstack/ai'
import { typesafeDecider } from '@tanstack/ai-typesafe'
const result = await decide({
adapter: typesafeDecider('jev-latest'),
state: ticket,
questions: {
queue: choice({
instructions: 'Which team should handle this ticket?',
options: {
billing: 'Payments, invoices, refunds',
tech: 'Bugs, outages, integrations',
sales: 'Pricing, upgrades, new accounts',
},
}),
urgency: score({
instructions: 'How urgent is this ticket?',
levels: ['low', 'medium', 'high'],
}),
refund: boolean({
instructions: 'Is the customer asking for a refund?',
}),
},
})
result.queue.value
result.meta.model
result.meta.usage
typesafeDecider(model) reads TYPESAFE_API_KEY from the environment. To
pass a key yourself, use createTypesafeDecider(model, apiKey).
Supported models
jev-latest — current stable Jev alias
jev-1.13.0 — pinned Jev release
You can also pass other TypeSafe model ids as a string.
License
MIT