The Prompt API Sampling Parameters allow developers to control the output variety of the built-in AI language model. Instead of exposing raw numerical parameters (e.g. topK and temperature) which can behave inconsistently across different underlying model families and versions, this feature introduces a categorical samplingMode enum. This allows the browser to handle the heavy lifting of mapping semantic presets to optimal raw parameters for a specific underlying model, providing developers with the necessary granularity to tune responses while maintaining cross-browser interoperability. enum AILanguageModelSamplingMode { "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 };
Explainers: https://github.com/webmachinelearning/prompt-api#sampling-parameters