Skip to content

Why web-ai-sdk

web-ai-sdk wraps browser-native AI APIs and WebMCP. It does not connect to hosted model providers.

Provider SDKs connect applications to hosted models. They often support several providers and frameworks through a server.

Use a provider SDK when your application calls a hosted model with an API key. Use web-ai-sdk for supported browser APIs.

Prompt uses the general LanguageModel API. The other browser APIs use different inputs and return different results.

  • Translator takes a source and target language and caches a session per language pair.
  • Summarizer is shaped by type (key-points, TL;DR, headlines) and length.
  • Writer is parameterized by tone, format, and length.
  • Rewriter applies relative shifts (shorter, longer, more formal) to existing text.
  • Proofreader returns per-issue corrections with offsets into the original input.
  • Detector returns a confidence-scored, sorted list of language alternates.
  • WebMCP (document.modelContext) is an agent surface, not a model surface. Tools call into the page, and it does not generate text.

For this reason, the SDK uses one package per capability.

The SDK handles lifecycle code for each native API:

  • feature detection and availability checks;
  • session creation, reuse, and cleanup;
  • stream normalization and AbortSignal wiring;
  • opt-in result caching.

See Architecture for package boundaries. See Browser support for current availability.