Skip to content

Install and configure

Terminal window
npm install jevlish
export TYPESAFE_API_KEY=...

Node 20+. ESM only. The package ships its own type declarations.

given, from, and grade share one Sense: the three verbs bound to one runtime. On first use, that runtime reads TYPESAFE_API_KEY and creates a Jev client. Nothing is sent until an expression runs, so importing the package and building expressions costs nothing.

Jevlish uses the TypeSafe/Jev SDK. The environment variable is therefore named TYPESAFE_API_KEY, and the default transport is TypeSafeClient.

If the key is missing when the first request goes out, the expression rejects with a SenseError that says so.

The module-level verbs create their shared Sense lazily. Call configure before their first use only when you need to replace its defaults.

import { configure } from "jevlish";
configure({
model: "jev-1.13", // default: jev-latest
policy: { noul: { yesAbove: 0.9, noBelow: 0.1 } }, // default: 0.8 / 0.2
});

Every field is optional:

  • apiKey instead of the environment variable. Ignored when client is given.
  • model, defaulting to the SDK’s jev-latest.
  • policy: the thresholds that turn probabilities into decisions. The defaults are Noul yes at P(yes) ≥ 0.8 and no at ≤ 0.2, Choice and Score at confidence ≥ 0.5. See Uncertainty and acceptance policy.
  • client: your own transport, or a fake in tests. See Testing.
  • cache, concurrency, questionsPerRequest: see Runtime.

createSense(config) builds a second, independent runtime and returns given, from, and grade bound to it. Use it when two parts of an application need different models, policies, or transports, or when a test should not touch the shared state.

import { createSense } from "jevlish";
const strict = createSense({ policy: { noul: { yesAbove: 0.95, noBelow: 0.05 } } });
const judgment = await strict.given(ticket).when(blocked);