v139 · AI · Prompt API

Prompt Playground

Chat with Gemini Nano running locally in your browser. No server, no API key, no network round-trip for inference. Uses LanguageModel.create() and session.promptStreaming().

Checking Gemini Nano availability…

Enable Gemini Nano in Chrome

  1. Open chrome://flags/#optimization-guide-on-device-model
  2. Set "Enables optimization guide on device" to Enabled BypassPerfRequirement
  3. Open chrome://flags/#prompt-api-for-gemini-nano
  4. Set "Prompt API for Gemini Nano" to Enabled
  5. Restart Chrome, then open chrome://components/ and check for "Optimization Guide On Device Model"
  6. Click "Check for update" — the model downloads in the background (≈1.7 GB)

Session config

Send a message to start. The model runs entirely in your browser.

API code

// Check availability
const available = await LanguageModel.availability();
// → 'readily' | 'after-download' | 'no'

// Create a session
const session = await LanguageModel.create({
  systemPrompt: 'You are a helpful assistant.',
  temperature: 1.0,
  topK: 3,
});

// Stream a response
const stream = session.promptStreaming('Summarize CSS gap decorations');
for await (const chunk of stream) {
  process.stdout.write(chunk); // incremental text
}

// Check token budget
console.log(session.tokensSoFar, '/', session.maxTokens);

// Clone for a parallel conversation
const session2 = await session.clone();

see also