Python SDK for the Superserve sandbox API
Project Links
Meta
Requires Python: >=3.9
Classifiers
Development Status
- 4 - Beta
Intended Audience
- Developers
License
- OSI Approved :: Apache Software License
Programming Language
- Python :: 3
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
Topic
- Software Development :: Libraries :: Python Modules
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()
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.
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())
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
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
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.
0.8.2
Jul 28, 2026
0.8.1
Jul 21, 2026
0.8.0
Jul 10, 2026
0.7.8
Jul 08, 2026
0.7.7
Jun 26, 2026
0.7.6
Jun 18, 2026
0.7.5
Jun 18, 2026
0.7.4
Jun 03, 2026
0.7.3
May 28, 2026
0.7.2
May 28, 2026
0.7.1
May 05, 2026
0.7.0
Apr 29, 2026
0.6.0
Apr 23, 2026
0.5.0
Apr 16, 2026
0.4.2
Apr 16, 2026
0.4.1
Apr 16, 2026
0.1.5
Feb 24, 2026
0.1.4
Feb 24, 2026
0.1.3
Feb 17, 2026
0.1.2
Jan 31, 2026
0.1.1
Jan 31, 2026
0.1.0
Jan 31, 2026
Wheel compatibility matrix
Files in release
Extras:
None
Dependencies:
httpx
(>=0.24.0)
pydantic
(>=2.0.0)
typing-extensions
(>=4.0.0)
websockets
(>=12.0)