Mingyu Lei | 3caacb17 | 2024-11-01 07:18:55 | [diff] [blame] | 1 | # Prompt API for extension |
| 2 | |
| 3 | - Contact: builtin-ai@chromium.org |
| 4 | |
| 5 | This document describes the status of the current implementation of the |
| 6 | [**Prompt API**](https://github.com/explainers-by-googlers/prompt-api) |
| 7 | for Chrome extension, and how to verify. |
| 8 | |
| 9 | Note that this API is not available by default. Chrome plans to do an |
| 10 | extension origin trial starting from M131 to evaluate its effectiveness |
| 11 | and to allow extension authors to give feedback. |
| 12 | |
| 13 | |
| 14 | ## What’s supported |
| 15 | |
| 16 | The API is implemented according to the |
| 17 | [explainer](https://github.com/explainers-by-googlers/prompt-api), but the |
| 18 | API namespace will be under `chrome.aiOriginTrial.languageModel` for the |
| 19 | extension origin trial. |
| 20 | |
| 21 | ## Activation |
| 22 | |
| 23 | The API can be enabled by participating in the |
| 24 | [extension origin trial](https://developer.chrome.com/docs/web-platform/origin-trials#extensions) |
| 25 | named `AIPromptAPIForExtension`. After obtaining the trial token, the |
| 26 | extension authors need to configure it in the `manifest.json` together with |
| 27 | the `aiLanguageModelOriginTrial` permission. |
| 28 | |
| 29 | ```json |
| 30 | { |
| 31 | "permissions": ["aiLanguageModelOriginTrial"], |
| 32 | "trial_tokens": [<GENERATED_TOKEN>], |
| 33 | } |
| 34 | |
| 35 | ``` |
| 36 | |
| 37 | ## Verifying the API is working |
| 38 | |
| 39 | The extension authors can verify if the API is available by checking the |
| 40 | `chrome.aiOriginTrial.languageModel` from the service worker script. |
| 41 | If the `AILanguageModel` object is defined, the authors can follow the |
| 42 | [explainer](https://github.com/explainers-by-googlers/prompt-api) to test |
| 43 | the APIs usage. |
| 44 | |
| 45 | ## Related Links |
| 46 | |
| 47 | - [Prompt API Explainer on GitHub](https://github.com/explainers-by-googlers/prompt-api) |
| 48 | - [Reporting bugs](https://g-issues.chromium.org/issues/new?component=1583624&priority=P2&type=feature_request&template=0&noWizard=true) |
| 49 | - [API Feedback](https://github.com/explainers-by-googlers/prompt-api/issues) |
| 50 | <!-- TODO: link the DevRel doc with more details once it's published --> |