Mingyu Lei | 3caacb17 | 2024-11-01 07:18:55 | [diff] [blame] | 1 | # Prompt API for extension |
| 2 | |
Mingyu Lei | 3caacb17 | 2024-11-01 07:18:55 | [diff] [blame] | 3 | This document describes the status of the current implementation of the |
Mike Wasserman | ed159149 | 2025-05-01 04:54:57 | [diff] [blame] | 4 | [**Prompt API**](https://github.com/webmachinelearning/prompt-api) for Chrome |
| 5 | extensions, and how to verify. |
Mingyu Lei | 3caacb17 | 2024-11-01 07:18:55 | [diff] [blame] | 6 | |
| 7 | ## What’s supported |
| 8 | |
Mike Wasserman | ed159149 | 2025-05-01 04:54:57 | [diff] [blame] | 9 | The implementation generally intends to follow the |
| 10 | [explainer](https://github.com/explainers-by-googlers/prompt-api). |
Mingyu Lei | 3caacb17 | 2024-11-01 07:18:55 | [diff] [blame] | 11 | |
| 12 | ## Activation |
| 13 | |
| 14 | The API can be enabled by participating in the |
Mike Wasserman | ed159149 | 2025-05-01 04:54:57 | [diff] [blame] | 15 | [extension origin trial](https://developer.chrome.com/blog/prompt-api-origin-trial) |
Mingyu Lei | 3caacb17 | 2024-11-01 07:18:55 | [diff] [blame] | 16 | named `AIPromptAPIForExtension`. After obtaining the trial token, the |
| 17 | extension authors need to configure it in the `manifest.json` together with |
| 18 | the `aiLanguageModelOriginTrial` permission. |
| 19 | |
| 20 | ```json |
| 21 | { |
| 22 | "permissions": ["aiLanguageModelOriginTrial"], |
| 23 | "trial_tokens": [<GENERATED_TOKEN>], |
| 24 | } |
Mingyu Lei | 3caacb17 | 2024-11-01 07:18:55 | [diff] [blame] | 25 | ``` |
| 26 | |
| 27 | ## Verifying the API is working |
| 28 | |
Mike Wasserman | ed159149 | 2025-05-01 04:54:57 | [diff] [blame] | 29 | The extension authors can verify if the API is available by checking for the |
| 30 | presence of `LanguageModel` or `chrome.aiOriginTrial.languageModel` entrypoints |
| 31 | from extension window and worker scripts. If the object is defined, the authors |
| 32 | can follow the [explainer](https://github.com/explainers-by-googlers/prompt-api) |
| 33 | and [developer docs](https://developer.chrome.com/docs/extensions/ai/prompt-api) |
| 34 | to check availability and test the APIs usage. |
Mingyu Lei | 3caacb17 | 2024-11-01 07:18:55 | [diff] [blame] | 35 | |
| 36 | ## Related Links |
| 37 | |
Mike Wasserman | ed159149 | 2025-05-01 04:54:57 | [diff] [blame] | 38 | - [Explainer on GitHub](https://github.com/webmachinelearning/prompt-api) |
| 39 | - [API feedback](https://github.com/webmachinelearning/prompt-api/issues) |
| 40 | - [Reporting bugs](https://issues.chromium.org/issues/new?component=1583624) |
| 41 | - [Extension origin trial](https://developer.chrome.com/blog/prompt-api-origin-trial) |
| 42 | - [Developer docs](https://developer.chrome.com/docs/extensions/ai/prompt-api) |