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 pulland place credentials in a.envfile (auto-loaded). - Alternatively provide
VERCEL_TOKEN,VERCEL_TEAM_ID, andVERCEL_PROJECT_ID.
Environment variables
VERCEL_OIDC_TOKENplusVERCEL_TEAM_IDandVERCEL_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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vercel_sandbox-0.0.3.tar.gz.
File metadata
- Download URL: vercel_sandbox-0.0.3.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27fd51525e9143e3f3e241575aaa77f4247a59f70f4202b46ec720ae464189ea
|
|
| MD5 |
5456b2e725032f43a0bcd11c785c1539
|
|
| BLAKE2b-256 |
c55240d89bf17b87aea0673a87a9172cb13fd7983b05c642bf43272e22631361
|
Provenance
The following attestation bundles were made for vercel_sandbox-0.0.3.tar.gz:
Publisher:
publish.yml on vercel/sandbox-sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vercel_sandbox-0.0.3.tar.gz -
Subject digest:
27fd51525e9143e3f3e241575aaa77f4247a59f70f4202b46ec720ae464189ea - Sigstore transparency entry: 628789390
- Sigstore integration time:
-
Permalink:
vercel/sandbox-sdk-py@a827895f4051c781a8512b9906d648d55e338fc8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vercel
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a827895f4051c781a8512b9906d648d55e338fc8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vercel_sandbox-0.0.3-py3-none-any.whl.
File metadata
- Download URL: vercel_sandbox-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8b2460aff051e7e6e76042b9d66c67360a8a31a0f6b6955669ce0cde2856fe9
|
|
| MD5 |
73df31d077436fe5d5bf3cd84cc11534
|
|
| BLAKE2b-256 |
61f1774d33ee9caece51ff1285bb61d42754039472b285a9b69b049e58628bc3
|
Provenance
The following attestation bundles were made for vercel_sandbox-0.0.3-py3-none-any.whl:
Publisher:
publish.yml on vercel/sandbox-sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vercel_sandbox-0.0.3-py3-none-any.whl -
Subject digest:
f8b2460aff051e7e6e76042b9d66c67360a8a31a0f6b6955669ce0cde2856fe9 - Sigstore transparency entry: 628789394
- Sigstore integration time:
-
Permalink:
vercel/sandbox-sdk-py@a827895f4051c781a8512b9906d648d55e338fc8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vercel
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a827895f4051c781a8512b9906d648d55e338fc8 -
Trigger Event:
push
-
Statement type: