v148 · AI · JavaScript

Local-First Workflow

Three concrete app flows powered by on-device Gemini Nano: a redaction assistant that strips PII, a triage tool that categorises support tickets, and a form assistant that auto-fills replies. All inference runs locally — no server round-trip, no API key.

On-device inference No API key No network needed
⚠ Prompt API not detected — these demos use a local simulation so you can explore the workflow. Enable via chrome://flags/#prompt-api-for-gemini-nano or join the origin trial.
Document with PII
Click redacted text to reveal
Redacted output
Press "Redact PII" to process the document…
Category:
Incoming ticket
Classification result
Press "Classify & summarise" to triage the ticket…
Customer message
Tone
Suggested reply
Press "Generate reply" to draft a response…
// Local-first pattern: session + streaming + graceful fallback async function localInference(systemPrompt, userPrompt) { if (!window.ai?.languageModel) throw new Error('Prompt API not available'); const session = await window.ai.languageModel.create({ systemPrompt, temperature: 0.3, topK: 40, }); const stream = await session.promptStreaming(userPrompt); let result = ''; for await (const chunk of stream) { result = chunk; // cumulative updateUI(result); } return result; }

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗