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.
// probing with the real library…
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:
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:
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#
- Group by output, not by task. Six verbs cover every task. New model families plug into an existing verb instead of adding API.
- 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.
- Await or stream, same call. There are no
streamXtwins. Iterate the Run to stream it. - Honest about devices. Edgewise picks WebGPU, then WebAssembly or CPU, tells you which one ran, and never hides a fallback.
- Pinned, verified models. Every model is pinned to an exact revision. Files that Edgewise hosts itself are checked against a SHA-256 hash.
- Tested for real. A model is
stableonly when real-model tests pass on Bun, Node and Chromium. See the model list.