files/en-us/web/api/summarizer/create_static/index.md
{{APIRef("Summarizer API")}}{{SeeCompatTable}}{{securecontext_header}}
The create() static method of the {{domxref("Summarizer")}} interface creates a new Summarizer instance from which to generate summaries.
[!NOTE] The
create()method requires transient activation, that is, it must be invoked in response to a user action such as a mouse click or button press.
Summarizer.create()
Summarizer.create(options)
options {{optional_inline}}
Summarizer. Possible values include:
expectedInputLanguages
["en"].expectedContextLanguages
sharedContext passed to the Summarizer, or a context specified during a {{domxref("Summarizer.summarize", "summarize()")}} or {{domxref("Summarizer.summarizeStreaming", "summarizeStreaming()")}} call), which should be valid BCP 47 language tags. Defaults to ["en"].format
markdown.length
short.monitor
outputLanguage
Summarizer, which should be a valid BCP 47 language tag. Defaults to en.sharedContext
Summarizer generate more suitable summaries.signal
create() operation to be aborted via the associated {{domxref("AbortController")}}. The exact effect is dependant on when {{domxref("AbortController.abort()")}} is called:
abort() is called before the create() promise resolves, the create() operation is cancelled.abort() is called after the create() promise fulfills, it has the same effect as calling {{domxref("Summarizer.destroy()")}}: The resources assigned to the resulting Summarizer instance are released, and any ongoing and subsequent Summarizer method calls will reject with an AbortError.type
Summarizer to generate. Defaults to key-points.A {{jsxref("Promise")}} that fulfills with a Summarizer object instance.
NotAllowedError {{domxref("DOMException")}}
NotSupportedError {{domxref("DOMException")}}
expectedContextLanguages, expectedInputLanguages, or outputLanguage are invalid, or not supported.OperationError {{domxref("DOMException")}}
Summarizer creation failed for any other reason.Summarizer creationconst summarizer = await Summarizer.create({
sharedContext:
"A general summary to help a user decide if the text is worth reading",
type: "tldr",
length: "short",
format: "markdown",
expectedInputLanguages: ["en-US"],
outputLanguage: "en-US",
});
{{Specifications}}
{{Compat}}