Browser AI Kit documentation

Build the local AI feature
users expect.

Start with a complete interface or compose your own. The same typed lifecycle handles readiness, downloads, streaming, long input, context, cancellation, and cleanup.

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.

TSAvailable

TypeScript core

Tree-shakeable browser lifecycle and WebMCP controllers.

Terminal
npm install @desource/browser-ai
Package guide →
VAvailable

Vue

Components and composables for Vue 3.4.33 or newer.

Terminal
npm install @desource/browser-ai-vue
Package guide →
NAvailable

Nuxt

Auto-imports, client components, and SSR-safe defaults.

Terminal
npm install @desource/browser-ai-nuxt
Package guide →
RAvailable

React

Hooks and accessible components for React 18.3 and 19.

Terminal
npm install @desource/browser-ai-react
Package guide →
SAvailable

Svelte

Readable controllers and components for Svelte 5.

Terminal
npm install @desource/browser-ai-svelte
Package guide →
AAvailable

Angular

Signals, services, and standalone components for Angular 22.1.7+.

Terminal
npm install @desource/browser-ai-angular
Package guide →
One browser runtime; native framework ergonomics. The 11 public components and eight headless APIs are checked for parity across Vue, React, Svelte, and Angular. Shared contract tests keep markup and behavior aligned without proxying browser-owned model objects. Read the framework contract →

Vue 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.

PromptExperience.vue
<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.

LocalPrompt.vue
<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.

nuxt.config.ts
export default defineNuxtConfig({
  modules: ["@desource/browser-ai-nuxt"],
  browserAi: {
    css: true,
    component: true,
    helpers: true,
  },
});
OptionDefaultPurpose
csstrueInclude the component stylesheet
componenttrueRegister client components
helperstrueAuto-import helpers and types

Every 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.

React
import { PromptApi } from "@desource/browser-ai-react";
import "@desource/browser-ai-react/assets/lib.css";

export function Assistant() {
  return <PromptApi allowAttachments />;
}
Svelte
<script lang="ts">
  import { PromptApi } from "@desource/browser-ai-svelte";
  import "@desource/browser-ai-svelte/assets/lib.css";
</script>

<PromptApi allowAttachments />
Angular
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 {}
TypeScript core
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.

available

Enable the action and prepare a session.

downloadable

Explain the local download and wait for a user action.

downloading

Show progress and keep the page active.

unavailable

Keep 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.

Summarizer example
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.

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.

CartTools.vue
<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

HTTP response
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 interfaceBrowser AI KitChrome model

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 →