Menu

Building with the Web Models API
📰

Building with the Web Models API

DEV Community: javascript·Chris McKenzie·1 day ago
#Sql3yjqN
#devtojavascript#devto#dev#summarize#summary
Reading 0:00
15s threshold

Web Models API: Practical Guide

In the last article , I focused on why I think an API that exposes open-weight, on-device models to web apps is desperately needed, and why the Web Models API could be a good solution.

In this article, I want to get down to brass tacks and show what the code would look like. I'll focus on the developer's side. I'll write more about how the browser implementation works in a future article.

These examples follow the current proposal. The API is still being developed and may change.

The API

Before getting into the examples, here's the API at a glance:

// Request access to a model. navigator . models . requestAccess ( model ) ;

// Generate text, stream a response, or create embeddings. navigator . models . generate ( model , input ) ; navigator . models . stream ( model , input ) ; navigator . models . embed ( model , input ) ;

// Bind a model for repeated calls. navigator . models . session ( model ) ;

// Read model details after access has been granted. navigator .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.