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 |
Mike Wasserman | 3848722 | 2025-05-13 17:07:32 | [diff] [blame] | 17 | extension authors need to configure it in the `manifest.json`: |
Mingyu Lei | 3caacb17 | 2024-11-01 07:18:55 | [diff] [blame] | 18 | |
| 19 | ```json |
| 20 | { |
Mingyu Lei | 3caacb17 | 2024-11-01 07:18:55 | [diff] [blame] | 21 | "trial_tokens": [<GENERATED_TOKEN>], |
| 22 | } |
Mingyu Lei | 3caacb17 | 2024-11-01 07:18:55 | [diff] [blame] | 23 | ``` |
| 24 | |
| 25 | ## Verifying the API is working |
| 26 | |
Mike Wasserman | ed159149 | 2025-05-01 04:54:57 | [diff] [blame] | 27 | The extension authors can verify if the API is available by checking for the |
Mike Wasserman | 3848722 | 2025-05-13 17:07:32 | [diff] [blame] | 28 | presence of the `LanguageModel` entrypoint from extension window and worker |
| 29 | scripts. If the object is defined, the authors can follow the |
| 30 | [explainer](https://github.com/explainers-by-googlers/prompt-api) and |
| 31 | [developer docs](https://developer.chrome.com/docs/extensions/ai/prompt-api) |
Mike Wasserman | ed159149 | 2025-05-01 04:54:57 | [diff] [blame] | 32 | to check availability and test the APIs usage. |
Mingyu Lei | 3caacb17 | 2024-11-01 07:18:55 | [diff] [blame] | 33 | |
| 34 | ## Related Links |
| 35 | |
Mike Wasserman | ed159149 | 2025-05-01 04:54:57 | [diff] [blame] | 36 | - [Explainer on GitHub](https://github.com/webmachinelearning/prompt-api) |
| 37 | - [API feedback](https://github.com/webmachinelearning/prompt-api/issues) |
| 38 | - [Reporting bugs](https://issues.chromium.org/issues/new?component=1583624) |
| 39 | - [Extension origin trial](https://developer.chrome.com/blog/prompt-api-origin-trial) |
| 40 | - [Developer docs](https://developer.chrome.com/docs/extensions/ai/prompt-api) |