@tokz/sdk
v0.6.0
Published
Client for the Tokz Decisions API: typed answers about text from the OpenDecision models.
Maintainers
Readme
@tokz/sdk
Client for the Tokz Decisions API: typed answers about text from the open OpenDecision models.
npm install @tokz/sdkdecide() answers a choice, multilabel, bool or score per question, with a
probability for every option. The text is read by a model on Tokz servers and is not
stored. Each request is billed, so the client never retries one.
import { Tokz } from "@tokz/sdk";
const tokz = new Tokz({ apiKey: process.env.TOKZ_API_KEY! });
const out = await tokz.decide({
inputs: "I was charged twice and the app keeps logging me out.",
decisions: {
queue: { type: "choice", options: ["billing", "technical", "account"] },
priority: { type: "score", low: 1, high: 5 },
},
});
const r = out.results[0]!;
r.queue.best; // "billing"
r.priority.type === "score" && r.priority.score; // expected value
out.usage.billed_tokens;
const { models, limits } = await tokz.listDecisionModels();A 402 raises TokzInsufficientCreditsError; every other failure raises TokzError
with the HTTP status.
MIT
