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.4.2.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.4.2-py3-none-any.whl (68.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: superserve-0.4.2.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.4.2.tar.gz
Algorithm Hash digest
SHA256 300c9a38d51a8fabe14ece8954392059c89712b3e72d1c8fd29be474865ae413
MD5 5b0430d4e9d8712b7653f04d0049e461
BLAKE2b-256 9c99967c05e9c49b338e1cdb1af0f6bf78d5203caac30fa9addf0279dabd5aa4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: superserve-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 68.9 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.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 116e19b212e273f51d227fb43da0afa91939ce84c8e206bcef92f4eb604164ce
MD5 3789b558b9b637e0da78388e9e23b1c9
BLAKE2b-256 a669594466ed4fad218144ab22f1570708ef388e46c7d0cea3170a88cce1cb3d

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