Skip to main content

Python SDK

Use the Python SDK for server-side integrations, local video replay, and local camera workflows. If you are still evaluating the product, start with the guided guest Workbench demo or the public catalog. This page is the integration path once you are ready to run your own backend workflow.

Step 1: Install

Requires Python 3.12 or newer. Install the media extra for local pose detection: pip install "kynasmith[media]".

Step 2: Initialize the client

The SDK infers your project from the API key.

Step 3: Create and release a MoveSpec

Define a MoveSpec using YAML that describes the movement you want to detect, then validate it, version it, and release it:
See MoveSpec for the full YAML authoring guide.

Step 4: Replay a video

Replace squat-demo.mp4 with the path to your own video file. If you are working inside this repo, the deterministic squat replay fixture lives at activities_golden_set/videos/squat.mp4.
Raw video stays local. The SDK extracts pose landmarks with MediaPipe and sends only pose frames to Kynasmith.

Step 5: Run a live camera session

start_camera() captures up to max_frames camera frames, finalizes the session, and returns the result.

Manual session control

Use the lower-level session helpers when you need full control over realtime flow:

Separate credential fields

Service account authentication

Pre-minted access token

When using a static access token, you are responsible for refresh and rotation.

Explicit project ID

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

Typed errors

The Python SDK raises typed exceptions for structured error handling:
  • AuthError — authentication failures (invalid or expired credentials)
  • AuthorizationError — permission or scope errors
  • CompatibilityError — SDK version is not compatible (update your SDK)
  • SessionStateError — session lifecycle violations
  • ValidationError — request or MoveSpec validation failures
  • RateLimitError — rate limit exceeded (HTTP 429)

Limitations

  • Synchronous only: The SDK is fully synchronous. In async frameworks, wrap SDK calls with asyncio.to_thread() to avoid blocking the event loop:
  • First-run model download: The first detector run downloads the default MediaPipe .task model (~100 MB) into the local cache. Pass model_path to use a pre-downloaded model.

Environment notes

  • Python 3.12 or newer required
  • Default install includes mediapipe and opencv-python-headless
  • Tested compatibility line: mediapipe==0.10.32
  • Default model asset: pose_landmarker_full/float16/1/pose_landmarker_full.task