Early Beta — The Web SDK is in early beta. APIs may change between releases.
Overview
This guide covers SDK initialization options, backend registration, model management, events, browser capabilities, and audio utilities.SDK Initialization
Basic Initialization
Full Configuration
Backend Registration
After initializing the core SDK, register the inference backends you need:Environment Modes
Logging
Configure Log Level
Log Levels
Events
EventBus
The SDK provides a typed event system for monitoring SDK activities:Event properties are directly on the event object (e.g.,
evt.modelId, evt.progress), not
nested under evt.data.Event Types
Model Sources
All models in RunAnywhere are sourced from HuggingFace. The SDK provides a model registry that resolves compact model definitions into full download URLs and manages the complete lifecycle: registration -> download -> storage -> loading.How It Works
When you register a model with arepo field, the SDK constructs the download URL automatically:
repo: 'LiquidAI/LFM2-350M-GGUF' with files: ['LFM2-350M-Q4_K_M.gguf'] resolves to:
CompactModelDef
TheregisterModels API accepts an array of compact model definitions:
URL Resolution Rules
Model Management
All model management operations useModelManager from @runanywhere/web.
Register Models
Available Models on HuggingFace
LLM Models
VLM Models
STT / TTS / VAD Models
Download and Load
Multi-Model Loading with coexist
By default, loading a new model unloads any previously loaded model. For the voice pipeline (which needs STT + LLM + TTS + VAD simultaneously), pass coexist: true:
Storage (OPFS)
Downloaded models are persisted in the browser’s Origin Private File System (OPFS). This means:- Models survive page refreshes and browser restarts
- Each origin (domain) has its own isolated storage
- The SDK auto-detects previously downloaded models on page load
- If storage quota is exceeded, the SDK auto-evicts least-recently-used models
Delete Models
Audio Utilities
Audio utilities (
AudioCapture, AudioPlayback) are in @runanywhere/web-onnx, while video
utilities (VideoCapture) are in @runanywhere/web-llamacpp. Don’t mix up the import sources.AudioCapture (Microphone)
AudioCapture is in @runanywhere/web-onnx. Configuration is passed to the constructor, and callbacks are passed to start():
AudioPlayback (Speaker)
AudioPlayback is in @runanywhere/web-onnx:
VideoCapture (Camera)
VideoCapture is in @runanywhere/web-llamacpp:
Acceleration
GPU Acceleration
The SDK auto-detects WebGPU availability whenLlamaCPP.register() is called:
If the WebGPU WASM file returns a 404, the SDK gracefully falls back to CPU mode. This is normal
behavior — check
LlamaCPP.accelerationMode to confirm which mode is active.Related
Error Handling
Handle errors gracefully
Best Practices
Optimization tips