Agent Sandbox SDK

raw JSON →
0.0.30 verified Fri May 01 auth: no python

Python SDK for the All-in-One Sandbox API (>=1.7.0). Provides a sandboxed environment for executing code, running commands, and managing files. Current version: 0.0.30. Active development, weekly releases.

pip install agent-sandbox
error ImportError: cannot import name 'Sandbox' from 'agent_sandbox'
cause The class was renamed to SandboxClient.
fix
Use from agent_sandbox import SandboxClient.
error httpx.HTTPStatusError: 403 Forbidden
cause Missing or invalid API key.
fix
Set the SANDBOX_API_KEY environment variable or pass a valid api_key to SandboxClient.
breaking The client class was renamed from `Sandbox` to `SandboxClient` in v0.0.20. Old imports will fail.
fix Use `from agent_sandbox import SandboxClient` instead of `from agent_sandbox import Sandbox`.
deprecated The `execute` method is deprecated in favor of `code_exec`.
fix Replace `client.execute(code='...')` with `client.code_exec(code='...')`.
gotcha API key is required; passing an empty string leads to a 403 error. Always set the SANDBOX_API_KEY environment variable.
fix Set the environment variable or pass `api_key` explicitly.

Create a client using the API key from environment variable and execute Python code.

import os
from agent_sandbox import SandboxClient

client = SandboxClient(api_key=os.environ.get('SANDBOX_API_KEY', ''))
result = client.code_exec(code='print("Hello, world!")')
print(result.text)