Jev TypeScript SDK: install, call, and read typed answers.
Install @typesafe-ai/sdk, keep TYPESAFE_API_KEY on your server, then call TypeSafeClient.systemOne(). Questions are a keyed object; results are read from response.answers under those same keys.
Current package at verification: 0.6.0. Requires Node.js 20 or newer. Verified September 22, 2026 against the published npm package and official source.
@typesafe-ai/sdkTypeScript declarations includedInstall and make the smallest useful request
Install the official package. It ships ESM, CommonJS, and its own TypeScript declarations; do not install a separate @types package.
Set the API key in the environment where your server process runs. The zero-argument constructor reads it automatically.
This is asynchronous: systemOne() returns an awaitable APIPromise. Default model is jev-latest, so the minimal request does not need a model field.
Use Choice, Score, and Noul in one typed request
Builder helpers preserve question names, Choice labels, and Score tuple positions. That gives your editor useful types at the exact point where application code reads an answer.
| Question | Read the answer | What TypeScript knows |
|---|---|---|
| Choice | answers.queue.choice | Union of your criteria keys; probabilities use the same keys |
| Score | answers.urgency.score | Number plus typed legend and probabilities for tuple indices |
| Noul | answers.refundRequested.noul | Number representing probability of yes, from 0 to 1 |
noul field is the probability of yes. Choose and validate any action threshold on your own labeled workload; do not cast the number to boolean.Exact request and response contracts
state accepts a string, JSON object, JSON array, or null. questions must be a non-empty object keyed by the answer names you want back. model is optional.choice(instructions, criteria) requires criteria as an object mapping labels to descriptions or null. It is not an array of choices.score(instructions, criteria) requires an ordered array with at least two levels. Returned score is an expected numeric value and can fall between integer levels.noul(instructions, criteria?) accepts optional true and false descriptions. Its answer contains type: "noul" and noul.model, keyed answers, and usage with input_tokens and output_tokens. Choice and Score also return confidence and probabilities; Score adds legend.For conceptual guidance on when each primitive fits, use the Choice, Score, and Noul reference. This page owns only their TypeScript SDK shapes.
Handle API, connection, timeout, and cancellation failures
Reuse one client, keep calls behind your server boundary, and log the request ID from API failures. The SDK already retries eligible connection failures, timeouts, HTTP 408, 429, and 5xx responses by default; per-call options can narrow the policy and add cancellation.
APITimeoutError extends APIConnectionError. APIError exposes status, headers, body, and requestId. These are exported SDK classes, not application-defined placeholders.
Choose a model and configure the client
| Model name | Current target | Use |
|---|---|---|
| jev-latest | jev-1.13.0 | Default moving stable alias |
| jev-preview | jev-1.13.0 | Newest release, including previews |
| jev-1.13.0 | Pinned | Reproducible evaluated behavior |
Aliases can move. Log result.model, which reports the versioned model that answered. Pin jev-1.13.0 only when your deployment needs a stable version while you re-evaluate a newer release.
Constructor and environment precedence
Explicit constructor values win over environment variables, which win over SDK defaults. The official client supports apiKey, baseURL, defaultModel, timeouts, retries, logging, headers, and a custom fetch implementation.
The matching variables are TYPESAFE_API_KEY, TYPESAFE_BASE_URL, and TYPESAFE_DEFAULT_MODEL. Direct TypeSafe defaults to https://api.typesafe.ai. Use a custom base URL only when the upstream provider documents it; see the dedicated Vercel or OpenRouter owner pages for provider-specific behavior.