Install the official package

The official JavaScript SDK supports JavaScript and TypeScript and documents Node.js 20 or newer. Install it in the server-side application that will call Jev:

EXAMPLE
npm install @typesafe-ai/sdk

Set TYPESAFE_API_KEY in that application's environment. This publication is a content site; the code below is for your own project and is not an interactive playground.

Describe one bounded choice

This original example asks which shelf fits a short piece of internal documentation. The available labels are defined in the request.

EXAMPLE
import { choice, TypeSafeClient } from '@typesafe-ai/sdk';

const jev = new TypeSafeClient();

const result = await jev.systemOne({
  state: {
    note: 'How to rotate the staging database password and update the service.',
  },
  questions: {
    shelf: choice('Which documentation shelf best fits this note?', {
      operations: 'Deployment, infrastructure and service maintenance.',
      product: 'Product behavior, customer workflows and feature design.',
      review: 'Insufficient context or none of the other shelves.',
    }),
  },
});

const suggestion = result.answers.shelf;
console.log({
  shelf: suggestion.choice,
  confidence: suggestion.confidence,
});

The SDK infers the answer shape from the question. Read the client API reference when you need model selection, request configuration and other options.

Keep a suggested label separate from an action

The example only prints a proposed shelf. A production system can show it for approval or use an evaluated policy to route automatically. The review category remains a meaningful result; do not treat it as an application error.

Handle API failures outside this happy-path example. If a request cannot finish, keep the document available and mark it pending. Avoid silently storing a default category as if the model had chosen it.

Keep credentials out of the browser

In a web application, a server route or server-side job should own the provider key. A public environment variable would expose it to visitors. The browser should receive only the information needed for the user interface.

This architecture also gives you a place to enforce input size, request budgets and access controls before a paid call. Those checks should be implemented independently of the model's answer.

Validate against your documents

Build a small labelled collection, include documents that straddle categories, and inspect both the predicted shelf and uncertainty. Measure how many items land in review. A system with an explicit unresolved state is easier to improve than one that forces every input into a misleading label.

For the same pattern in another language, read Jev with Python. For category design, revisit Choice, Score or Noul?.

The code follows the documented SDK shape and has not been run against a live Jev account by this publication.