Metadata-Version: 2.4
Name: sandcovery
Version: 0.2.0
Summary: Python client for the Sandcovery API: one API and one key for ephemeral sandboxes across providers.
License-Expression: MIT
License-File: LICENSE
Requires-Dist: httpx>=0.28.1
Requires-Dist: pydantic>=2.14.3
Requires-Python: >=3.11
Project-URL: Homepage, https://www.sandcovery.com
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://www.sandcovery.com/logo.svg" alt="Sandcovery" width="96" height="96">
</p>

# Sandcovery

Python client for the [Sandcovery API](https://www.sandcovery.com): one API and one key for ephemeral sandboxes across E2B, Daytona, Vercel Sandbox, and Depot, running on your own provider accounts.

## Install

```sh
pip install sandcovery
```

Python 3.11 or later.

## Quick start

Create an API key and add your provider credentials in the dashboard at https://www.sandcovery.com/app, then set `SANDCOVERY_API_KEY`.

```python
from sandcovery import Sandcovery

with Sandcovery() as sandcovery:
    sandbox = sandcovery.sandboxes.create(size="2x4:cheapest", ttl_seconds=600)

    result = sandcovery.sandboxes.exec(sandbox.id, "python --version")
    print(result.exit_code, result.stdout)

    for event in sandcovery.sandboxes.exec_stream(sandbox.id, "pytest"):
        if event.type == "stdout":
            print(event.data, end="")

    sandcovery.sandboxes.destroy(sandbox.id)
```

Sandcovery destroys every sandbox at its `ttl_seconds`, even when your process exits first.

## Routing

A size name such as `2x4` (2 vCPU, 4 GiB) picks the provider by default routing. Add `:cheapest`, `:fastest`, or `:most-reliable` to sort candidates by list price, measured create latency, or uptime over the last 15 minutes. `provider` takes `order`, `only`, `ignore`, `sort`, and `allow_fallbacks`. Every create attempt is listed in `sandbox.attempts`.

Provider, region, and size names are open strings, so a name the API adds later works with this version. The names known at release are `sandcovery.PROVIDERS`, `REGIONS`, `STANDARD_SIZES`, `SIZE_NAMES`, and `EGRESS_MODES`.

## Keys and provider credentials

`keys`, `credentials`, and `usage` need a management key, which an organization owner or admin mints in the dashboard. An API key receives 403 there.

```python
import os

from sandcovery import Sandcovery

admin = Sandcovery(os.environ["SANDCOVERY_MANAGEMENT_KEY"])
admin.credentials.set("e2b", api_key=os.environ["E2B_API_KEY"])
```

The fields each provider takes are its `credential_fields` on `sandcovery.providers.get(provider)`.

## Errors

A failed call raises `SandcoveryError` with the HTTP `status`, the error `code`, such as `unsupported`, `no_provider_available`, `provider_error`, or `spend_limit_reached`, and the decoded error in `body`, which lists every attempt for `no_provider_available` and names the provider for `provider_error`.

## Reference

The API reference and the OpenAPI document are at https://www.sandcovery.com/docs.
