Notă
Accesul la această pagină necesită autorizare. Puteți încerca să vă conectați sau să modificați directoarele.
Accesul la această pagină necesită autorizare. Puteți încerca să modificați directoarele.
The Proofreader API is an experimental web API that allows you to correct grammar, spelling, and punctuation errors in text by using a small language model (SLM) that is built into Microsoft Edge, from your website's or browser extension's JavaScript code.
For introductory information about the Proofreader API, see Proofreader API Explainer.
Detailed contents:
- Availability of the Proofreader API
- Decide which API to use
- The Aion Instruct model
- Enable the Proofreader API
- See a working example
- Use the Proofreader API
- Send feedback
- See also
Availability of the Proofreader API
The Proofreader API is available as a developer preview in Microsoft Edge, starting with version 158. You can test the Proofreader API locally in Microsoft Edge, on your device only. See Enable the Proofreader API, below.
The Proofreader API is optimized to correct grammar, spelling, and punctuation errors in text content. To learn more about an alternative for more custom prompt engineering scenarios that may not be served by these APIs, see Prompt a built-in language model with the Prompt API.
Decide which API to use
To leverage AI capabilities in websites and browser extensions, you can also use the following methods:
Send network requests to cloud-based AI services, such as Azure AI solutions.
Run local AI models using the Web Neural Network (WebNN) API or ONNX Runtime for Web.
The Proofreader API uses a small language model (SLM) that runs on the same device where the inputs to and outputs of the model are used (that is, locally). This has the following benefits compared to cloud-based solutions:
Reduced cost: There's no cost associated with using a cloud AI service.
Network independence: Beyond the initial model download, there's no network latency when prompting the model, and the model can also be used when the device is offline.
Improved privacy: The data that's input to the model never leaves the device, and isn't collected (such as to train AI models).
The Proofreader API use a model that's provided by Microsoft Edge and built into the browser, which comes with the additional benefits over custom local solutions such as those based on WebGPU, WebNN, or WebAssembly:
Shared one-time cost: The browser-provided model is downloaded when the API is called for the first time, and then the model is shared across all websites that run in the browser, reducing network costs for developers and users.
Simplified usage for web developers: The built-in model can be run by using straightforward web APIs, and doesn't require AI/ML expertise or using third-party frameworks.
The Aion Instruct model
In Microsoft Edge, the Proofreader API uses the Aion Instruct model, which is built into the browser. Aion Instruct is a capable 2.3B parameter small language model which excels at text-based tasks. To learn more about the model, see the model card at microsoft/Aion-1.0-Instruct, at Hugging Face.
Disclaimer
Like other language models of this size, Aion Instruct can potentially behave in ways that are unreliable, inaccurate, unfair, or offensive. You should consider the risks of passing untrusted content to the model, and validate the source and integrity of content before using the content as model input. To learn more about the model's Responsible AI considerations, see Responsible AI Considerations, in microsoft/Aion-1.0-Instruct, at Hugging Face.
Hardware requirements
The Proofreader API developer preview is intended to work on devices that have hardware capabilities that produce Small Language Model (SLM) outputs that have predictable quality and latency.
The Proofreader API has the following requirements:
Operating systems:
- Windows 10 or 11.
- macOS 13.3 or later.
- 64-bit (x64) Linux with Vulkan GPU drivers and Microsoft Edge 159 or later.
Storage: At least 20 GB available on the volume that contains your Edge profile. If the available storage drops below 5 GB, the model will be deleted to ensure that other browser features have sufficient space to function.
GPU: 3 GB of VRAM or more.
Network: Unlimited data plan or unmetered connection. The model is not downloaded if using a metered connection.
To check if your device supports the Proofreader API developer preview, see Enable the Proofreader API below and check your device performance class.
Due to the experimental nature of the Proofreader API, you might observe issues on specific hardware configurations. If you see issues on specific hardware configurations, please provide feedback by opening a new issue at the MSEdgeExplainers repository.
Availability of the Aion Instruct model
An initial download of the Aion Instruct model is required the first time that a website calls an API that requires an on-device model. To monitor the downloading of the model, use the monitor option when creating a new Proofreader API session. See Monitor the progress of the model download, below.
The model is unavailable in the following conditions:
- If the On-device AI option is disabled under Settings > Copilot and AI.
- If the GenAILocalFoundationalModelSettings or ComponentUpdatesEnabled enterprise policies are configured to block the model download.
- If the device doesn't meet hardware, disk space, or network requirements.
Consideration for Edge Canary, Dev, and Beta
In Microsoft Edge Canary, Dev, and Beta, the On-device AI option is disabled by default under Settings > Copilot and AI, to avoid downloading the model separately for each channel.
If you enable the Proofreader API flag in edge://flags, the On-device AI option is automatically enabled in Canary, Dev, and Beta. See Enable the Proofreader API, below.
Enable the Proofreader API
To use the Proofreader API in Microsoft Edge:
Make sure you're using Microsoft Edge version 158 or later.
In Microsoft Edge, open a new tab or window, and then go to
edge://flags.In the search box, at the top of the page, enter Proofreader API.
The page is filtered to show the matching flag.
Select Enabled next to the Proofreader API flag:

Optionally, to log information locally that may be useful for debugging issues, also enable the Enable on device AI model debug logs flag.
Restart Microsoft Edge.
To check if your device meets the hardware requirements for the Proofreader API developer preview, open a new tab, go to
edge://on-device-internals, and check the Device performance class value.If your device performance class is Medium or greater, the Proofreader API is expected to be supported on your device. If you continue to notice issues, please file a new issue.
See a working example
To see the Proofreader API in action, and examine existing code that uses these APIs:
Enable the Proofreader API, as described above.
In Microsoft Edge, open a tab or window and go to the Proofreader API playground.
In the information banner at the top, check the status. The status initially reads On-device API and model downloading:

After the model has been downloaded, the information banner reads On-device API and model available, indicating that the API and model can be used:

If the model doesn't start downloading, restart Microsoft Edge and try again.
The Proofreader API is only supported on devices that meet certain hardware requirements. For more information, see Hardware requirements, above.
Optionally change the content and settings in the page. For example, modify the text to proofread, or change the expected input language.
Click the Proofread button, at the bottom of the page.
The output is generated in the response section of the page:

See also:
- /built-in-ai/ - Readme and source code for the Built-in AI playgrounds demo.
Use the Proofreader API
Check if the API is enabled
Before using the Proofreader API in your website's code, check that the API is enabled, by testing for the presence of the Proofreader object:
if (!Proofreader) {
// The Proofreader API is not available.
}
Check if the model can be used
The Proofreader API can only be used if the device supports running the model, and after the language model and model runtime have been downloaded by Microsoft Edge.
To check if the API can be used, use the availability() method:
const availability = await Proofreader.availability();
if (availability == "unavailable") {
// The model is not available.
}
if (availability == "downloadable" || availability == "downloading") {
// The model can be used, but it needs to be downloaded first.
}
if (availability == "available") {
// The model is available and can be used.
}
Create a new session
Creating a session instructs the browser to load the language model in memory, so that it can be used. Before you can use the Proofreader API to correct text, create a new session by using the create() method:
// Create a Proofreader session.
const session = await Proofreader.create();
To customize the model session, you can pass options to the create() method:
// Create a Proofreader session with options.
const session = await Proofreader.create(options);
The available options are listed below:
| Option | Description |
|---|---|
monitor |
A function that's used to monitor the progress of the model download. See Monitor the progress of the model download, below. |
expectedInputLanguages |
An array of strings. Each string is a language that the input text is expected to contain. For example: ["en", "es"]. |
Monitor the progress of the model download
To follow the progress of the downloading of the model, use the monitor option. This is useful when the model has not yet been fully downloaded onto the device on which the model will be used, to inform users of your website that they need to wait.
// Create a Proofreader session with the monitor option to monitor the model
// download.
const session = await Proofreader.create({
monitor: m => {
// Use the monitor object argument to add an listener for the
// downloadprogress event.
m.addEventListener("downloadprogress", event => {
// The event is an object with the loaded and total properties.
if (event.loaded == event.total) {
// The model is fully downloaded.
} else {
// The model is still downloading.
const percentageComplete = (event.loaded / event.total) * 100;
}
});
}
});
Run the Proofreader API
To generate revised text by using the Proofreader API, after you have created the corresponding model session, use the session.proofread() method. This method returns a promise that resolves after the Proofreader API has finished generating corrected text.
// Create a Proofreader session.
const session = await Proofreader.create();
// Correct the text and wait for the result.
const result = await session.proofread(textToBeCorrected);
// Use the result.
console.log(result);
Use the result of the Proofreader API
The session.proofread() method returns a promise that resolves to an object that has the following properties:
| Property | Description |
|---|---|
correctedInput |
The corrected text, as a string. |
corrections |
An array of correction objects. |
A correction object has the following properties:
| Property | Description |
|---|---|
startIndex |
The index of the first character, in the input text, that was corrected. |
endIndex |
The index of the last character, in the input text, that was corrected. |
correction |
The string that replaces the incorrect text. |
The following example shows how to use the result of the session.proofread() method:
// Create a Proofreader session.
const session = await Proofreader.create();
// Correct the text and wait for the result.
const result = await session.proofread(textToBeCorrected);
// Log the corrected text.
console.log("Corrected text:", result.correctedInput);
// Log each correction.
result.corrections.forEach(({ startIndex, endIndex, correction }) => {
const initialText = textToBeCorrected.slice(startIndex, endIndex);
console.log(`Replaced text "${initialText}" (index ${startIndex} to ${endIndex}) with "${correction}"`);
});
Destroy a session
Destroy the session to let the browser know that you don't need the language model anymore, so that the model can be unloaded from memory.
You can destroy a session in two different ways:
- By using the
destroy()method. - By using an
AbortController.
Destroy a session by using the destroy() method
You can use the session.destroy() method to destroy a Proofreader session:
const session = await Proofreader.create();
// Later, destroy the session by using the destroy method.
session.destroy();
Destroy a session by using an AbortController
Alternatively, you can create an AbortController object, create a Proofreader session, and then call abort():
// Create an AbortController object.
const controller = new AbortController();
// Create a Proofreader session and pass the
// AbortController signal object by using the signal option.
const session = await Proofreader.create({ signal: controller.signal });
// Later, such as when the user interacts with the UI, destroy the session by
// calling the abort() function of the AbortController object.
controller.abort();
Send feedback
We're very interested in learning about the range of scenarios for which you intend to use the Proofreader API, any issues with the API or language model, and whether new task-specific APIs would be useful.
To send feedback about your scenarios and the tasks you want to achieve, please add a comment to the Proofreader API feedback issue.
If you notice any issues when using the API instead, please report it on the repo.
You can also contribute to the discussion about the design of the Proofreader API at the W3C Web Machine Learning Working Group repository.
See also
- Proofreader API Explainer, on the Web Machine Learning GitHub repo.
- Write, rewrite, and summarize text with the Writing Assistance APIs.
- Prompt a built-in language model with the Prompt API.
- /built-in-ai/ - Source code and Readme for the Built-in AI playgrounds demo.