v148 · 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().
Prompt API unavailable in this browser profile
The interface, model, and hardware requirements are separate checks. A Chrome version alone does not prove availability.
- Use a supported desktop Chrome build and a secure top-level page.
- Allow the on-device model to download and keep sufficient free storage.
- Check device requirements and enterprise policy in the current Prompt API documentation.
- After changing the profile or model state, choose Check again.
Session config
API code
// Check availability for the text languages this session will use
const availability = await LanguageModel.availability({
expectedInputs: [{ type: 'text', languages: ['en'] }],
expectedOutputs: [{ type: 'text', languages: ['en'] }],
});
// Current values: 'available' | 'downloadable' | 'downloading' | 'unavailable'
// Earlier prototypes used: 'readily' | 'after-download' | 'no'
// Create a session
const session = await LanguageModel.create({
initialPrompts: [{
role: 'system',
content: '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.contextUsage, '/', session.contextWindow);
// Clone for a parallel conversation
const session2 = await session.clone();
see also
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗