{"id":49994925,"url":"https://github.com/obetomuniz/web-ai-sdk","last_synced_at":"2026-06-13T05:01:25.424Z","repository":{"id":358797593,"uuid":"1238113494","full_name":"obetomuniz/web-ai-sdk","owner":"obetomuniz","description":"Building blocks for the Web's Built-in AI APIs. Composable. No runtime deps. Just lifecycle, streaming, and AbortSignals.","archived":false,"fork":false,"pushed_at":"2026-06-07T19:05:21.000Z","size":956,"stargazers_count":17,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-07T20:12:15.368Z","etag":null,"topics":["built-in-ai","language-detection","language-model","on-device-ai","prompt-api","proofreader-api","react","rewriter-api","summarizer-api","translator-api","typescript","web-ai","webmcp","writer-api"],"latest_commit_sha":null,"homepage":"https://web-ai-sdk.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/obetomuniz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-05-13T20:32:56.000Z","updated_at":"2026-06-07T18:47:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"01e98a22-81e3-4535-b61b-99b3e2b732f8","html_url":"https://github.com/obetomuniz/web-ai-sdk","commit_stats":null,"previous_names":["obetomuniz/web-ai-sdk"],"tags_count":80,"template":false,"template_full_name":null,"purl":"pkg:github/obetomuniz/web-ai-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obetomuniz%2Fweb-ai-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obetomuniz%2Fweb-ai-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obetomuniz%2Fweb-ai-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obetomuniz%2Fweb-ai-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/obetomuniz","download_url":"https://codeload.github.com/obetomuniz/web-ai-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obetomuniz%2Fweb-ai-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34272603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["built-in-ai","language-detection","language-model","on-device-ai","prompt-api","proofreader-api","react","rewriter-api","summarizer-api","translator-api","typescript","web-ai","webmcp","writer-api"],"created_at":"2026-05-19T07:11:31.952Z","updated_at":"2026-06-13T05:01:25.417Z","avatar_url":"https://github.com/obetomuniz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# web-ai-sdk\n\n**web-ai-sdk is a TypeScript SDK for the Web's Built-in AI APIs.**\n\nUse Prompt, Writer, Rewriter, Proofreader, Translator, Summarizer, Language Detector, and WebMCP with a stable, typed, composable interface, instead of wiring up each experimental browser API by hand.\n\n```ts\nimport { ask } from \"@web-ai-sdk/prompt\";\n\nconst { output } = await ask({ input: \"Summarize this page in one sentence.\" });\n```\n\nA small, focused monorepo of framework-agnostic packages that smooth over the gnarly bits of the new `document.modelContext`, `Translator`, `Summarizer`, `LanguageModel`, `LanguageDetector`, `Writer`, `Rewriter`, and `Proofreader` browser APIs (feature detection, session caching, streaming, lifecycle, safe DOM rebuild) without bringing any UI along.\n\n\u003e If you're exploring AI in the browser, a [star on GitHub](https://github.com/obetomuniz/web-ai-sdk) helps others find web-ai-sdk.\n\n## Why this exists\n\nThe Web's Built-in AI APIs are promising but still early and shifting. Every app that touches them re-implements the same lifecycle: feature-detect, wait for model availability, create and reuse sessions, stream chunks, abort cleanly, and fall back when the capability is missing. web-ai-sdk owns that layer so you build against one stable, typed surface rather than coupling your whole app to today's experimental API shape. The wrappers feature-detect and no-op when a browser lacks the API, so the same code ships everywhere.\n\n## What it is\n\n**`web-ai-sdk`** ships one package per browser capability. Zero runtime dependencies. Written in TypeScript. That's it. The SDK tracks a moving browser spec and intentionally stays out of the way of *how* you build an app.\n\nCompositions that bond multiple primitives (block-level DOM translation,\narticle-aware summarization, detect-then-summarize chains) are\ndeliberately out of scope — the SDK wraps one capability per package;\ncomposition is your code.\n\nSee [`apps/site/src/content/docs/architecture.mdx`](./apps/site/src/content/docs/architecture.mdx) (rendered at [`web-ai-sdk.dev/docs/architecture/`](https://web-ai-sdk.dev/docs/architecture/)) for the full model.\n\n| Package                                          | Wraps                                          | Highlights                                                                |\n| ------------------------------------------------ | ---------------------------------------------- | ------------------------------------------------------------------------- |\n| [`@web-ai-sdk/webmcp`](./packages/webmcp)            | `document.modelContext` (W3C WebMCP)           | Safe register/unregister, shorthand annotations, `useWebMCP` hook         |\n| [`@web-ai-sdk/translator`](./packages/translator)    | Web Built-in `Translator`                   | Block serialization, casing restoration, snapshot-based restore           |\n| [`@web-ai-sdk/summarizer`](./packages/summarizer)    | Web Built-in `Summarizer`                   | Skeleton extraction, sessionStorage caching, streaming chunks             |\n| [`@web-ai-sdk/prompt`](./packages/prompt)            | Web Built-in `LanguageModel` (Prompt API)   | System prompt + sampling, session reuse, streaming, result cache          |\n| [`@web-ai-sdk/detector`](./packages/detector)        | Web Built-in `LanguageDetector`             | Confidence thresholds, bias hints, session reuse, `useDetector` hook      |\n| [`@web-ai-sdk/writer`](./packages/writer)            | Web Built-in `Writer`                       | Tone/format/length, session reuse, streaming, `useWriter` hook            |\n| [`@web-ai-sdk/rewriter`](./packages/rewriter)        | Web Built-in `Rewriter`                     | Relative tone/length shifts, streaming, `useRewriter` hook                |\n| [`@web-ai-sdk/proofreader`](./packages/proofreader)  | Web Built-in `Proofreader`                  | Corrected text + per-issue offsets, session reuse, `useProofreader` hook  |\n\nEach package ships:\n\n- **Vanilla** entry (`@web-ai-sdk/\u003cpkg\u003e`): TypeScript / DOM only, zero framework deps.\n- **React** entry (`@web-ai-sdk/\u003cpkg\u003e/react`): small hook adapter wrapping the vanilla core. `react` is an optional peer dep.\n\n## Build for the agentic web\n\nThe browser is becoming both an AI runtime and an agent surface. The Built-in AI wrappers (Prompt, Summarizer, Translator, and friends) cover the runtime half: local model capabilities behind one typed interface. [`@web-ai-sdk/webmcp`](./packages/webmcp) covers the agent half: structured, agent-callable tools your page exposes to visiting agents. Feature detection and no-op fallbacks keep the same code shipping everywhere, so neither half is a hard requirement — see [Browser support](./apps/site/src/content/docs/browser-support.mdx) for what's available where.\n\n## Why composable\n\nBrowsers are shipping built-in AI APIs behind flags. The shape changes; the lifecycle is similar across them: feature-detect, lazily create a session, stream chunks, cache results, clean up. Those concerns are framework-agnostic and worth sharing.\n\n**We ship that lifecycle layer.** Framework adapters, polyfills, UI primitives stay optional subpaths so they don't constrain your design system, framework, or styling stack. Pick the layers you need; skip the rest.\n\nThis is the same shape mature utility libraries converge on as the platform catches up (lodash → native methods, moment/date-fns → `Temporal`): a thin shim over a native primitive that gets *thinner* as the primitive stabilizes. See [Architecture § Lineage](./apps/site/src/content/docs/architecture.mdx) for the full reasoning.\n\n## Install\n\nPick the building blocks you need, or grab the whole suite in one install:\n\n```sh\npnpm add @web-ai-sdk/webmcp        # one block\npnpm add @web-ai-sdk/all           # all eight blocks under one install\n```\n\nEach package has its own README with install + usage:\n\n- [`@web-ai-sdk/all`](./packages/sdk/README.md) (meta-package; re-exports all eight)\n- [`@web-ai-sdk/webmcp`](./packages/webmcp/README.md)\n- [`@web-ai-sdk/translator`](./packages/translator/README.md)\n- [`@web-ai-sdk/summarizer`](./packages/summarizer/README.md)\n- [`@web-ai-sdk/prompt`](./packages/prompt/README.md)\n- [`@web-ai-sdk/detector`](./packages/detector/README.md)\n- [`@web-ai-sdk/writer`](./packages/writer/README.md)\n- [`@web-ai-sdk/rewriter`](./packages/rewriter/README.md)\n- [`@web-ai-sdk/proofreader`](./packages/proofreader/README.md)\n\n## Try it locally\n\nOne workspace app ships under `apps/site`: an Astro marketing site with Starlight docs mounted at `/docs/`.\n\n```sh\ngit clone https://github.com/obetomuniz/web-ai-sdk.git\ncd web-ai-sdk\n\n# Node 24 (or any version-manager that respects .nvmrc) + Corepack picks up\n# pnpm 9.15.0 automatically from package.json's \"packageManager\" field.\npnpm install\npnpm build:packages  # build packages so workspace consumers can resolve them\npnpm dev             # site at http://localhost:5173/, docs at /docs/\n```\n\nFor the AI APIs to actually run, open a supporting browser. On Chrome, Summarizer/Translator/Detector are stable in 138+ and Prompt is stable in 148+ (no flags); the Writing Assistance APIs (Writer, Rewriter, Proofreader) are developer/origin trials behind their own `chrome://flags/` toggles; WebMCP needs `chrome://flags/#enable-webmcp-testing` through Chrome 148 and joins a public origin trial in Chrome 149. On Edge, only Summarizer is in stable (138+ default-on); Prompt, Translator, Detector, and WebMCP are developer previews in Canary/Dev behind their respective `edge://flags/` toggles. On Windows the four Built-in AI APIs (Prompt, Summarizer, Translator, Detector) work reliably once flagged; macOS sees higher refusal rates from the Phi-4-mini safety pipeline for Prompt and Summarizer. WebMCP on Edge remains rough on both platforms. See [Browser support](./apps/site/src/content/docs/browser-support.mdx) for the per-package matrix and exact flag names.\n\n## Repo layout\n\n```\n.\n├── packages/\n│   ├── webmcp/         # @web-ai-sdk/webmcp\n│   ├── translator/     # @web-ai-sdk/translator\n│   ├── summarizer/     # @web-ai-sdk/summarizer\n│   ├── prompt/         # @web-ai-sdk/prompt\n│   ├── detector/       # @web-ai-sdk/detector\n│   ├── writer/         # @web-ai-sdk/writer\n│   ├── rewriter/       # @web-ai-sdk/rewriter\n│   ├── proofreader/    # @web-ai-sdk/proofreader\n│   └── sdk/            # @web-ai-sdk/all (meta-package; re-exports the eight above)\n├── apps/\n│   └── site/           # @web-ai-sdk-apps/site (private; Astro site + Starlight docs)\n├── .agents/agents.md           # agent instructions (AGENTS.md symlink kept at root)\n├── README.md           # ← you are here\n└── …\n```\n\n## Workflow\n\n| Task                            | Command               |\n| ------------------------------- | --------------------- |\n| Watch site + docs               | `pnpm dev`            |\n| Watch wrapper packages          | `pnpm dev:packages`   |\n| Watch meta-package              | `pnpm dev:sdk`        |\n| Boot unified app (`:5173`)      | `pnpm site`           |\n| Build everything                | `pnpm build`          |\n| Build publishable packages only | `pnpm build:packages` |\n| Build app only                  | `pnpm build:apps`     |\n| Typecheck everything            | `pnpm typecheck`      |\n| Run tests                       | `pnpm test`           |\n| Lint + format audit             | `pnpm lint`           |\n| Auto-fix lint + format          | `pnpm lint:fix`       |\n| Full quality gate               | `pnpm gate`           |\n| Build Pages artifact            | `pnpm pages:build`    |\n| Preview combined Pages locally  | `pnpm pages:preview`  |\n\nToolchain: Node 24 (pinned in `.nvmrc`) + pnpm 9.15.0 (pinned via `package.json#packageManager` and provisioned automatically by Corepack on Node 16.13+).\n\n## Roadmap\n\nDirectional, not a commitment. The bias is toward owning only the lifecycle and ergonomics the raw APIs leave rough, and thinning out as the Built-in AI APIs stabilize.\n\n- Native tool calling for the Prompt API\n- Session resilience (auto-retry on session loss)\n- Session context introspection (token / quota usage)\n- IndexedDB cache backend for result caches\n- Cloud / custom-provider fallback for unsupported browsers\n- More browser compatibility helpers\n\n## Contributing\n\nSee [`CONTRIBUTING.md`](./CONTRIBUTING.md) for the human-facing onboarding, and [`.agents/agents.md`](./.agents/agents.md) for the deeper conventions (same rules apply to humans and AI agents).\n\n## License\n\nMIT © Beto Muniz\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobetomuniz%2Fweb-ai-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobetomuniz%2Fweb-ai-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobetomuniz%2Fweb-ai-sdk/lists"}