Skip to main content

Web SDK

Use the Web SDK in browser applications with a short-lived tokenProvider flow from your backend. If you want to evaluate the runtime before you wire in browser auth, start with the guided guest Workbench demo. This page is the integration path once you are ready to connect your own frontend.

Step 1: Install

The @kynasmith/web-sdk package is the intended public browser integration path. If the install command currently returns a 404, check the changelog for registry availability before treating it as an integration issue.

Step 2: Set up a backend token endpoint

Your browser application must not embed long-lived API keys. Instead, create a backend endpoint that exchanges your API key for a short-lived access token:
See Authentication for more details on the token exchange flow and available scopes.

Step 3: Initialize the client

Your tokenProvider is called before each authenticated request, so it must always be able to return a fresh token.

Step 4: Create and release a MoveSpec

See MoveSpec for the full YAML authoring guide.

Step 5: Replay a browser video file

Step 6: Run a live camera session

startCamera() processes local camera frames until maxFrames is reached or the run is aborted, then finalizes the session and returns the result.

Manual session control

Use the lower-level session helpers for full control over realtime flow:

Static access token

If you already have a short-lived bearer token:
When using a static accessToken, you are responsible for refresh and rotation.

Explicit project ID

When your credential is scoped to multiple projects, pass projectId in request payloads:

Typed errors

The Web SDK exposes typed error classes for structured error handling:
  • AuthError — authentication failures
  • AuthorizationError — permission or scope errors
  • CompatibilityError — SDK version is not compatible (update your SDK)
  • RealtimeProtocolError — connection or session communication failure
  • SessionStateError — session lifecycle violations
  • ValidationError — request or MoveSpec validation failures
  • RateLimitError — rate limit exceeded (HTTP 429)

Browser requirements

  • tokenProvider must be able to mint or fetch fresh short-lived bearer tokens repeatedly
  • Camera helpers require navigator.mediaDevices.getUserMedia()
  • Replay and camera helpers need a browser environment with fetch, WebSocket, and media APIs
  • If you keep the default MediaPipe asset URLs, your CSP and network path must allow Google Cloud Storage and jsDelivr

Compatibility

  • @mediapipe/tasks-vision 0.10.32
  • Default WASM root: @mediapipe/tasks-vision@0.10.32/wasm
  • Default model asset: pose_landmarker_full/float16/1/pose_landmarker_full.task