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().
Enable Gemini Nano in Chrome
- Open
chrome://flags/#optimization-guide-on-device-model - Set "Enables optimization guide on device" to Enabled BypassPerfRequirement
- Open
chrome://flags/#prompt-api-for-gemini-nano - Set "Prompt API for Gemini Nano" to Enabled
- Restart Chrome, then open
chrome://components/and check for "Optimization Guide On Device Model" - Click "Check for update" — the model downloads in the background (≈1.7 GB)
Session config
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();