Choice
Route a message.
A support inbox gets messages about billing, logins, bugs, pricing, and everything in between. A Choice question asks Jev to pick one department from a fixed set, and returns a probability for every option so your code can see how close the call was, not just the winner.
Choice
Route a message
Shows recorded and illustrative answers. This site's own live testing is unavailable.
Chosen: billing
Charges, invoices, refunds, payment methods, subscription costs
- billing91.0%
- account3.0%
- other3.0%
- technical2.0%
- sales1.0%
This illustrative answer puts 91.0% on billing, with account next at 3.0%. Probabilities describe the distribution over the options, not a guarantee that the choice is correct. Confidence: 0.89.
Not a live or recorded response. Shown to illustrate the shape of an answer.
Build this
import { choice, TypeSafeClient } from "@typesafe-ai/sdk"; const client = new TypeSafeClient(); // reads TYPESAFE_API_KEY, defaults to jev-latest const message = "Hi, I was charged twice for my subscription this month. The two charges show up on my card statement on the 3rd and the 4th. Can you refund one of them?"; const { answers } = await client.systemOne({ state: message, model: "jev-latest", questions: { department: choice( "Which department should handle this customer message?", { billing: "Charges, invoices, refunds, payment methods, subscription costs", account: "Login, password, profile, permissions, closing or changing an account", technical: "Bugs, errors, outages, integrations, something not working", sales: "Pricing questions, plan comparisons, upgrades, purchasing for a team", other: "Anything that does not fit the departments above", }, ), },}); const { choice: result, probabilities, confidence } = answers.department; // Your code decides what to do with the answer.if (confidence < 0.5) { console.log("Unsure. Route to a person.", probabilities);} else { console.log("Route to " + result + " (confidence " + confidence.toFixed(2) + ")");}Type-checked against @typesafe-ai/sdk 0.6.0 as part of this site's build. Not executed against the live API by this guide.
npm install @typesafe-ai/sdk. Requires Node.js 20+. Set TYPESAFE_API_KEY in your environment.
Keep TYPESAFE_API_KEY on the server. Never embed it in client code or ship it in a browser bundle.
Reading the three samples
Charged twice. A duplicate charge and a refund request. Only billing fits, so the probability should sit almost entirely on one department.
Webhook failing. Malformed payloads and 500 errors after a deploy. This is a technical problem, and nothing about it points to billing or sales.
Upgrade won't charge. The customer is trying to buy a plan, which is sales, but the checkout is broken, which is technical. When two departments both fit, probabilities split and confidence drops. The illustrative value shown for that sample here is a hand-authored example of that pattern, not a measured Jev response.
Reading the result
The department with the highest probability is Jev's answer, shown as choice. Treat a flat, low-confidence distribution as a signal to ask a person rather than route automatically; see Confidence for how that number is derived. The 0.5 cutoff in the code is a starting point, not a TypeSafe recommendation: set it from your own labelled messages.
Where this fails
It always names a department. A message that fits none of them should land on other, but adding that option does not detect uncertainty: Jev can pick “other” confidently, or pick a real department confidently when it should not. Gate on confidence in your code as well.
It routes to one department. A message with two separate requests, such as a refund and a password reset, gets one answer. If that matters, ask one Noul per department instead.
The homepage preview uses the same department definitions, question, and model alias, so the same input is asked the same way in both places. Keep in mind that jev-latest moves to a newer release over time. Pin a versioned model id if you tune thresholds against it.
Wondering whether a call like this one should use Jev or a general-purpose LLM in the first place? See Jev vs LLMs: when to use TypeSafe AI.