← Back to release summary

Prompt API Sampling Mode

Category
Miscellaneous
Type
New or changed feature
Status
Proposed (Chrome Proposed)
Intent stage
None

WPT details: Yes; the API surface is tested in https://wpt.fyi/results/ai/language-model (language-model-availability-sampling-mode.tentative.https.window.html and language-model-create-sampling-mode.tentative.https.window.html). Automated testing of sampling parameter effects on probabilistic model response is not readily feasible; instead we conduct rounds of evaluations on configuration updates.

Summary

Allows developers to configure language model output variety and creativity in the Prompt API using high-level samplingMode presets. Instead of exposing raw numerical parameters like topK and temperature that vary unpredictably across models, developers can choose semantic presets ranging from "most-predictable" for deterministic extraction to "most-creative" for open-ended brainstorming. The browser maps these presets to optimal sampling hyperparameters for the underlying model, providing developers with reliable response tuning while preserving cross-browser interoperability. enum LanguageModelSamplingMode { "most-predictable", // For strict consistency/factual extraction "predictable", // For highly focused outputs "slightly-predictable", // For moderately focused, consistent outputs "balanced", // The default state for standard prompting "slightly-creative", // For moderately varied, expressive outputs "creative", // For tasks favoring variety over strict facts "most-creative" // For maximum token diversity and brainstorming }; This feature is an enhancement of the Prompt API (https://chromestatus.com/feature/5134603979063296).

Motivation

Web developers using the Prompt API often need to steer response variance to match their task, such as deterministic decoding for structured data extraction, classification, and tool calling, or higher output diversity for open-ended drafting and brainstorming. Raw numerical hyperparameters (`temperature` and `topK`) were excluded from the initial Prompt API launch due to cross-browser and cross-model interoperability concerns raised during TAG review (https://github.com/w3ctag/design-reviews/issues/1093), leaving web applications with no way to tune output variability beyond default session behavior. `samplingMode` bridges this gap with seven semantic presets (`"most-predictable"` through `"most-creative"`) that express developer intent without coupling web code to a single model's hyperparameter scale. User agents map each preset to model-specific sampling configurations and can apply mode-specific inference optimizations (such as greedy speculative decoding in `"most-predictable"` sessions). Live interactive demo: https://isaacahouma.github.io/prompt-api-sampling-presets/

Standards & signals

Ecosystem

Samples: https://isaacahouma.github.io/prompt-api-sampling-presets

Explainers: https://github.com/webmachinelearning/prompt-api#sampling-parameters

View on chromestatus.com