WebAI Studio

The Decisions API (window.DecisionModel) evaluates input text against a caller-defined schema of structured questions (boolean, choice, and score) on the user's device, returning a selected option label, confidence score, and probability distribution for each question.

Enable #decisions-api in chrome://flags to use this API. For the DevTrial prototype, cross-origin iframes reuse the "language-model"Permissions-Policy feature.
No flag? The WebAI Studio extension polyfills window.DecisionModel on every page with a local Laya decision encoder running on LiteRT.js. The model is downloaded once from Hugging Face; inputs never leave the device. Pick the model in the extension settings and inspect calls in the DevTools panel.

Use cases

Intent & action routing

Map a user's natural-language input or support request to a predefined set of application actions, departments, or UI filters.

Pre-send checks & moderation

Evaluate drafts or comments locally against boolean criteria (such as policy checks or tone checks) before submitting or escalating to a generative model.

Ordinal rating & ranking

Score items along an ordered scale (such as 1 to 5 severity or relevance) and read the expected value expectedScore.

Question types

A schema passed to DecisionModel.create() contains a questions array. Each question specifies an id, a prompt, and one of three type values:

TypeOptions RequiredOutput Fields
booleanNo (implicit "true" / "false")Returns label ("true" or "false"), probability (P("true")), confidence, and probabilities.
choiceYes (2 or more { label, description } items)Returns the top option label, confidence, and probabilities across all options.
scoreOptional (ordered levels; defaults to "1" through "5" when omitted)Returns label, expectedScore (weighted average across levels), confidence, and probabilities.

DecisionModel.availability()

Checks whether the browser supports creating a decision model session for the given options.

staticavailability(options?: DecisionModelCreateOptions): Promise<Availability>;

Returns

A promise that resolves to an Availability string: 'available', 'downloadable', 'downloading', or 'unavailable'.

Interactive Playground

DecisionModel.create()

Creates a new DecisionModel instance configured with the provided question schema.

staticcreate(options: DecisionModelCreateOptions): Promise<DecisionModel>;
Interactive Playground

decisionModel.decide()

Evaluates the input string against all questions defined in the session schema and returns a DecisionResult: a record keyed by question id, so you can read result.category.label or destructure const { command } = await decisionModel.decide(input). (A backward-compatible .classify() alias is also supported.)

decide(input: DOMString, options?: DecisionModelDecideOptions): Promise<DecisionResult>;
Interactive Playground

Decision properties (Decision)

PropertyTypeDescription
idDOMStringThe question identifier defined in the schema.
labelDOMStringThe highest-probability option label ("true"/"false" for boolean, or one of the options).
confidencedouble (0.0 – 1.0)Always the winning label's probability.
probabilitydouble? (0.0 – 1.0)Present for boolean questions: probability of "true" (P("true")).
expectedScoredouble?Present for score questions: weighted by parsed numeric option labels when all labels are finite numbers, or 1..N ordinal indices otherwise.
probabilitiessequence<OptionProbability>List of { label, probability } entries across all options for the question.

decisionModel.destroy()

Releases the resources associated with the decision model session when it is no longer needed.

Interactive Playground

API reference (Prospective WebIDL)

Example Output