demo · v137 · origin trial

Prompt API

The on-device LanguageModel — Gemini Nano running locally — is the foundation that the other built-in AI APIs (Summariser, Translator, Rewriter, Writer) ride on top of. Type a prompt, hit run, watch tokens stream from the model on your own machine.

Heads up · origin trial / flagThe Prompt API is in an origin trial. To run locally, enable chrome://flags/#prompt-api-for-gemini-nano and chrome://flags/#optimization-guide-on-device-model, restart, then visit chrome://components and update Optimization Guide On Device Model. The probe below tells you exactly what your browser will do.
probing…
no output yet

the code

const avail = await LanguageModel.availability();
if (avail !== "available") {
  // "downloadable" → call create() to trigger download
  // "after-download" → wait for monitor.progress
}
const session = await LanguageModel.create({ initialPrompts: [
  { role: "system", content: "You are concise." },
]});
const stream = await session.promptStreaming("haiku about bugs");
for await (const chunk of stream) out.textContent += chunk;

see also