Skip to main content

superserve

Python SDK for the Superserve sandbox API — run code in isolated Firecracker MicroVMs.

Installation

pip install superserve
# or
uv add superserve
# or
poetry add superserve

Requires Python ≥ 3.9.

Quick Start

from superserve import Sandbox

sandbox = Sandbox.create(name="my-sandbox")

result = sandbox.commands.run("echo hello")
print(result.stdout)

sandbox.files.write("/app/data.txt", b"content")
text = sandbox.files.read_text("/app/data.txt")

sandbox.kill()

Custom size

A template built with a size range lets each sandbox use a fixed size within it:

from superserve import Sandbox, Template, TemplateSizeRange

template = Template.create(
    name="my-env",
    from_="python:3.11",
    vcpu=1,
    memory_mib=2048,
    size_range=TemplateSizeRange(vcpu_max=4, memory_max_mib=8192),
)
template.wait_until_ready()

sandbox = Sandbox.create(
    name="build",
    from_template="my-env",
    vcpu=4,
    memory_mib=8192,
)

Leave either out to keep the template's default size. Sandboxes created from a snapshot can pick a size within the range the snapshot records. See Custom size.

Preview URLs

Choose the default access for new ports, publish only the ports you intend to expose, and request a signed link for private browser access:

sandbox = Sandbox.create(name="private-preview", preview_access="private")
sandbox.publish_preview_port(3000, access="private")

browser_url = sandbox.get_signed_preview_url(3000, expires_in_seconds=300)
credential = sandbox.get_preview_token(3000)
# Machine clients: {credential.header: credential.token}

Each published port keeps its own public or private mode; preview_access is only the default for newly published ports. Omitting it defaults a new sandbox to strict public. legacy_public is returned only for pre-migration sandboxes. See the preview URL guide.

Desktop (computer use)

Control a GUI desktop inside a sandbox — screenshot, mouse, keyboard, and a live browser viewer. Requires a desktop-enabled template.

sandbox = Sandbox.create(name="desktop", from_template="superserve/desktop")

shot = sandbox.desktop.screenshot()  # PNG; format="jpeg" for smaller frames
sandbox.desktop.click(640, 400)
sandbox.desktop.write("hello")  # no per-character pacing
sandbox.desktop.press("ctrl+l")
sandbox.desktop.drag((10, 10), (200, 200))  # one atomic request

# Several model-emitted actions in a single round trip:
sandbox.desktop.actions([
    {"type": "click", "x": 640, "y": 32},
    {"type": "write", "text": "https://example.com"},
    {"type": "press", "key": "enter"},
])

# ...or the whole turn plus the next frame, still one request:
step = sandbox.desktop.step(
    [{"type": "click", "x": 640, "y": 400}], wait_for_change=True, format="jpeg"
)
frame = step.screenshot

sandbox.desktop.resize(1920, 1080)  # live, no restart
viewer = sandbox.desktop.get_stream_url()  # noVNC URL

Authentication

Set the SUPERSERVE_API_KEY environment variable:

export SUPERSERVE_API_KEY=ss_live_...

Or pass it explicitly:

sandbox = Sandbox.create(
    name="my-sandbox",
    api_key="ss_live_...",
    base_url="https://api.superserve.ai",  # optional
)

Async usage

import asyncio
from superserve import AsyncSandbox

async def main():
    sandbox = await AsyncSandbox.create(name="async-example")
    try:
        result = await sandbox.commands.run("echo hello")
        print(result.stdout)
    finally:
        await sandbox.kill()

asyncio.run(main())

Calls made on an AsyncSandbox reuse its connection. To reuse connections across other calls too, such as AsyncSandbox.create or AsyncSnapshot.get, make them inside async_connection_pool(). The connections close when the block ends.

from superserve import AsyncSandbox, AsyncSnapshot, async_connection_pool

async with async_connection_pool():
    sandbox = await AsyncSandbox.create(name="async-example")
    snapshots = await AsyncSnapshot.list(sandbox.id)

Streaming command output

result = sandbox.commands.run(
    "pip install numpy",
    on_stdout=lambda data: print(data, end=""),
    on_stderr=lambda data: print(data, end=""),
    timeout_seconds=120,
)

Error handling

from superserve import (
    SandboxError,
    AuthenticationError,     # 401
    ValidationError,         # 400
    NotFoundError,           # 404
    ConflictError,           # 409 — invalid state for operation
    BillingError,            # 402 — billing blocks the request; has code and action_url
    SandboxTimeoutError,     # request timed out (does not shadow builtin TimeoutError)
    ServerError,             # 500
)

try:
    sandbox.pause()
except ConflictError:
    # Sandbox is not in a pausable state
    pass

Full documentation

docs.superserve.ai

Development

# From repo root:
bunx turbo run build --filter=@superserve/python-sdk
bunx turbo run typecheck --filter=@superserve/python-sdk
bunx turbo run lint --filter=@superserve/python-sdk

License

Apache License 2.0.

Metadata

Release files for superserve 0.14.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for superserve 0.14.1
File Size Uploaded Provenance Actions
superserve-0.14.1.tar.gz 111.4 kB Without provenance Details for superserve-0.14.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for superserve 0.14.1
File Interpreter ABI Platform Actions
superserve-0.14.1-py3-none-any.whl Python 3 none any Details for superserve-0.14.1-py3-none-any.whl

Total release size: 188.7 kB

Release files / superserve-0.14.1.tar.gz

Download URL superserve-0.14.1.tar.gz
Size 111.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4c1e0c01e562a08f9be642b3d708851b1a283ce426757bb7491017d10aed43e2
BLAKE2b-256 checksum
How to use checksums
bc4b42b9c98563ca5863637a4024d36d970c106e6ef1b8687f0cab4239b4701e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / superserve-0.14.1-py3-none-any.whl

Download URL superserve-0.14.1-py3-none-any.whl
Size 77.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbc798bd402bc8858ca21833a18c93fa6252996cccc172150e63a65c0a2dc78a
BLAKE2b-256 checksum
How to use checksums
f8991be9d45f52d444623500d2dad8d1e4644786e68cf707e97d585f63d22b6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for superserve 0.14.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.14.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page