Overview
Chrome provides the model.
The kit provides the product layer.
Browser AI Kit wraps Chrome's built-in AI APIs in framework-native state and optional interfaces. It does not proxy prompts through a server or flatten every capability into one generic abstraction. Prompt, Summarizer, Writer, Rewriter, Translator, Language Detector, Proofreader, and WebMCP keep their distinct strengths.
The library is production-oriented; the browser APIs are still evolving. Always keep an unsupported state and a non-AI path for essential work.
On-device by design
No package-owned inference endpoint, credentials, or usage meter.
Fast framework state
Native sessions stay outside deep reactive proxies and are reused across compatible requests.
Composable by default
Use the interface, the headless state, or direct native-shaped operations.
Installation
Choose the framework boundary.
Six packages expose one runtime behavior contract. Each adapter maps it to native framework lifecycle and state primitives; Nuxt adds client-safe auto-imports around Vue.
TypeScript core
Tree-shakeable browser lifecycle and WebMCP controllers.
npm install @desource/browser-aiVue
Components and composables for Vue 3.4.33 or newer.
npm install @desource/browser-ai-vueNuxt
Auto-imports, client components, and SSR-safe defaults.
npm install @desource/browser-ai-nuxtReact
Hooks and accessible components for React 18.3 and 19.
npm install @desource/browser-ai-reactSvelte
Readable controllers and components for Svelte 5.
npm install @desource/browser-ai-svelteAngular
Signals, services, and standalone components for Angular 22.1.7+.
npm install @desource/browser-ai-angularVue quick start
Use the full interface.
Import the stylesheet once, then render a component. The Prompt API interface includes saved chats, streaming, attachments supported by Chrome, stop controls, download UX, and context recovery.
<script setup lang="ts">
import { PromptApi } from "@desource/browser-ai-vue";
import "@desource/browser-ai-vue/assets/lib.css";
</script>
<template>
<PromptApi
context-strategy="summarize"
context-summary-mode="cache-first"
/>
</template>Or own every pixel.
Composables expose reactive state and direct operations. A native session lives in a shallow ref, avoiding expensive traversal while the rest of your UI updates.
<script setup lang="ts">
import { ref } from "vue";
import { usePromptApi } from "@desource/browser-ai-vue";
const ai = usePromptApi(); // Disposed with this component's effect scope.
const answer = ref("");
async function ask() {
await ai.init({
expectedInputs: [{ type: "text", languages: ["en"] }],
expectedOutputs: [{ type: "text", languages: ["en"] }],
});
await ai.create(); // User action permits a required model download.
answer.value = await ai.prompt("Explain local AI.");
}
</script>
<template>
<button @click="ask">Explain local AI</button>
<p>{{ answer }}</p>
</template>Nuxt quick start
One module, no browser globals on the server.
Components are registered in client mode. Composables, helpers, language options, and public types are auto-imported.
export default defineNuxtConfig({
modules: ["@desource/browser-ai-nuxt"],
browserAi: {
css: true,
component: true,
helpers: true,
},
});csstrueInclude the component stylesheetcomponenttrueRegister client componentshelperstrueAuto-import helpers and typesEvery framework package
Keep the browser behavior. Choose the state model.
React uses hooks backed by useSyncExternalStore. Svelte exposes readable stores and controller factories. Angular provides signal controllers, standalone components, and BrowserAiService. The core package works in vanilla TypeScript and is the only place browser lifecycle logic is implemented.
import { PromptApi } from "@desource/browser-ai-react";
import "@desource/browser-ai-react/assets/lib.css";
export function Assistant() {
return <PromptApi allowAttachments />;
}<script lang="ts">
import { PromptApi } from "@desource/browser-ai-svelte";
import "@desource/browser-ai-svelte/assets/lib.css";
</script>
<PromptApi allowAttachments />import { Component } from "@angular/core";
import { BrowserAiPromptApiComponent } from "@desource/browser-ai-angular";
@Component({
selector: "app-assistant",
standalone: true,
imports: [BrowserAiPromptApiComponent],
template: '<browser-ai-prompt-api />',
})
export class AssistantComponent {}import { createPromptApi } from "@desource/browser-ai";
// Call from a button handler when a model download may be needed.
async function ask() {
const prompt = createPromptApi();
try {
return await prompt.prompt("Explain local AI in one sentence.");
} finally {
prompt.dispose();
}
}Browser lifecycle
Availability is part of the interface.
Chrome decides whether a capability is ready, needs local resources, is already downloading, or is unavailable on the current profile. Check again when the feature starts; model state can change.
availableEnable the action and prepare a session.
downloadableExplain the local download and wait for a user action.
downloadingShow progress and keep the page active.
unavailableKeep the essential workflow usable without AI.
When an API is downloadable, call create() from a genuine click or keyboard action. Programmatic clicks and page-load effects do not satisfy Chrome's activation requirement.
Long work stays measurable and cancellable.
Specialized composables measure the browser's real quota and apply a strategy that fits the task: recursive summary rollups, ordered translation chunks, optional-context fitting, confidence merging, or normalized proofreader ranges.
const summarizer = useSummarizer();
const result = await summarizer.summarizeWithDetails(article, {
createOptions: {
type: "key-points",
format: "markdown",
length: "medium",
},
context: "Focus on decisions, owners, and unresolved risks.",
});API directory
Start from the outcome you need.
Prompt API
Stream private chats, return schema-constrained JSON, and keep long sessions useful.
Summarizer
Turn long content into summaries, key points, headlines, or teasers on-device.
Writer
Draft text in the tone, format, and length your interface needs.
Rewriter
Make existing text clearer, shorter, longer, or more formal without a server.
Translator
Translate supported language pairs with Chrome-managed local packs.
Language Detector
Rank likely languages with confidence scores and long-text merging.
Proofreader
Correct grammar, spelling, and punctuation with inspectable edit ranges.
WebMCP
Publish lifecycle-safe app tools for compatible browser agents to discover and call.
Every example calls the native API in this browser profile. No demo response is mocked and no hosted model is used as a fallback.
WebMCP
Make your application legible to browser agents.
Register imperative tools, annotate existing forms, discover tools, execute them manually during development, and observe lifecycle changes through one composable.
<script setup lang="ts">
import { onMounted } from "vue";
import { useWebMcp } from "@desource/browser-ai-vue";
const props = defineProps<{ total: number; currency: string }>();
const webMcp = useWebMcp(); // Unregisters tools with the component scope.
onMounted(async () => {
await webMcp.registerTool({
name: "get_cart_total",
description: "Return the displayed cart total without changing it.",
inputSchema: { type: "object", properties: {}, additionalProperties: false },
annotations: { readOnlyHint: true },
execute: async () => ({ total: props.total, currency: props.currency }),
});
});
</script> Schemas guide the caller; they do not authorize it. Validate every input and re-check authentication and authorization inside execute.
Production headers
Origin-Agent-Cluster: ?1
Permissions-Policy: tools=(self)WebMCP is experimental and currently requires Chrome's testing flag or origin-trial availability. Read the complete security and deployment guide →
Privacy and fallback
Be precise about where data goes.
Browser AI Kit does not send prompts, outputs, or telemetry to DeSource Labs. Built-in model execution remains inside Chrome, which owns the model files and resource lifecycle.
Your own application code, extensions, monitoring software, and WebMCP tools can still transmit information. Audit those paths and never put secrets in client-side prompts or tool descriptions.
If local AI is unavailable, keep the manual workflow, explain how to retry, or offer a hosted model only after disclosing that content will leave the device. Do not silently cross that privacy boundary.
Frequently asked questions
Before you ship.
Does Browser AI Kit work in every browser?
No. It intentionally targets Chrome's built-in AI surfaces. Support also varies by Chrome version, platform, device, region, language, profile policy, and model state.
Does it cost anything per request?
The kit has no request fee and uses no DeSource Labs inference service. Local inference still consumes the user's device resources, and your own hosting or optional cloud fallback may have costs.
Will it work offline?
A ready local model can run without an inference network request, but Chrome may need network access to install or update the model or a language pack. Chrome can also remove resources under storage pressure.
Can I replace the provided interface?
Yes. Components are optional. Every capability has a Vue composable, React hook, Svelte controller, Angular signal controller or service method, and a framework-neutral core factory.
Is it production-ready if Chrome's APIs are experimental?
The library handles production concerns and is tested against the documented and verified runtime surface. Your product must still feature-detect, present an unsupported state, and accept that browser behavior can evolve.
Is the native browser API a better choice?
For a small one-off call, it can be. The kit is valuable when download UX, streaming, long inputs, persisted context, cancellation, SSR, cleanup, or several APIs would otherwise be rebuilt in your application.
Next step
Run the real API.
The example directory detects capabilities in this Chrome profile and lets you test every available surface.
Open interactive examples →