Skip to main content

Overview

Telegram Mini Apps run on the ZeroGPU browser SDK: one script tag in your Mini App’s HTML turns the devices opening it into inference nodes on the ZeroGPU network. The SDK detects the Telegram WebApp environment automatically and adapts to it.

Requirements

  • A Telegram Mini App (a web app opened inside Telegram).
  • An SDK key (zgpu-sdk-…) from the Edge Operator Portal. When you add your app, select Telegram Mini App as an app type and use your t.me link as the website.
  • The same browser requirements as the Browser SDK: WebAssembly, IndexedDB, and Web Workers, all available in Telegram’s in-app browser.

Download

Installation

Add the loader to your Mini App’s HTML. It always resolves the latest released SDK:

Initialization

The simplest setup is auto-init: put your SDK key on the script tag and the SDK starts when the page loads.
For manual init, use ZeroGpuSdk.initZeroGpuSdk({ edgeOperatorKey }) exactly as in the Browser SDK. All the same options apply.

App ID and app name (optional)

Pass the app ID and name from the Edge Operator Portal so the inference these devices serve is attributed to your Mini App. Copy the ID from your app’s row on My Apps, and pass your bot username as the native ID:
All three are optional: leaving them unset never affects registration or inference, and ZeroGPU then uses the app your SDK key belongs to.

Authentication

The SDK authenticates with your SDK key (zgpu-sdk-…), passed as edgeOperatorKey. The key only joins devices to your fleet; it can’t call the inference API or spend credits.

Register device

Registration is automatic. Inside Telegram, the SDK:
  • Detects that it’s running inside Telegram.
  • Uses the Telegram user ID as appUserId, so you don’t need to pass it.
  • Downloads and caches a model, then connects the device to ZeroGPU.

Start contributing compute

The device contributes compute while your Mini App is open. There’s nothing else to call.

Stop / pause

Keep the handle returned by initZeroGpuSdk and call shutdown() to stop:
There is no separate pause call. Closing the Mini App also stops contribution.

Device lifecycle

The lifecycle matches the Browser SDK: starting, running, degraded, shutdown, or error, with degraded, recovered, and shutdown events. Telegram’s in-app WebViews behave differently from regular browsers, so the SDK adapts its memory and storage checks there, and includes a guard that stops it from restarting repeatedly if the WebView keeps crashing and reloading.

Example integration

index.html
To verify, open the Mini App in Telegram Desktop or Telegram Web with developer tools, and watch the console as the SDK registers the device, loads a model, and becomes ready. Turn enableConsoleLogs off for release. Once the device is online, check that it’s eligible and earning.

Troubleshooting

See Browser troubleshooting for worker and CSP issues.