Skip to main content

Python SDK for the Superserve sandbox API

Project description

Superserve Python SDK

Python SDK for the Superserve sandbox API — spin up isolated sandboxes, run commands in them, and tear them down from code.

Install

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

Requires Python 3.9+.

Quick start

import os
from superserve import Superserve

client = Superserve(api_key=os.environ["SUPERSERVE_API_KEY"])

sandbox = client.sandboxes.create_sandbox(name="hello-world")

try:
    result = client.exec.command(
        sandbox_id=sandbox.id,
        body={"command": "echo 'Hello from Superserve!'"},
    )
    print(result.stdout)
finally:
    client.sandboxes.delete_sandbox(sandbox.id)

Get an API key from the Superserve console.

Resource clients

The Superserve client exposes four resource groups:

  • client.sandboxes — create, list, get, patch, pause, resume, and delete sandboxes
  • client.exec — run commands inside a sandbox (command) or stream output (command_stream)
  • client.files — upload and download files to and from a sandbox
  • client.system — health check

Configuration

from superserve import Superserve
from superserve.environment import SuperserveEnvironment

client = Superserve(
    api_key="ss_live_...",                            # required
    environment=SuperserveEnvironment.PRODUCTION,     # optional
    base_url="http://localhost:8080",                 # optional, overrides environment
    timeout=60.0,                                     # optional, default 60
    httpx_client=None,                                # optional, inject a custom httpx.Client
)

Async client

AsyncSuperserve mirrors every method on Superserve with async/await:

import asyncio
import os
from superserve import AsyncSuperserve

async def main():
    client = AsyncSuperserve(api_key=os.environ["SUPERSERVE_API_KEY"])

    sandbox = await client.sandboxes.create_sandbox(name="async-example")
    try:
        result = await client.exec.command(
            sandbox_id=sandbox.id,
            body={"command": "uname -a"},
        )
        print(result.stdout)
    finally:
        await client.sandboxes.delete_sandbox(sandbox.id)

asyncio.run(main())

Error handling

from superserve import Superserve
from superserve.errors import BadRequestError, NotFoundError

client = Superserve(api_key=os.environ["SUPERSERVE_API_KEY"])

try:
    client.sandboxes.get_sandbox("sbx_missing")
except NotFoundError:
    print("sandbox does not exist")
except BadRequestError as err:
    print("invalid request:", err.body)

Available error classes: BadRequestError, UnauthorizedError, NotFoundError, ConflictError, InternalServerError.

Documentation

Full docs: docs.superserve.ai

License

Apache-2.0

Project details


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.5.0.tar.gz (41.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

superserve-0.5.0-py3-none-any.whl (69.0 kB view details)

Uploaded Python 3

File details

Details for the file superserve-0.5.0.tar.gz.

File metadata

  • Download URL: superserve-0.5.0.tar.gz
  • Upload date:
  • Size: 41.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for superserve-0.5.0.tar.gz
Algorithm Hash digest
SHA256 44756ccc7cf7f2c727385e1697ab6d36c4e21251d48d184d1840c7bb90ccc524
MD5 2d8ef33d63bd37f937432e8b8bdca1d6
BLAKE2b-256 624764c6b3437e62e2b892c8c3ff59e7433179cacefb75f5aea91fea6fcb466a

See more details on using hashes here.

File details

Details for the file superserve-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: superserve-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 69.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for superserve-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ebdf04a61ca28945cc10748d7c2538b746cdf7ca575e7bbe08b5e537e5de253
MD5 dbcbb3a2f589438729b84f8a87a20e7c
BLAKE2b-256 542e291e718a75b79c72038937c7bd2f2ca4e28d1e9e0cf696976270e74c2ae7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page