914 words
5 minutes

Jev TypeScript API: Choice, Score, and Noul in One Request

2026-09-22
AI
AI
/
API
/
TypeScript
/
Automation

The clearest way to learn the Jev TypeScript API is to put all three primitives into one bounded workflow. This example classifies a support message, scores its urgency, and detects an explicit refund request. Application code then decides whether to route automatically or request review.

The example targets @typesafe-ai/sdk 0.6.0, Node.js 20 or newer, and Jev 1.13 as checked on September 22, 2026. It is server-side code: do not expose the TypeSafe API key in a browser bundle.

Install the SDK and set the API key#

Create a TypeSafe API key, store it outside the repository, and install the official JavaScript SDK:

Terminal window
export TYPESAFE_API_KEY='replace-with-your-key'
npm install @typesafe-ai/sdk

The SDK reads TYPESAFE_API_KEY and defaults to jev-latest. Pin a version after calibrating production thresholds because the alias can move when TypeSafe releases another model.

The SDK refuses browser execution by default. Calling from a backend route, serverless function, or controlled worker keeps the secret outside client JavaScript.

Ask Choice, Score, and Noul together#

One systemOne request can evaluate several named questions against the same state:

import {
choice,
noul,
score,
TypeSafeClient,
} from '@typesafe-ai/sdk';
const client = new TypeSafeClient({
defaultModel: 'jev-1.13.0',
});
const message = {
subject: 'Duplicate March charge',
body: 'My card was charged twice. Please refund it today or I will cancel.',
};
const response = await client.systemOne({
state: message,
questions: {
department: choice('Which team should handle this message?', {
billing: 'Invoices, payments, duplicate charges, and refunds',
technical: 'Service failures, bugs, and integration problems',
sales: 'Pricing, upgrades, and new contracts',
other: 'None of the other options apply',
}),
urgency: score('How urgent is this message?', [
'No deadline or blocking problem',
'Should be handled soon, but no explicit deadline',
'Explicit deadline, operational block, or high churn risk',
]),
refundRequested: noul('Does the customer explicitly request a refund?', {
true: 'The message directly asks for money to be refunded',
false: 'The message does not request a refund',
}),
},
});
console.log(response.model);
console.log(response.answers.department);
console.log(response.answers.urgency);
console.log(response.answers.refundRequested);

department.choice is the selected label, urgency.score is the probability-weighted rubric level, and refundRequested.noul is the probability of a yes answer. Choice and Score also include distributions and confidence values.

Keep policy decisions in code#

Do not treat the top choice as authorization for an irreversible operation. Apply thresholds and fallback behavior explicitly:

const department = response.answers.department;
const refund = response.answers.refundRequested;
if (department.confidence < 0.6) {
await sendToManualReview({ message, reason: 'department_uncertain' });
} else if (department.choice === 'billing') {
await enqueueBillingTicket(message);
} else {
await enqueueDepartmentTicket(department.choice, message);
}
if (refund.noul >= 0.8) {
await addTicketFlag('refund_requested');
}

The values 0.6 and 0.8 are illustrative, not recommended defaults. Choose them from labeled data and the relative cost of false positives, false negatives, and human review.

The refund result should add a signal, not execute the transaction. Order ownership, payment state, amount, authorization, and idempotency still belong to deterministic business logic.

Write questions that can be evaluated#

Keep each question atomic. Do not combine urgency, department, and refund eligibility into one vague score.

  • Give Choice options distinct descriptions and include other or none when the catalog is not exhaustive.
  • Write Score criteria as ordered, self-contained levels. The API accepts 2 to 10 criteria.
  • Use one Noul per independent condition when several labels may be true at the same time.
  • Use code for exact dates, totals, and identifiers instead of asking a probabilistic model to reconstruct them.

Choice supports up to 255 options, but a large catalog is not automatically a good single-stage classifier. Evaluate hierarchical routing when neighboring labels become difficult to distinguish.

Define the failure path#

The API can return authentication, validation, rate-limit, or temporary overload errors. The SDK retries selected temporary failures with backoff, but the application still needs a final fallback:

try {
const response = await client.systemOne({
state: message,
questions: {
department: choice('Which team should handle this message?', {
billing: 'Billing and payments',
technical: 'Product and integration problems',
other: 'Other requests',
}),
},
});
await routeWithPolicy(response.answers.department);
} catch (error) {
console.error('TypeSafe decision failed', error);
await sendToManualReview({ message, reason: 'typesafe_unavailable' });
}

A support pipeline should usually preserve the ticket by sending it to review. A low-risk recommendation widget may instead use a default order. The product’s failure cost determines the fallback.

Verify in shadow mode before automating#

Run Jev alongside the existing route without changing user-visible behavior. Record the versioned model ID, probabilities, predicted label, actual outcome, latency, and final path. Keep sensitive message text out of uncontrolled logs.

Use that dataset to answer whether English and non-English inputs need different thresholds, which labels overlap, and how often fallback erases the expected savings. Repeat the evaluation before moving from a pinned model to a new release.

Read the Jev model boundary guide before choosing a workflow. If an agent is expected to invoke this API, the Codex routing analysis explains what installing the TypeSafe skill does and does not automate. For local inference, compare Laya’s checkpoints and limits.

FAQ#

Q: Should I use jev-latest or a versioned Jev model?#

A: Use jev-latest while exploring. Pin a version such as jev-1.13.0 after calibrating thresholds, log the model returned by each response, and evaluate a new release before changing production traffic.

Q: Can one Jev request contain several questions?#

A: Yes. Choice, Score, and Noul questions can share one state and are returned under their named keys. Packing related independent decisions can reduce round trips, but every question still contributes to the input budget.

Q: Can I call the Jev API directly from a web app?#

A: Do not ship the API key to the browser. Put the call behind a server endpoint or another trusted runtime, authenticate the application request, and return only the fields the client needs.

References:

TypeSafe AI: JavaScript SDK

TypeSafe AI: API reference

TypeSafe AI: Choice

TypeSafe AI: Confidence

TypeSafe JavaScript SDK v0.6.0

Jev TypeScript API: Choice, Score, and Noul in One Request
https://laplusda.com/en/posts/jev-typescript-api-choice-score-noul/
Author
Zero
Published at
2026-09-22
License
CC BY-NC-SA 4.0