edgewise v0.4.1

edgewise · on-device AI for TypeScript

Six verbs. Real models. On the device.

Edgewise runs language, vision, speech, judging, embedding, image and forecasting models where your code runs: in the browser tab through WebGPU or WebAssembly, and in Bun or Node through ONNX Runtime, with vgpu for WebGPU on the server. You learn six functions, grouped by what they produce.

Quickstart
$bun add edgewise
await capabilities()your browser
// probing with the real library…
This runs Edgewise's own capabilities() in your browser. Edgewise makes the same check before it downloads anything.

One verb per kind of output#

A vision-language model is a language model that also accepts images. A speech recognizer turns audio into text. So both use generate. Edgewise has one verb for each kind of output, and every model declares which inputs it accepts.

Verbs compose#

Every streaming verb returns a Run: await it for the result, or iterate it as a stream. A running generate can go straight into speak. This is a complete local voice assistant for the browser:

assistant.tsts
import { generate, mic, speak } from 'edgewise';

const microphone = await mic({ vad: true });
for await (const heard of microphone.utterances()) {
  const { text } = await generate({ model: 'stt:realtime', input: heard });   // audio → text
  const reply = generate({ model: 'text:default', input: text });                // text → text, streaming
  await speak({ model: 'voice:default', input: reply }).play();               // text stream → audio
}

The same code in Bun, Node and the browser#

Edgewise is one isomorphic TypeScript package. The browser build uses Transformers.js and ONNX Runtime Web (WebGPU, then WebAssembly). The server build uses ONNX Runtime for Node, and probes for a GPU with vgpu. Every result says which one ran:

ts
const { text, info } = await generate({ model: 'lfm2.5-350m', input: 'Hello!' });
info; // { model: 'lfm2.5-350m', device: 'webgpu', dtype: 'q4f16', backend: 'onnxruntime-web:webgpu' }

See Runtimes and GPUs for what runs where.

Design principles#

  1. Group by output, not by task. Six verbs cover every task. New model families plug into an existing verb instead of adding API.
  2. Inputs are message parts. Text, image, audio and video parts work the same everywhere. A model's manifest lists which ones it accepts, and a wrong input fails before any download.
  3. Await or stream, same call. There are no streamX twins. Iterate the Run to stream it.
  4. Honest about devices. Edgewise picks WebGPU, then WebAssembly or CPU, tells you which one ran, and never hides a fallback.
  5. Pinned, verified models. Every model is pinned to an exact revision. Files that Edgewise hosts itself are checked against a SHA-256 hash.
  6. Tested for real. A model is stable only when real-model tests pass on Bun, Node and Chromium. See the model list.

Edgewise 0.4.1 · MIT licence · Edit this page