← Chrome 148 reference

v148 · web ai · origin trial

Prompt API Sampling Parameters

Adds temperature and topK sampling parameters to the built-in Prompt API's LanguageModel interface, giving developers direct control over the randomness and diversity of on-device model outputs. Also exposes static helpers to query the browser's supported ranges for these parameters.

Origin trial / experimental This feature is in origin trial in Chrome 148. The API shape described here is based on the spec draft and may change before general availability. Register at the Chrome Origin Trials dashboard before shipping.

at a glance

Status in 148Origin trial
FlagNone (requires OT token)
Standards positionFirefox: No signal  ·  Safari: No signal
Specwebmachinelearning.github.io/prompt-api (W3C WICG)
Blink componentBlink>AI>Prompt
ChromeStatus6325545693478912 — Prompt API Sampling Parameters

why it exists

The built-in Prompt API relies on an on-device language model managed by the browser. Without sampling controls, every prompt runs with the browser's fixed defaults, which can produce deterministic but low-creativity outputs. By exposing temperature (how "random" the distribution is) and topK (how many candidate tokens are considered at each step), developers can tune the trade-off between coherence and variety — useful for creative writing, brainstorming, or testing model robustness.

Source: chromestatus summary + Prompt API spec.

shape of the API

Session creation options

LanguageModelCreateOptions.temperaturefloat — Controls token distribution sharpness. 0.0 = fully deterministic (argmax); higher values increase randomness. Default and max are device-dependent.
LanguageModelCreateOptions.topKunsigned long — Restricts sampling to the top-K most probable tokens. 1 = greedy decoding. Device-dependent max.

Instance attributes (read-back)

LanguageModel.temperatureThe effective temperature for this session (the value set at creation, or browser default).
LanguageModel.topKThe effective topK for this session.

Static capability query

LanguageModel.params()Returns a Promise<LanguageModelParams> describing the browser's defaultTemperature, maxTemperature, defaultTopK, and maxTopK.
Source: Prompt API spec §LanguageModel. Field names paraphrased; verify against the live spec before shipping.

example

Query device limits then create a creative session

// 1. Check what the device supports
const params = await LanguageModel.params();
console.log(params.defaultTemperature, params.maxTemperature);
// e.g. 1.0, 2.0

// 2. Create a higher-temperature session for brainstorming
const session = await LanguageModel.create({
  temperature: Math.min(1.8, params.maxTemperature),
  topK: 40,
  systemPrompt: "You are a creative writing assistant."
});

// 3. Verify the applied values
console.log(session.temperature, session.topK); // 1.8, 40

// 4. Prompt
const result = await session.prompt("Give me five unusual fantasy city names.");
console.log(result);

Conservative/deterministic session

const session = await LanguageModel.create({
  temperature: 0.2,
  topK: 1,  // greedy decoding — most deterministic
  systemPrompt: "Extract structured data from text."
});
const json = await session.prompt(
  "Extract: 'Alice, 30, engineer, London'"
);

browser support

ChromeOrigin trial in 148
EdgeTracking Chromium
FirefoxNo signal
SafariNo signal
Source: chromestatus browser views, May 2026.

see also