The Rewriter API provides a high-level interface to call on the browser's built-in language model to transform, rephrase, expand, or adjust the tone and format of existing text inputs.
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 rewriter session with the provided configuration. Returns a Promise resolving to an Availability string ('available' | 'downloadable' | 'unavailable' | 'downloading').
static availability(options?: RewriterCreateCoreOptions): Promise<Availability>;| Name | Type / Values | Description |
|---|---|---|
| tone | "as-is" | "more-formal" | "more-casual" | The directional tone of the rewritten text. Default is "as-is". |
| format | "as-is" | "plain-text" | "markdown" | Output format. Default is "as-is". |
| length | "as-is" | "shorter" | "longer" | The target length of the text relative to the input. Default is "as-is". |
| expectedInputLanguages | sequence<DOMString> | BCP-47 language tags for the input text you intend to rewrite. |
| expectedContextLanguages | sequence<DOMString> | BCP-47 language tags for the context strings. |
| outputLanguage | DOMString | The language to output the rewritten text in. |
Creates and returns a new Rewriter 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?: RewriterCreateOptions): Promise<Rewriter>;Inherits all properties from RewriterCreateCoreOptions (above), plus:
| Name | Type | Description |
|---|---|---|
| sharedContext | DOMString | Background context shared across all rewrite 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 rewritten text.
rewrite(input: DOMString, options?: RewriterRewriteOptions): Promise<DOMString>;| Name | Type | Description |
|---|---|---|
| context | DOMString | Context specific to this individual rewriting request. |
| signal | AbortSignal | Pass an AbortController.signal to cancel this specific operation. |
Identical parameters to rewrite(), but returns a ReadableStream of string chunks as they are generated.
rewriteStreaming(input: DOMString, options?: RewriterRewriteOptions): 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?: RewriterRewriteOptions): Promise<double>; Signals that the rewriter is no longer needed, allowing the browser to free the model resources. Any pending rewrite() calls are rejected with an AbortError.
destroy(): undefined;Read-only attributes representing the configuration of the current session.
readonly sharedContext: DOMStringreadonly tone: RewriterTonereadonly format: RewriterFormatreadonly length: RewriterLengthreadonly 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).