files/en-us/web/api/summarizer/summarizestreaming/index.md
{{APIRef("Summarizer API")}}{{SeeCompatTable}}{{securecontext_header}}
The summarizeStreaming() method of the {{domxref("Summarizer")}} interface generates a new summary as a {{domxref("ReadableStream")}}.
summarizeStreaming(input)
summarizeStreaming(input, options)
input
options {{optional_inline}}
summarizeStreaming() operation. Possible values include:
context
Summarizer generate a more suitable summary.signal
summarizeStreaming() operation to be aborted via the associated {{domxref("AbortController")}}.A {{domxref("ReadableStream")}} containing the generated summary.
AbortError {{domxref("DOMException")}}
Summarizer was previously destroyed (had {{domxref("Summarizer.destroy()")}} called on it, or was aborted via its abort signal after creation).InvalidStateError {{domxref("DOMException")}}
NotAllowedError {{domxref("DOMException")}}
NotReadableError {{domxref("DOMException")}}
NotSupportedError {{domxref("DOMException")}}
context is not in language the Summarizer supports.UnknownError {{domxref("DOMException")}}
summarizeStreaming() call failed for any other reason, or a reason the user agent did not wish to disclose.summarizeStreaming() usageconst summarizer = await Summarizer.create({
sharedContext:
"A general summary to help a user decide if the text is worth reading",
type: "tldr",
length: "short",
});
const stream = summarizer.summarizeStreaming(myTextString);
let summary = "";
for await (const chunk of stream) {
summary += chunk;
}
console.log("Stream complete");
summaryOutput.textContent = summary;
{{Specifications}}
{{Compat}}