Python SDK for the Superserve sandbox API
Project description
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()
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
superserve-0.8.0.tar.gz
(57.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file superserve-0.8.0.tar.gz.
File metadata
- Download URL: superserve-0.8.0.tar.gz
- Upload date:
- Size: 57.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f7851be7b8b4e43a57e22820380146222f473b2be9284c4b7ab2ac8f40d6d73
|
|
| MD5 |
6dd882f55f36ad9396a3ff60a6c98d35
|
|
| BLAKE2b-256 |
20483316ad613cceb005d689071bbf87c1ebc9e8d461eb9f2c35929c1b48a166
|
File details
Details for the file superserve-0.8.0-py3-none-any.whl.
File metadata
- Download URL: superserve-0.8.0-py3-none-any.whl
- Upload date:
- Size: 43.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1359b13b2954a6fe1319b5eb2490568c7e8edf74922413db3eb89b6a45c62605
|
|
| MD5 |
db92d5ad51708c88b8ed4932d5c46430
|
|
| BLAKE2b-256 |
c2144ef1a780d334093c44a71578ed35dbef0d88d5e7a227f2e5d640cb27c9f8
|