Prompt API Unavailability: Seeking Guidance on Proper Setup

194 views
Skip to first unread message

Nikul Ram

unread,
Nov 29, 2024, 3:24:45 AM11/29/24
to Chrome Built-in AI Early Preview Program Discussions

Hello,

I’m working on integrating the Prompt API in my Chrome Extension. Despite following the documentation and registering the appropriate origin trial tokens, I receive the error:
  "Prompt API is unavailable. Ensure tokens and permissions are correct."
Here is what i did so far:
1) Registered and added the correct trial_tokens in the manifest.json   
2) Included the aiLanguageModelOriginTrial permission in the manifest.
3) Verified my Chrome version is 131+
4) Enabled the required Chrome flags (#optimization-guide-on-device-model).  
5)Checked the API status using chrome.ai.languageModel.capabilities().
So, API remains unavailable, and the available field consistently indicates the model is inaccessible.
Is there any steps I missed any requirements for the environment that prevents the model from being initialized ?

manifest:
{
  "manifest_version": 3,
  "name": "XYZ",
  "version": "1.0",
  "permissions": [
    "activeTab",
    "scripting",
    "storage",
    "aiLanguageModelOriginTrial"
  ],
  "background": { "service_worker": "background.js" },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["content.js"]
    }
  ],
  "action": {
    "default_popup": "popup.html"
  },
  "trial_tokens": [
    "token_1_summarizer",
    "token_2_prompt",
    "token_3_languageDetector",
    "token_4_translator"

  ]
}

Thomas Steiner

unread,
Nov 29, 2024, 3:30:05 AM11/29/24
to Nikul Ram, Chrome Built-in AI Early Preview Program Discussions
Hi Nikul,

Here's an example of how to call the API in an extension. Also note that as per the API status page, the language detector API is currently broken in extensions. Hope this helps you unlock yourself.

Cheers,
Tom

--
You received this message because you are subscribed to the Google Groups "Chrome Built-in AI Early Preview Program Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chrome-ai-dev-previe...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/chrome-ai-dev-preview-discuss/38b248a9-0eb4-4b21-a61d-6a372e8b781fn%40chromium.org.


--
Thomas Steiner, PhD—Developer Relations Engineer (blog.tomayac.comtoot.cafe/@tomayac)

Google Germany GmbH, ABC-Str. 19, 20354 Hamburg, Germany
Geschäftsführer: Paul Manicle, Liana Sebastian
Registergericht und -nummer: Hamburg, HRB 86891

----- BEGIN PGP SIGNATURE -----
Version: GnuPG v2.4.3 (GNU/Linux)

iFy0uwAntT0bE3xtRa5AfeCheCkthAtTh3reSabiGbl0ck
0fjumBl3DCharaCTersAttH3b0ttom.xKcd.cOm/1181.
----- END PGP SIGNATURE -----

Nikul Ram

unread,
Nov 29, 2024, 4:04:54 AM11/29/24
to Chrome Built-in AI Early Preview Program Discussions, Thomas Steiner, Chrome Built-in AI Early Preview Program Discussions, Nikul Ram
Hello I did follow but I am a bit confused I am getting same error :
  "Prompt API is unavailable. Verify tokens and permissions in the manifest."  

part of manifest :
{
  "manifest_version": 3,
  "name": "Learning Tools",

  "version": "1.0",
  "permissions": [
    "activeTab",
    "scripting",
    "storage",
    "aiLanguageModelOriginTrial"
  ],
  "background": { "service_worker": "background.js" },
  "trial_tokens": [
    "VALID_PROMPT_API_TOKEN",
    "VALID_SUMMARIZATION_API_TOKEN",
    "VALID_TRANSLATOR_API_TOKEN"
  ]
}


My  background.js has :

if (!chrome.ai || !chrome.ai.languageModel) {
  console.error("Prompt API is unavailable. Verify tokens and permissions.");
}

I dont know what I am doing wrong.

And thank you for your assistance,
Nikul

Thomas Steiner

unread,
Nov 29, 2024, 4:31:25 AM11/29/24
to Nikul Ram, Chrome Built-in AI Early Preview Program Discussions, Thomas Steiner
Did you click my link? It was right there.
Reply all
Reply to author
Forward
0 new messages