v148 · Web APIs · AI

Writing Assistant

The Prompt API's streaming responses make it practical for writing assistance. Pick a mode — continue, improve, summarise, or change tone — write a passage, and let the on-device model suggest next steps. Suggestions stream token-by-token and can be accepted (appended to your document) or dismissed.

Checking Prompt API availability…
Document 0 words
// Chrome 148: Prompt API with streaming const session = await window.ai.languageModel.create({ systemPrompt: 'You are a helpful writing assistant.', }); // promptStreaming() returns an async iterable const stream = session.promptStreaming('Continue: The web platform...'); for await (const chunk of stream) { // Each chunk is a cumulative string (not a delta) outputEl.textContent = chunk; } // Or use prompt() for a complete response const result = await session.prompt('Summarise: ...'); console.log(result);

see also

implementation reference

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