Skip to main content
This example requires a desktop-capable template.

Setup

uv pip install "${NULLSPACE_SDK_INSTALL_SPEC:-nullspace-sdk==0.1.9}"
export NULLSPACE_API_KEY=ns_live_...
export NULLSPACE_API_URL=https://api.your-nullspace-domain

Python

from nullspace import Sandbox

with Sandbox.create(template="desktop", timeout=300) as sandbox:
    width, height = sandbox.desktop.screen_size()
    print(f"desktop: {width}x{height}")

    sandbox.desktop.open("https://example.com")
    stream = sandbox.desktop.stream.start(view_only=False)
    print(f"viewer: {stream.viewer_url}")

    png = sandbox.desktop.screenshot()
    print(f"screenshot bytes: {len(png)}")

    sandbox.desktop.stream.stop()

Production note

Viewer URLs are signed. Treat them as bearer credentials and rotate viewer sessions when sharing access. Guide: Managed desktop viewer.