Skip to main content

Overview

The ZeroGPU browser SDK turns the browsers running your website or Chrome extension into on-device inference nodes on the ZeroGPU network. It downloads a small model, registers the device, and serves inference tasks locally, in a Web Worker so your page’s main thread stays responsive. There are two ways to integrate: Building a Telegram Mini App? See Telegram Mini Apps.

Requirements

  • A modern desktop or mobile browser with WebAssembly, IndexedDB (for the model cache), and Web Workers.
  • An SDK key (zgpu-sdk-…) from the Edge Operator Portal.
  • Websites with a strict Content Security Policy: allow blob: workers, or host the worker yourself and set overrides.inference.workerUrl.
  • Chrome extensions: Manifest V3, plus Node.js and npm at build time only. Nothing from node_modules ships in your extension.

Installation

Add the loader to your page. It always resolves the latest released SDK, so you never pin or bump versions:
Or install from npm if you bundle your own JavaScript:

Initialization

Script tag (auto-init). The SDK starts as soon as edgeOperatorKey is present:
Manual init. Load the loader without a key and call initZeroGpuSdk. Calls made before the SDK finishes loading are queued and replayed:
ESM:

Authentication

The SDK authenticates with your SDK key (zgpu-sdk-…), passed as edgeOperatorKey. The key can only join devices to your fleet; it can’t call the inference API or spend credits. Still, inject it at build time rather than committing it.

Register device

Registration is automatic. On start, the SDK collects coarse device capabilities (platform, CPU cores, approximate memory, battery level, connection type), downloads and caches its assigned model in IndexedDB, registers with the ZeroGPU device registry, and opens a WebSocket for tasks.

Start contributing compute

  • Websites: the SDK starts when it’s initialized with your SDK key and keeps contributing while the page is open.
  • Chrome extensions: the SDK runs in a background offscreen document and starts automatically whenever your extension loads.

Stop / pause

initZeroGpuSdk returns a handle. Call shutdown() to stop gracefully:
Shutdown lasts until the page initializes the SDK again; there is no separate pause call.

Device lifecycle

On websites, the handle’s status is one of starting, running, degraded, shutdown, or error. Subscribe to changes:
initZeroGpuSdk never throws: if the SDK can’t run on a device, status reports it instead of breaking your page. Before downloading models, the SDK checks memory and storage, and blocks downloads when the battery is below 20% and the device isn’t charging.

Example integration

index.html
Open the page and check the console: with enableConsoleLogs on, you’ll see the SDK register the device, load a model, and become ready.

Troubleshooting