Last updated: March 24, 2026
Before using a Built-in AI API, you must check its availability on the user's device. The browser might need to download the model weights (which can be several gigabytes) before it can run inference.
When you call the availability() method, it returns a promise that resolves to one of the following strings:
| Enum Value | Description | Action |
|---|---|---|
unavailable | The API is not supported on this device, or the required flags are not enabled. | You should gracefully disable or hide the feature in your application. |
downloadable | The API is supported, but the model needs to be downloaded. | Calling create() will initiate the download process over the network. |
downloading | The model download is currently in progress (whether triggered by this page, another tab, or the browser itself). | Wait for the model to be available. You can safely call create() and it will resolve once the download finishes. |
available | The API is supported, and the necessary model is already downloaded. | Call create() and it will resolve almost instantly, ready for inference. |
// 1. Check availability
const status = await LanguageModel.availability();
if (status === 'unavailable') {
console.log("Not supported.");
return;
}
if (status === 'downloadable') {
console.log("Model needs to be downloaded.");
}
// 2. Create session and monitor download
const options = {
monitor(m) {
m.addEventListener("downloadprogress", (e) => {
console.log("Downloading: " + Math.round(e.loaded * 100) + "%");
});
}
};
const session = await LanguageModel.create(options);
console.log("LanguageModel model is ready!");Click to query the browser for the LanguageModel status.