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.1.tar.gz (41.8 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.1-py3-none-any.whl (68.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: superserve-0.4.1.tar.gz
  • Upload date:
  • Size: 41.8 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.1.tar.gz
Algorithm Hash digest
SHA256 b1db05888c3ffa2d99ca83bbc7fe6987f3f5c53c346692b1bd41aae00b8f5d44
MD5 b89a5edb97f09585809671e8078b520f
BLAKE2b-256 d648fd1ff622be5e6b14b94a314f38026d6a0f98a1c4a73e38698a97b17645cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: superserve-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 68.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 36b18d094b449de5472e7785c91c6b74b180d79c2cd5b508465eceb9b2af5577
MD5 53dc6e68281cfb6900dee6697210f9c4
BLAKE2b-256 1b5c8666db293e371d33935cdcf2157979906dff6eecb71bfdaaa34842d89529

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