Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,33 @@ const fullReply = await engine.getMessage();
console.log(fullReply);
```

### Vercel AI SDK

The community-maintained `@browser-ai/web-llm` provider lets browser applications use the AI SDK's `streamText` with a WebLLM model. Install it alongside WebLLM and the AI SDK.

```sh
npm install ai @browser-ai/web-llm @mlc-ai/web-llm
```

This example downloads SmolLM2 on first use and runs it on a WebGPU adapter with `shader-f16`.

```typescript
import { streamText } from "ai";
import { webLLM } from "@browser-ai/web-llm";

const result = streamText({
model: webLLM("SmolLM2-135M-Instruct-q0f16-MLC"),
prompt: "Name one planet.",
maxOutputTokens: 16,
});

for await (const text of result.textStream) {
console.log(text);
}
```

For model initialization and download progress, see the [provider documentation](https://www.browser-ai.dev/docs/ai-sdk-v7/web-llm).

## Advanced Usage

### Using Workers
Expand Down
Loading