https://github.com/jakobhoeg/built-in-ai
https://github.com/jakobhoeg/built-in-ai
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jakobhoeg/built-in-ai
- Owner: jakobhoeg
- License: mit
- Created: 2025-07-14T21:04:10.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-07-15T19:04:32.000Z (3 months ago)
- Last Synced: 2025-07-16T10:55:03.280Z (3 months ago)
- Language: TypeScript
- Homepage: https://built-in-ai-provider-next-hybrid.vercel.app
- Size: 485 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Built-in AI provider for Vercel AI SDK
![]()
[](https://www.npmjs.com/package/@built-in-ai/core)
[](https://www.npmjs.com/package/@built-in-ai/core)A TypeScript library that provides access to browser-based AI capabilities with seamless fallback to using server-side models using the [Vercel AI SDK](https://ai-sdk.dev/). This library enables you to leverage **Chrome** and **Edge's** built-in AI features ([Prompt API](https://github.com/webmachinelearning/prompt-api)) with the AI SDK.
> We will also aim to add other providers such as [web-llm](https://github.com/mlc-ai/web-llm) and [transformers.js](https://huggingface.co/docs/transformers.js/en/index)
Vercel AI SDK v5 introduces [custom Transport support](https://v5.ai-sdk.dev/docs/announcing-ai-sdk-5-beta#enhanced-usechat-architecture) for the `useChat()` hook, which has been the _missing piece_ needed to fully integrate browser-based Prompt API capabilities with the Vercel AI SDK.
> [!IMPORTANT]
> This package is under constant development as the Prompt API matures, and may contain errors and incompatible changes.## Installation
> [!NOTE]
> This only works with the new v5 of the Vercel AI SDK.```bash
npm i @built-in-ai/core
```The `@built-in-ai/core` package is the AI SDK provider for your Chrome and Edge browser's built-in AI models.
## Browser Requirements
> [!IMPORTANT]
> The Prompt API is currently experimental and might change as it matures. The below enablement guide of the API might also change in the future.1. You need Chrome (v. 128 or higher) or Edge Dev/Canary (v. 138.0.3309.2 or higher)
2. Enable these experimental flags:
- If you're using Chrome:
1. Go to chrome://flags/#prompt-api-for-gemini-nano and set it to Enabled
2. Go to chrome://flags/#optimization-guide-on-device-model and set it to Enabled BypassPrefRequirement
3. Go to chrome://components and click Check for Update on Optimization Guide On Device Model
- If you're using Edge:
1. Go to edge://flags/#prompt-api-for-phi-mini and set it to EnabledFor more information, check out [this guide](https://developer.chrome.com/docs/extensions/ai/prompt-api)
## Basic usage
```typescript
import { streamText } from "ai";
import { builtInAI } from "@built-in-ai/core";const result = streamText({
model: builtInAI(),
messages: [{ role: "user", content: "Hello, how are you?" }],
});for await (const chunk of result.textStream) {
console.log(chunk);
}
```Look [here](/packages/built-in-ai/README.md) for more usage examples and API reference.
## Features
### Supported
- [x] **Text generation** (`generateText()`)
- [x] **Streaming responses** (`streamText()`)
- [x] **Multimodal functionality** (image and audio support)\*
- [x] **Temperature control**
- [x] **Response format constraints** (JSON)
- [x] **Abort signals**### Planned (when implemented in the Prompt API)
- [ ] **Tool calling**
- [ ] **Token counting**
- [ ] **Custom stop sequences**
- [ ] **Presence/frequency penalties**> \*Multimodal functionality is currently only available in Chrome's Prompt API implementation
## Contributing
Contributions are more than welcome!
## Why This Package?
While there is an [existing package](https://github.com/jeasonstudio/chrome-ai) that attempted to provide similar functionality, it has been inactive for the past year with no maintenance or updates. We're grateful for their initial exploration and the foundation they provided for the community.
This package was created to provide a reliable, actively maintained solution for integrating browser-based AI capabilities with modern web applications, ensuring ongoing support and compatibility with the latest browser AI features.