jevx-client
v0.1.1
Published
Typed client for the Jev AI decisions API on jevx.org: send a state and typed questions, get choices, scores and probabilities back.
Maintainers
Readme
jevx-client
A small typed client for the Jev AI decisions API on Jevx. Send a state and the questions you branch on, get back the choice, a probability on every option and a confidence. Zero runtime dependencies, Node 18+.
Jev AI is a zero-shot decision model from TypeSafe: text or JSON in, typed values out. This package is an independent client for the Jevx API and is not affiliated with TypeSafe AI.
npm install jevx-clientCreate an API key at jevx.org/settings/apikeys and export it as JEVX_API_KEY.
import { decide } from 'jevx-client';
const { answers, charged } = await decide({
state: 'Customer wrote: my order arrived three days late and the box was crushed.',
questions: {
sentiment: {
type: 'choice',
instructions: 'Overall sentiment of the customer.',
criteria: { positive: 'Happy.', neutral: 'Neither happy nor upset.', negative: 'Unhappy or angry.' },
},
needs_human: {
type: 'noul',
instructions: 'Does this need a human agent?',
criteria: { true: 'Requires a human agent.', false: 'Can be handled automatically.' },
},
},
});
if (answers.sentiment.type === 'choice' && answers.sentiment.probabilities.negative > 0.8) {
await escalate();
}Question shapes
| type | criteria | returns |
|---|---|---|
| choice | object of option to meaning, two or more options | choice, probabilities, confidence |
| score | ordered array, low to high | score, probabilities, confidence |
| noul | exactly the keys true and false | noul between 0 and 1, where exactly 0.5 means the model declined |
validateQuestions() runs the same shape checks locally and decide() calls it before sending, so a malformed question fails before it reaches the API. The API reports failures as HTTP 200 with a non-zero code; decide() turns those into a JevxError.
Up to 16 questions per request. The playground and the full guide are at jevx.org.
License
MIT
