BROWSER-NATIVE AI · 0 RUNTIME DEPS · Open Source

web-ai-sdk

The TypeScript SDK for the Web AI surface.

purpose

Why use a wrapper?

You can use the browser APIs directly.

web-ai-sdk handles capability checks, session reuse, stream normalization, abort signals, cleanup, and optional result caching.

See package boundaries
coverage

Why one package per capability.

Prompt.

Prompt wraps the general LanguageModel API.

  • Prompt / LanguageModel only
  • Text, tools, structured output

Other capabilities.

The other APIs use different options and result types. Each has its own package.

  • Translator (source + target language, pair-cached sessions)
  • Summarizer (type and length)
  • Writer (tone, format, length)
  • Rewriter (relative tone/length shifts)
  • Proofreader (per-issue offsets)
  • Detector (confidence scores, alternates)
  • WebMCP (an agent surface, not a model)
capability matrix

Lifecycle features by package.

Each package implements only the lifecycle features supported by its browser API.

PackageStreamingSession reuseResult cacheAbortSignal
@web-ai-sdk/prompt
@web-ai-sdk/webmcp
@web-ai-sdk/summarizer
@web-ai-sdk/translator
@web-ai-sdk/detector
@web-ai-sdk/writer
@web-ai-sdk/rewriter
@web-ai-sdk/proofreader
Streaming = AsyncIterable output. Session reuse = sessions cached by config so repeat calls skip model setup (conversation turns, language pairs, task options). Result cache = opt-in memoized results. AbortSignal = cleanup wiring on unmount and abort.
SDK catalog

Packages.

@web-ai-sdk/prompt
Send prompts and manage independent sessions, streams, and abort signals.
  • Session reuse. Compatible calls reuse a cached base session.
  • Streaming first. Sessions yield deltas. ask() exposes cumulative text.
  • Clean lifecycle. Abort signals cancel runs. Leases release prepared sessions.
web-ai-sdk Prompt API docs
ask() · streamingsession: on-demand · balanced
Output will stream here…
statusidletok0ms0tok/s0
runtime: browser-provided model
support

Browser support.

Support differs by capability and browser. Each status links to a vendor source. The wrappers expose an unavailable state for fallback UI.

PackageChromeEdgeSafari / Firefox
@web-ai-sdk/prompt148+ stable138+ Canary/Dev flag; OT 150no-op fallback
@web-ai-sdk/summarizer138+ stable138+ stableno-op fallback
@web-ai-sdk/translator138+ stable148+ stableno-op fallback
@web-ai-sdk/detector138+ stable148+ stableno-op fallback
@web-ai-sdk/writerDeveloper trial, local flag138+ Canary/Dev flagno-op fallback
@web-ai-sdk/rewriterDeveloper trial, local flag138+ Canary/Dev flagno-op fallback
@web-ai-sdk/proofreaderDeveloper trial, local flag142+ Canary/Dev flagno-op fallback
@web-ai-sdk/webmcpOT 149+, local flagOT 150no-op fallback
Each status links to its vendor source. stable = documented as on by default; Canary/Dev = Edge preview channel with the documented flag; Developer trial = Chrome's current status label, not an active public token program; OT = origin trial. Historical Writer/Rewriter (137–148) and Proofreader (141–145) Chrome origin-trial windows have ended.
Agent consumer signal, not browser support. ChatGPT Desktop Site tools are an implemented WebMCP consumer in the built-in browser only. Availability depends on the account, model, current page, and user permission. Tools do not carry after navigation. Closing the page makes them unavailable. This does not establish Chrome support or follow from engine lineage.
how it works

Compare three API levels.

Each tab detects an article's language and creates a key-point summary. Compare the raw API, vanilla SDK, and React code.

// summarize.ts
import { detect } from "@web-ai-sdk/detector"
import { summarize } from "@web-ai-sdk/summarizer"
const article = document.querySelector("article")
const text = article?.innerText ?? ""
const detection = await detect({ input: text })
const { output: summary } = await summarize({
input: text,
language: detection.output?.language ?? "en",
type: "key-points", length: "short",
onUpdate: render,
})
scope

Responsibilities.

SDK responsibilities.

The SDK handles browser API lifecycles. This includes support checks, sessions, streams, abort signals, and cleanup.

  • Feature detection per package
  • Session cache keyed by config
  • AsyncIterable streams plus AbortSignal cleanup
  • Hot-reload and StrictMode safe
  • Zero-runtime fallback when API missing

Application responsibilities.

Application code owns UI, persistence, DOM traversal, fallbacks, and cross-capability workflows.

  • Framework-agnostic core
  • Optional /react subpath
  • No global state, no providers required
  • Tree-shakable per package
  • Pick the layers you need
ArchitectureOwner
Browser Web AI
document.modelContext, Summarizer, Translator, LanguageModel, LanguageDetector, Writer, Rewriter, Proofreader
platform
@web-ai-sdk/X
ask(), createSession(), summarize(), translate(), detect(), write(), rewrite(), proofread(), registerTool(), AbortSignal, session cache
web-ai-sdk
@web-ai-sdk/X/react
usePrompt(), useSession(), useSummarizer(), useTranslator(), useDetector(), useWriter(), useRewriter(), useProofreader(), useWebMCP()
web-ai-sdk
Your application
Card, Button, Spinner, the design system
your code