Chrome API Compatible Version
Drag this button to your bookmarks bar
This version uses the Chrome Prompt API style. The entire logic is just 4 lines:
// Create session using Chrome's languageModel API const session = await window.ai.languageModel.create({ systemPrompt: 'Summarize clearly in 2-3 paragraphs.' }); // Prompt with page content const summary = await session.prompt(document.body.innerText); // That's it! Permissions are auto-requested.
No explicit permission request needed! Web Agent API implementations automatically show the permission dialog when languageModel.create() is called.
The Web Agent API supports both Chrome's API and its own extended API:
await ai.languageModel.capabilities()await ai.languageModel.create(options)await session.prompt(text)session.promptStreaming(text)await session.clone()await session.destroy()