demo · v131
Streaming translation for live chat
The motivating chat-app use case: a message comes in, you want to start showing the translated text as soon as the first tokens arrive — not wait for the full sentence. translator.translateStreaming(text) returns a ReadableStream<string> you can pipe into the UI tokens-at-a-time.
flags
Enable
chrome://flags/#translation-api and visit chrome://components to install the language packs you intend to use. If the model isn't on the device, create() rejects with NotSupportedError.
the api
const tx = await Translator.create({ sourceLanguage: "en", targetLanguage: "es" });
const stream = tx.translateStreaming("Long text...");
for await (const chunk of stream) {
outEl.append(chunk); // tokens appear as the model emits them
}