Skip to main content

Python SDK for Vercel Sandbox

Project description

Python SDK for Vercel Sandbox

This is a minimal Python SDK that mirrors the core features of the TypeScript SDK:

  • Create sandboxes
  • Run commands (detached or wait for completion)
  • Stream command logs
  • Read/Write files, mkdir
  • Stop sandbox
  • Resolve exposed port domain

Quickstart

pip install vercel-sandbox

Or locally:

pip install -e .

Example

import asyncio
from vercel.sandbox import AsyncSandbox as Sandbox

async def main():
    async with await Sandbox.create(
        source={"type": "git", "url": "https://github.com/vercel/sandbox-example-next.git"},
        resources={"vcpus": 4},
        ports=[3000],
        timeout=600_000,
        runtime="node22",
    ) as sandbox:
        print("Installing dependencies...")
        result = await sandbox.run_command("npm", ["install", "--loglevel", "info"])  # waits
        if result.exit_code != 0:
            raise SystemExit("install failed")

        print("Starting dev server...")
        cmd = await sandbox.run_command_detached("npm", ["run", "dev"])  # detached
        print("Visit:", sandbox.domain(3000))

asyncio.run(main())

Using or not using the context manager

# Preferred: automatic cleanup
async with await Sandbox.create(timeout=60_000, runtime="node22") as sandbox:
    await sandbox.run_command("echo", ["hello"])

# Manual cleanup
sandbox = await Sandbox.create(timeout=60_000, runtime="node22")
try:
    await sandbox.run_command("echo", ["hello"])
finally:
    await sandbox.stop()
    await sandbox.client.aclose()

Authentication

The SDK prefers Vercel OIDC tokens when available:

  • Local: use vercel env pull and place credentials in a .env file (auto-loaded).
  • Alternatively provide VERCEL_TOKEN, VERCEL_TEAM_ID, and VERCEL_PROJECT_ID.

Environment variables

  • VERCEL_OIDC_TOKEN plus VERCEL_TEAM_ID and VERCEL_PROJECT_ID
  • or VERCEL_TOKEN, VERCEL_TEAM_ID, VERCEL_PROJECT_ID

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

vercel_sandbox-0.0.5.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

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

vercel_sandbox-0.0.5-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file vercel_sandbox-0.0.5.tar.gz.

File metadata

  • Download URL: vercel_sandbox-0.0.5.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vercel_sandbox-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a30d2301c8b2fcc35640b8f376fa7d708e0fe34f801703e67ff6a0034f206ca1
MD5 f6ebc359ca8b9120a97cc8a7d68fe1dd
BLAKE2b-256 03a3066c2d6f9b48d72a22113a561c797046e3c37a59f46a3e43d7f216b13083

See more details on using hashes here.

Provenance

The following attestation bundles were made for vercel_sandbox-0.0.5.tar.gz:

Publisher: publish.yml on vercel/sandbox-sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vercel_sandbox-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: vercel_sandbox-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vercel_sandbox-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 eed37c405c41da8eff21c1a8900bbdc8096239da38a741e6bb45f678c42453fc
MD5 42b91ac1d16319bfb03e646e81b591e6
BLAKE2b-256 2650634fc188d15b248f25bcec95f8dfa5db4a7ff7d43735c85e521c09014e9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for vercel_sandbox-0.0.5-py3-none-any.whl:

Publisher: publish.yml on vercel/sandbox-sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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