blob: af1eafb4dc8cdf055a292d89f982fe86edfb9ae9 [file] [log] [blame] [view]
Mingyu Lei3caacb172024-11-01 07:18:551# Prompt API for extension
2
3- Contact: builtin-ai@chromium.org
4
5This document describes the status of the current implementation of the
6[**Prompt API**](https://github.com/explainers-by-googlers/prompt-api)
7for Chrome extension, and how to verify.
8
9Note that this API is not available by default. Chrome plans to do an
10extension origin trial starting from M131 to evaluate its effectiveness
11and to allow extension authors to give feedback.
12
13
14## What’s supported
15
16The API is implemented according to the
17[explainer](https://github.com/explainers-by-googlers/prompt-api), but the
18API namespace will be under `chrome.aiOriginTrial.languageModel` for the
19extension origin trial.
20
21## Activation
22
23The API can be enabled by participating in the
24[extension origin trial](https://developer.chrome.com/docs/web-platform/origin-trials#extensions)
25named `AIPromptAPIForExtension`. After obtaining the trial token, the
26extension authors need to configure it in the `manifest.json` together with
27the `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
39The extension authors can verify if the API is available by checking the
40`chrome.aiOriginTrial.languageModel` from the service worker script.
41If the `AILanguageModel` object is defined, the authors can follow the
42[explainer](https://github.com/explainers-by-googlers/prompt-api) to test
43the 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 -->