[{"data":1,"prerenderedAt":39},["ShallowReactive",2],{"docs:providers/typesafe":3},{"title":4,"navTitle":4,"description":5,"api":6,"html":7,"toc":8,"path":28,"tab":29,"group":30,"prev":31,"next":34,"markdownUrl":37,"sourceUrl":38,"lastModified":6},"@standardagents/typesafe","TypeSafe AI decision inference with typed questions, probabilities, and automatic thread logs",null,"\u003Cp>First-party TypeSafe AI decision inference for Standard Agents. Jev evaluates\nexplicit context against multiple independent questions in one request. The\npackage implements \u003Ccode>DecisionProviderInterface\u003C/code> (\u003Ccode>kind: 'decision'\u003C/code>, \u003Ccode>decide()\u003C/code>),\nindependently of the conversational provider \u003Ccode>generate()\u003C/code> and \u003Ccode>stream()\u003C/code> methods.\nUse it from hooks, tools, handlers, or thread endpoints; keep prompt-backed\nconversation models configured separately with \u003Ccode>defineModel\u003C/code>.\u003C/p>\n\u003Ch2 id=\"install-and-configure\">\u003Ca class=\"docs-anchor\" href=\"#install-and-configure\" aria-label=\"Link to this section\">\u003C/a>Install and configure\u003C/h2>\n\u003Cfigure class=\"docs-code\" data-docs=\"code\" data-lang=\"bash\">\u003Cpre class=\"shiki shiki-themes one-light github-dark\" style=\"--shiki-light:#383A42;--shiki-dark:#e1e4e8;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#4078F2;--shiki-dark:#B392F0\">pnpm\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> add\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> @standardagents/typesafe\u003C/span>\u003C/span>\u003C/code>\u003C/pre>\u003C/figure>\n\u003Cp>Set \u003Ccode>TYPESAFE_AI_API_KEY\u003C/code> in local \u003Ccode>.dev.vars\u003C/code> or production secrets for BYOK.\n\u003Ccode>state.decide()\u003C/code> resolves scoped provider credentials and hosted routing.\nProvider and platform destinations come only from trusted instance-admin or\ndeployment configuration; user/thread URL overrides cannot redirect inherited\ncredentials.\nHosted requests use the platform TypeSafe route when supported and configured;\nplatform availability requires a platform-owned TypeSafe credential.\u003C/p>\n\u003Ch2 id=\"decide-within-a-thread\">\u003Ca class=\"docs-anchor\" href=\"#decide-within-a-thread\" aria-label=\"Link to this section\">\u003C/a>Decide within a thread\u003C/h2>\n\u003Cfigure class=\"docs-code\" data-docs=\"code\" data-lang=\"typescript\">\u003Cpre class=\"shiki shiki-themes one-light github-dark\" style=\"--shiki-light:#383A42;--shiki-dark:#e1e4e8;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#A626A4;--shiki-dark:#F97583\">import\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> { \u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">typesafe\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> } \u003C/span>\u003Cspan style=\"--shiki-light:#A626A4;--shiki-dark:#F97583\">from\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> '@standardagents/typesafe'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">;\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#A626A4;--shiki-dark:#F97583\">const\u003C/span>\u003Cspan style=\"--shiki-light:#986801;--shiki-dark:#79B8FF\"> result\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#F97583\"> =\u003C/span>\u003Cspan style=\"--shiki-light:#A626A4;--shiki-dark:#F97583\"> await\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> state.\u003C/span>\u003Cspan style=\"--shiki-light:#4078F2;--shiki-dark:#B392F0\">decide\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">({\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">  provider\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> typesafe,\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">  model\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'jev-latest'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">,\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">  context\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> { \u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">ticket\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'My payment failed twice. Please refund it.'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> },\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">  questions\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> {\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">    department\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> {\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">      type\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'choice'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">,\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">      instructions\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'Which team should handle this ticket?'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">,\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">      options\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> { \u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">billing\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'Payments and refunds'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">, \u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">technical\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'Software failures'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">, \u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">other\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#986801;--shiki-dark:#79B8FF\"> null\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> },\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">    },\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">    severity\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> {\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">      type\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'score'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">,\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">      instructions\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'How disruptive is this problem?'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">,\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">      levels\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> [\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\">'Minor inconvenience'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">, \u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\">'Work blocked'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">, \u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\">'Critical outage'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">],\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">    },\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">    refund\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> {\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">      type\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'boolean'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">,\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">      instructions\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'Does the customer explicitly request a refund?'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">,\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">      criteria\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> { \u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">true\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'An explicit refund request'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">, \u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">false\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'No refund requested'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> },\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">    },\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">  },\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">});\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#A626A4;--shiki-dark:#F97583\">const\u003C/span>\u003Cspan style=\"--shiki-light:#986801;--shiki-dark:#79B8FF\"> team\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#F97583\"> =\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> result.\u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">answers\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">.\u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">department\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">.\u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">choice\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">;\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#A626A4;--shiki-dark:#F97583\">const\u003C/span>\u003Cspan style=\"--shiki-light:#986801;--shiki-dark:#79B8FF\"> refundRequested\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#F97583\"> =\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> result.\u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">answers\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">.\u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">refund\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">.\u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">probability\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#F97583\"> >=\u003C/span>\u003Cspan style=\"--shiki-light:#986801;--shiki-dark:#79B8FF\"> 0.9\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">;\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003C/span>\u003C/code>\u003C/pre>\u003C/figure>\n\u003Cp>\u003Ccode>decide(state, options)\u003C/code> from \u003Ccode>@standardagents/spec\u003C/code> or \u003Ccode>@standardagents/builder\u003C/code>\nis an equivalent SDK helper. In Standard Agents Builder, both forms record the request, response, duration,\nstatus, usage, and known cost in the thread's application logs, including failure\ninformation. They work outside an active conversation turn, and their logs\npersist even before the thread has its first message. They do not read or\nwrite conversation messages implicitly. If an answer belongs in conversation\nhistory, explicitly call \u003Ccode>state.injectMessage()\u003C/code> with the selected information.\nAvoid logging the same decision cost again through \u003Ccode>state.log()\u003C/code>.\u003C/p>\n\u003Cp>Automatic logs, \u003Ccode>state.log()\u003C/code>, and log attribution are Standard Agents Builder extensions,\nnot Standard Agent conformance requirements. Import log types such as\n\u003Ccode>ThreadLogEntry\u003C/code> from \u003Ccode>@standardagents/builder\u003C/code>.\u003C/p>\n\u003Cp>Standard Agents Builder adds optional \u003Ccode>name\u003C/code> and \u003Ccode>trigger\u003C/code> to the thread call to identify the operation\nand its cause. Pass \u003Ccode>signal\u003C/code> to cancel a request. Context is explicit: a string,\nJSON object, or array. Select any relevant conversation content yourself rather\nthan assuming Jev receives the thread history. Pre-process images, audio, video,\nand binary data into text or structured fields.\u003C/p>\n\u003Ch2 id=\"questions-and-native-conversion\">\u003Ca class=\"docs-anchor\" href=\"#questions-and-native-conversion\" aria-label=\"Link to this section\">\u003C/a>Questions and native conversion\u003C/h2>\n\u003Cp>Every question has a stable name and \u003Ccode>instructions\u003C/code>. Write the full question in\n\u003Ccode>instructions\u003C/code>: the question's map key is an answer identifier, not an instruction\nsent to Jev. Instructions, option descriptions, rubric levels, and boolean\ncriteria may be strings, JSON objects, or arrays. Surface the domain's actual\noptions and scoring rubric in each invocation so the decision is unambiguous.\u003C/p>\n\u003Cdiv class=\"docs-table\">\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Standard Agent request\u003C/th>\n\u003Cth>Native TypeSafe request\u003C/th>\n\u003C/tr>\n\u003C/thead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>\u003Ccode>context\u003C/code>\u003C/td>\n\u003Ctd>\u003Ccode>state\u003C/code>, preserving its JSON structure\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>questions.&#x3C;id>.type: 'choice'\u003C/code> with \u003Ccode>options\u003C/code>\u003C/td>\n\u003Ctd>\u003Ccode>type: 'choice'\u003C/code> with \u003Ccode>criteria\u003C/code>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>questions.&#x3C;id>.type: 'score'\u003C/code> with ordered \u003Ccode>levels\u003C/code>\u003C/td>\n\u003Ctd>\u003Ccode>type: 'score'\u003C/code> with ordered \u003Ccode>criteria\u003C/code>\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>questions.&#x3C;id>.type: 'boolean'\u003C/code> with optional \u003Ccode>criteria.true/false\u003C/code>\u003C/td>\n\u003Ctd>\u003Ccode>type: 'noul'\u003C/code> with the same optional criteria\u003C/td>\n\u003C/tr>\n\u003Ctr>\n\u003Ctd>Each question's \u003Ccode>instructions\u003C/code> and identifier\u003C/td>\n\u003Ctd>Preserved\u003C/td>\n\u003C/tr>\n\u003C/tbody>\n\u003C/table>\u003C/div>\n\u003Cp>All questions share one state and are evaluated in one \u003Ccode>POST /v1/systemone\u003C/code>\nrequest. Choice accepts up to 255 options; use \u003Ccode>null\u003C/code> for an option that needs no\nextra description. Score accepts 2–10 ordered levels. Put rules and boundary\ncases in instructions and criteria; do not put questions in provider connection\nconfiguration or represent them as generated tool calls.\u003C/p>\n\u003Ch2 id=\"answers-and-thresholds\">\u003Ca class=\"docs-anchor\" href=\"#answers-and-thresholds\" aria-label=\"Link to this section\">\u003C/a>Answers and thresholds\u003C/h2>\n\u003Cp>\u003Ccode>result\u003C/code> contains the resolved \u003Ccode>model\u003C/code>, named \u003Ccode>answers\u003C/code>, standard \u003Ccode>usage\u003C/code>, and\nprovider \u003Ccode>metadata\u003C/code>. Every answer retains its question identifier:\u003C/p>\n\u003Cul>\n\u003Cli>Choice: \u003Ccode>{ type: 'choice', choice, probabilities, confidence }\u003C/code>.\u003C/li>\n\u003Cli>Score: \u003Ccode>{ type: 'score', score, legend, probabilities, confidence }\u003C/code>. The score\nis a probability-weighted, zero-based rubric value and can be fractional.\u003C/li>\n\u003Cli>Boolean: \u003Ccode>{ type: 'boolean', probability }\u003C/code>, converted from native \u003Ccode>noul\u003C/code>.\u003C/li>\n\u003C/ul>\n\u003Cp>Probabilities and confidence use \u003Cstrong>0–1\u003C/strong>. Boolean results are never coerced to\nJavaScript booleans; choose and validate a threshold for the application's\npolicy. Confidence is provider-reported and is distinct from an option's\nprobability. Preserve the full probability distribution, score legend, and\nconfidence when storing or presenting results. Native rounded distributions can\nsum slightly above or below one; the provider preserves them without silently\nrenormalizing. \u003Ccode>metadata.native\u003C/code> retains the native response, and \u003Ccode>metadata.rounding\u003C/code> records\nprobability and score precision.\u003C/p>\n\u003Ch2 id=\"standalone-use\">\u003Ca class=\"docs-anchor\" href=\"#standalone-use\" aria-label=\"Link to this section\">\u003C/a>Standalone use\u003C/h2>\n\u003Cfigure class=\"docs-code\" data-docs=\"code\" data-lang=\"typescript\">\u003Cpre class=\"shiki shiki-themes one-light github-dark\" style=\"--shiki-light:#383A42;--shiki-dark:#e1e4e8;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#A626A4;--shiki-dark:#F97583\">import\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> { \u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">typesafe\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> } \u003C/span>\u003Cspan style=\"--shiki-light:#A626A4;--shiki-dark:#F97583\">from\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> '@standardagents/typesafe'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">;\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#A626A4;--shiki-dark:#F97583\">const\u003C/span>\u003Cspan style=\"--shiki-light:#986801;--shiki-dark:#79B8FF\"> provider\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#F97583\"> =\u003C/span>\u003Cspan style=\"--shiki-light:#4078F2;--shiki-dark:#B392F0\"> typesafe\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">({ \u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">apiKey\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'your-typesafe-key'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> });\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#A626A4;--shiki-dark:#F97583\">const\u003C/span>\u003Cspan style=\"--shiki-light:#986801;--shiki-dark:#79B8FF\"> result\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#F97583\"> =\u003C/span>\u003Cspan style=\"--shiki-light:#A626A4;--shiki-dark:#F97583\"> await\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> provider.\u003C/span>\u003Cspan style=\"--shiki-light:#4078F2;--shiki-dark:#B392F0\">decide\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">({\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">  model\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'jev-latest'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">,\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">  context\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'The customer asks to cancel their plan.'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">,\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">  questions\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> {\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">    cancel\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> { \u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">type\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'boolean'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">, \u003C/span>\u003Cspan style=\"--shiki-light:#E45649;--shiki-dark:#E1E4E8\">instructions\u003C/span>\u003Cspan style=\"--shiki-light:#0184BC;--shiki-dark:#E1E4E8\">:\u003C/span>\u003Cspan style=\"--shiki-light:#50A14F;--shiki-dark:#9ECBFF\"> 'Does this request cancellation?'\u003C/span>\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\"> },\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">  },\u003C/span>\u003C/span>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#383A42;--shiki-dark:#E1E4E8\">});\u003C/span>\u003C/span>\u003C/code>\u003C/pre>\u003C/figure>\n\u003Cp>Direct \u003Ccode>provider.decide()\u003C/code> calls have no thread and create no automatic thread\nlogs. Connection configuration supports \u003Ccode>apiKey\u003C/code>, \u003Ccode>baseUrl\u003C/code>, \u003Ccode>timeout\u003C/code>,\n\u003Ccode>defaultHeaders\u003C/code>, and a custom \u003Ccode>fetch\u003C/code>; the default base is\n\u003Ccode>https://api.typesafe.ai/v1\u003C/code>. For thread calls, trusted instance-admin or\ndeployment configuration can override it with \u003Ccode>TYPESAFE_AI_BASE_URL\u003C/code>.\nAuthenticated \u003Ccode>getModels()\u003C/code> uses \u003Ccode>/models\u003C/code>. Each attempt\nmakes one HTTP request; the caller or runtime owns retry policy. Invalid\nquestions or mismatched answers raise a \u003Ccode>ProviderError\u003C/code>.\u003C/p>\n\u003Ch2 id=\"usage-and-pricing\">\u003Ca class=\"docs-anchor\" href=\"#usage-and-pricing\" aria-label=\"Link to this section\">\u003C/a>Usage and pricing\u003C/h2>\n\u003Cp>Native \u003Ccode>usage.input_tokens\u003C/code> maps to \u003Ccode>promptTokens\u003C/code>. Native \u003Ccode>output_tokens\u003C/code> maps to\n\u003Ccode>completionTokens\u003C/code>. Their sum maps to \u003Ccode>totalTokens\u003C/code>. Prices change. See the\n\u003Ca href=\"https://docs.typesafe.ai/models\">TypeSafe model reference\u003C/a> for current rates.\nState is ingested once for all questions. Use provider-reported input usage\nunchanged. Do not multiply it by the question count. Hosted router fees are additional. A decision routed through the Standard Agents platform logs the price the router charged, fee included; when the router reports none, the log shows the provider-reported cost plus the fee percent as an estimate.\u003C/p>\n\u003Cp>\u003Ccode>jev-latest\u003C/code> and \u003Ccode>jev-preview\u003C/code> currently resolve to \u003Ccode>jev-1.14.0\u003C/code>. See the \u003Ca href=\"https://docs.typesafe.ai/models\">TypeSafe model reference\u003C/a> for alias updates. Aliases may move to new versions. \u003Ccode>result.model\u003C/code> identifies the actual version;\nre-audit rates when aliases change, or pin \u003Ccode>jev-1.13.0\u003C/code> for a fixed version.\nAn unpriced resolved model does not receive an invented \u003Ccode>usage.cost\u003C/code>.\nCurrent context limits are 64k tokens for state plus all questions and 32k for\nstate plus the longest question. See the \u003Ca href=\"https://docs.typesafe.ai/models\">TypeSafe model reference\u003C/a>\nand \u003Ca href=\"https://docs.typesafe.ai/api\">native API reference\u003C/a> for current limits.\u003C/p>",[9,13,16,19,22,25],{"id":10,"text":11,"depth":12},"install-and-configure","Install and configure",2,{"id":14,"text":15,"depth":12},"decide-within-a-thread","Decide within a thread",{"id":17,"text":18,"depth":12},"questions-and-native-conversion","Questions and native conversion",{"id":20,"text":21,"depth":12},"answers-and-thresholds","Answers and thresholds",{"id":23,"text":24,"depth":12},"standalone-use","Standalone use",{"id":26,"text":27,"depth":12},"usage-and-pricing","Usage and pricing","providers/typesafe","docs","Providers",{"path":32,"title":33,"navTitle":33},"providers/openrouter","@standardagents/openrouter",{"path":35,"title":36,"navTitle":36},"providers/xai","@standardagents/xai","/docs/providers/typesafe.md","https://github.com/standardagents/agentbuilder/blob/main/docs/providers/typesafe.mdx",1794580510062]