Overview
Chrome runs the models.
You build the experience.
Browser AI Kit brings private, on-device AI to Vue, React, Svelte, Angular, Nuxt, and TypeScript. Chrome processes prompts locally, without an inference server or API key. The kit adds download progress, streaming, stop controls, saved chats, and session cleanup.
Use Chrome on HTTPS or localhost. Each API has its own device and language requirements, and first use may need a model download. The examples check availability in your browser.
On-device by design
Prompts are processed locally. No inference server, API key, or per-request fee from the kit.
Ready for your interface
Show download progress, stream answers, and stop a request with state that fits your framework.
Make it your own
Use a complete component, theme its styles, or connect the APIs to your own design.
Installation
Install your framework package.
Choose one package for your app. Vue, React, Svelte, and Angular include components and APIs for a custom UI. Nuxt sets up the Vue integration for you. Use the TypeScript core when you do not need a UI framework.
TypeScript core
Local AI and WebMCP controllers without a UI framework.
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 stores 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
Add a complete chat interface.
Import the stylesheet once, then render a component. The Prompt API interface includes saved chats, streaming Markdown, attachments supported by Chrome, stop controls, download progress, 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>Build a custom interface
Composables give your own UI reactive availability, progress, results, and errors. Call the model from a button handler; the composable releases its sessions when the component unmounts.
<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
Add the module. Use the components.
The module registers components on the client, includes their styles, and auto-imports composables, helpers, and types. Model operations stay in the browser while the rest of your app can render on the server.
export default defineNuxtConfig({
modules: ["@desource/browser-ai-nuxt"],
browserAi: {
css: true,
component: true,
helpers: true,
},
});<template>
<PromptApi />
</template>csstrueInclude the component stylesheetcomponenttrueRegister client componentshelperstrueAuto-import helpers and typesEvery framework package
Use your framework's state and lifecycle.
Start with the same chat component in React, Svelte, or Angular. For a custom UI, use React hooks, Svelte stores, or Angular signals and services. The core controller works in plain TypeScript.
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";
import "@desource/browser-ai-angular/assets/lib.css";
@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
Prepare the browser for its first request.
Chrome may need to download a model or language pack before it can answer. Components handle the states below. In a custom interface, check availability with the languages and options your feature will use.
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.
If an API is unavailable, check its Chrome requirements, supported languages, and any local testing flags. Browser setup and troubleshooting →
Work with long text.
The text components and optional workflows handle input that exceeds one model request. Summarizer combines summaries from measured chunks, Translator keeps translated chunks in order, and Proofreader maps corrections back to the original text. You can show progress and stop long work.
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.
The AI examples run real models on your device. They show an unavailable state when an API cannot run and never switch to a hosted model.
WebMCP
Expose application tools to browser agents.
Let compatible browser agents use actions your app already offers: search a catalog, read a cart total, or submit a form. Register a typed tool or annotate an existing HTML form. Its result updates the same state your users see.
<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
AI processing stays on the device.
Chrome's built-in models process prompts and generate responses locally. Browser AI Kit does not send that content or telemetry to DeSource Labs. Chrome manages model downloads and updates; once the resources are installed, model processing can work offline.
Saved chat text stays in the browser's IndexedDB. Image and audio attachments stay in memory for the current conversation controller and need to be reattached after a reload.
WebMCP connects agents to your application tools; the agent and tool code determine where tool data goes. If your app offers a cloud model when local AI is unavailable, explain that prompts will leave the device and let the user choose it. The kit does not provide an automatic cloud fallback.
Frequently asked questions
Before you ship.
Where are my prompts processed?
On your device, using Chrome's built-in AI models. The kit does not send prompts to a cloud model or require an API key. WebMCP agents and tools have their own data flows, separate from local model processing.
Does Browser AI Kit work in every browser?
It uses Chrome's built-in AI APIs, and availability varies by API, device, language, and browser configuration. The live examples show what your browser supports. Keep essential tasks usable when local AI is unavailable.
Does it cost anything per request?
The kit is MIT licensed and has no per-request fee. Models run on the user's device, so there is no inference service to pay for or API key to manage. Your app's hosting and any cloud services you add have their own costs.
Will it work offline?
Model processing can work offline once the required model or language pack is installed. Your app must also be available offline. Downloads and updates need a connection, and Chrome may remove unused resources or reclaim storage.
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.
How should I handle an unavailable API?
Keep the manual workflow usable, explain the current requirements, and let the user retry. Check availability with the exact languages and model options your feature needs.
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
Try your first local response.
Open an example to check support, prepare any required model, and try chat, writing, or translation on your own device.
Open interactive examples →