← Chrome 148 reference

v148 · web ai · origin trial

Prompt API Sampling Parameters

Limited availability

  • Chrome · 148 (LanguageModel); sampling parameters by origin trial only
  • Edge · 138 behind a flag (LanguageModel)
  • Firefox · not shipped (position: negative)
  • Safari · not shipped (position: oppose)

Not in Baseline. webstatus.dev languagemodel reports limited availability (Chrome 148 only; queried 2026-11-15). web-features has no separate entry for the sampling parameters, and BCD api/LanguageModel.json has no sub-entries for temperature, topK or params(). See the full table.

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.

To enable it: register your origin for the AIPromptAPIParams origin trial (desktop only: Windows, macOS, Linux, ChromeOS; third-party tokens allowed) and serve the token. For local testing, launch Chrome with --enable-blink-features=AIPromptAPIParams. Since Chrome 148 the API surface has already moved: the current spec deprecates these raw parameters in favour of samplingMode.

Source: Chromium M148 branch (7778) runtime_enabled_features.json5 (AIPromptAPIParams implies AIPromptAPILegacyParams); trial window 148–153 from the ChromeStatus API record.

at a glance

Status in 148Origin trial
FlagOrigin trial token (AIPromptAPIParams); local testing: --enable-blink-features=AIPromptAPIParams
Standards positionFirefox: Negative  ·  Safari: Oppose (parent Prompt API, per ChromeStatus 2026-11-15)
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 feature 6325545693478912 summary; Prompt API spec.

shape of the API

The Prompt API sampling parameters extend session options and language model instances with temperature and topK controls, alongside the LanguageModel.params() capability inspector.

Formal syntax (Web IDL)

The sampling-parameter members as they appear in the current spec (excerpt, verbatim, including the spec's own deprecation comments). Chrome 148 exposes the same members with the same types, gated by AIPromptAPILegacyParams (implied by the AIPromptAPIParams origin trial).

[Exposed=Window, SecureContext]
interface LanguageModel : EventTarget {
  static Promise<LanguageModel> create(optional LanguageModelCreateOptions options = {});
  static Promise<Availability> availability(optional LanguageModelCreateCoreOptions options = {});
  // **DEPRECATED**: This method will be removed; use samplingMode instead. Only available in extension contexts.
  static Promise<LanguageModelParams?> params();

  // (other LanguageModel members omitted from this excerpt)

  // **DEPRECATED**: This attribute will be removed; use samplingMode instead. Only available in extension contexts.
  readonly attribute unsigned long topK;
  // **DEPRECATED**: This attribute will be removed; use samplingMode instead. Only available in extension contexts.
  readonly attribute float temperature;
};

// **DEPRECATED**: This interface will be removed; use samplingMode instead. Only available in extension contexts.
[Exposed=Window, SecureContext]
interface LanguageModelParams {
  readonly attribute unsigned long defaultTopK;
  readonly attribute unsigned long maxTopK;
  readonly attribute float defaultTemperature;
  readonly attribute float maxTemperature;
};

dictionary LanguageModelCreateCoreOptions {
  // Note: these two have custom out-of-range handling behavior, not in the IDL layer.
  // They are unrestricted double so as to allow +Infinity without failing.
  // **DEPRECATED**: This option will be removed; use samplingMode instead. Only available in extension contexts.
  unrestricted double topK;
  // **DEPRECATED**: This option will be removed; use samplingMode instead. Only available in extension contexts.
  unrestricted double temperature;
};
Source: Prompt API spec IDL index (fetched 2026-11-15); Chrome 148 shape from M148 language_model.idl and M148 language_model_create_options.idl.

Session creation options

LanguageModelCreateOptions.temperatureunrestricted double — Controls token distribution sharpness. 0.0 = fully deterministic (argmax); higher values increase randomness. Default and max are device-dependent.
LanguageModelCreateOptions.topKunrestricted double — Restricts sampling to the top-K most probable tokens. 1 = greedy decoding. Device-dependent max. Fractional values are rounded down (WebIDL IntegerPart).

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 (and Issue #203). Field names paraphrased; verify against the live spec before shipping. Option types corrected to unrestricted double per the IDL above (2026-11-15).

Errors and out-of-range values

Source: Prompt API explainer §Legacy: Configuration of per-session raw parameters (read 2026-11-15).

Successor: samplingMode (not in Chrome 148)

After Chrome 148 the spec replaced the raw parameters with seven semantic presets, and the ChromeStatus record for this feature is now titled “Prompt API Sampling Mode” with shipping proposed for Chrome 160. The Chrome 148 branch IDL has no samplingMode member, so it is not part of this release’s surface:

enum LanguageModelSamplingMode { "most-predictable", "predictable", "slightly-predictable", "balanced", "slightly-creative", "creative", "most-creative" };

// on LanguageModelCreateCoreOptions:
LanguageModelSamplingMode samplingMode;
// on LanguageModel:
readonly attribute LanguageModelSamplingMode? samplingMode;
Source: Prompt API spec IDL index; explainer §Configuration of sampling modes; ChromeStatus 6325545693478912.

example

Query device limits and configure sampling parameters with LanguageModel.create():

// 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,
  initialPrompts: [
    { role: "system", content: "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
  initialPrompts: [
    { role: "system", content: "Extract structured data from text." }
  ]
});
const json = await session.prompt(
  "Extract: 'Alice, 30, engineer, London'"
);

System prompts go in initialPrompts with role: "system"; Chrome 148’s LanguageModelCreateOptions has no systemPrompt member, so the earlier version of these examples passed an option that was silently ignored (corrected 2026-11-15).

Source: M148 language_model_create_options.idl (initialPrompts); explainer §System prompts.

Live example

All concept demos for this feature are listed on the Chrome Platform Showcase feature page. The embedded sampling playground uses the raw temperature/topK options, so it needs the origin trial (or the local-testing switch above) and an on-device model.

Live example from the Chrome Platform Showcase (route HEAD-checked 200, 2026-11-15). Sibling concepts: determinism test and creative parameter explorer.Source: chrome-platform-showcase

browser support

Per-version data for the parent LanguageModel interface from BCD api/LanguageModel.json (raw JSON fetched 2026-11-15). BCD has no entries for the temperature/topK options and attributes or for params(), so the sampling-parameter column is interim data from ChromeStatus and the Chromium M148 branch, labelled as such.

BrowserLanguageModel (BCD)Sampling parameters (interim)
Chrome (desktop)148148–153 origin trial AIPromptAPIParams (ChromeStatus); spec now deprecates them for web pages
Chrome AndroidNot supported (version_added: false)Not supported: the trial is desktop-only (origin_trial_os)
Edge138 behind flag #edge-llm-prompt-api-for-phi-miniUnknown (no BCD or ChromeStatus data)
FirefoxNot supported (version_added: false)Not supported; position: negative (#1213)
SafariNot supported (version_added: false)Not supported; position: oppose (#495)
Source: BCD api/LanguageModel.json; webstatus.dev languagemodel; chromestatus browser views (queried 2026-11-15); M148 runtime_enabled_features.json5; Mozilla standards-positions #1213; WebKit standards-positions #495.

see also