The Writer API provides a high-level interface to call on the browser's built-in language model to generate net-new material given a writing task prompt, configuring tone, format, and length.
chrome://flags. For production origins, register for the joint Writer/Rewriter origin trial (Chrome 137 to 148). Checks if the browser currently supports creating a writer session with the provided configuration. Returns a Promise resolving to an Availability string ('available' | 'downloadable' | 'unavailable' | 'downloading').
static availability(options?: WriterCreateCoreOptions): Promise<Availability>;| Name | Type / Values | Description |
|---|---|---|
| tone | "formal" | "neutral" | "casual" | The overall tone of the generated writing. Default is "neutral". |
| format | "plain-text" | "markdown" | Output format. Default is "markdown". |
| length | "short" | "medium" | "long" | The target length of the text. Default is "short". |
| expectedInputLanguages | sequence<DOMString> | BCP-47 language tags for the writing-task input. |
| expectedContextLanguages | sequence<DOMString> | BCP-47 language tags for the context strings. |
| outputLanguage | DOMString | The language to generate the text in. |
Creates and returns a new Writer instance. If the model is downloadable, calling this method initiates the network download — in that case the call must happen from a user gesture (it requires and consumes transient user activation) or it rejects with a NotAllowedError.
static create(options?: WriterCreateOptions): Promise<Writer>;Inherits all properties from WriterCreateCoreOptions (above), plus:
| Name | Type | Description |
|---|---|---|
| sharedContext | DOMString | Background context shared across all write calls made by this instance. |
| monitor | CreateMonitorCallback | A function to track model weight downloads (emits downloadprogress events). |
| signal | AbortSignal | Pass an AbortController.signal to cancel session creation and halt downloads. |
Executes inference and returns a single Promise resolving to the complete generated text.
write(input: DOMString, options?: WriterWriteOptions): Promise<DOMString>;| Name | Type | Description |
|---|---|---|
| context | DOMString | Context specific to this individual writing request. |
| signal | AbortSignal | Pass an AbortController.signal to cancel this specific operation. |
Identical parameters to write(), but returns a ReadableStream of string chunks as they are generated.
writeStreaming(input: DOMString, options?: WriterWriteOptions): ReadableStream;Measures how much of the input quota the given input and context will consume (implementation-defined units, typically tokens). Returns a Promise resolving to a number.
measureInputUsage(input: DOMString, options?: WriterWriteOptions): Promise<double>; Signals that the writer is no longer needed, allowing the browser to free the model resources. Any pending write() calls are rejected with an AbortError.
destroy(): undefined;Read-only attributes representing the configuration of the current session.
readonly sharedContext: DOMStringreadonly tone: WriterTonereadonly format: WriterFormatreadonly length: WriterLengthreadonly expectedInputLanguages: FrozenArray<DOMString>?readonly expectedContextLanguages: FrozenArray<DOMString>?readonly outputLanguage: DOMString?readonly inputQuota: unrestricted double - The maximum input usage this instance accepts (implementation-defined units; may be Infinity if unrestricted).