blob: c75eb937d60f69c9a1571a9ba3b84ed82ac75bcf [file] [log] [blame] [view]
Mingyu Lei3caacb172024-11-01 07:18:551# Prompt API for extension
2
Mingyu Lei3caacb172024-11-01 07:18:553This document describes the status of the current implementation of the
Mike Wassermaned1591492025-05-01 04:54:574[**Prompt API**](https://github.com/webmachinelearning/prompt-api) for Chrome
5extensions, and how to verify.
Mingyu Lei3caacb172024-11-01 07:18:556
7## What’s supported
8
Mike Wassermaned1591492025-05-01 04:54:579The implementation generally intends to follow the
10[explainer](https://github.com/explainers-by-googlers/prompt-api).
Mingyu Lei3caacb172024-11-01 07:18:5511
12## Activation
13
14The API can be enabled by participating in the
Mike Wassermaned1591492025-05-01 04:54:5715[extension origin trial](https://developer.chrome.com/blog/prompt-api-origin-trial)
Mingyu Lei3caacb172024-11-01 07:18:5516named `AIPromptAPIForExtension`. After obtaining the trial token, the
17extension authors need to configure it in the `manifest.json` together with
18the `aiLanguageModelOriginTrial` permission.
19
20```json
21{
22 "permissions": ["aiLanguageModelOriginTrial"],
23 "trial_tokens": [<GENERATED_TOKEN>],
24}
Mingyu Lei3caacb172024-11-01 07:18:5525```
26
27## Verifying the API is working
28
Mike Wassermaned1591492025-05-01 04:54:5729The extension authors can verify if the API is available by checking for the
30presence of `LanguageModel` or `chrome.aiOriginTrial.languageModel` entrypoints
31from extension window and worker scripts. If the object is defined, the authors
32can follow the [explainer](https://github.com/explainers-by-googlers/prompt-api)
33and [developer docs](https://developer.chrome.com/docs/extensions/ai/prompt-api)
34to check availability and test the APIs usage.
Mingyu Lei3caacb172024-11-01 07:18:5535
36## Related Links
37
Mike Wassermaned1591492025-05-01 04:54:5738- [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)