Installation
- pip
- uv
Quick Start
- Async
- Sync
Core Features
Lifecycle Management
Manage the complete sandbox lifecycle with renewal, pausing, and resuming capabilities.Custom Health Check
Define custom logic to determine if the sandbox is healthy. This overrides the default ping check.Command Execution & Streaming
Execute commands and handle output streams in real-time.File Operations
Comprehensive file and directory management including read, write, search, and delete.Sandbox Management (Admin)
UseSandboxManager for administrative tasks and finding existing sandboxes.
Configuration
Connection Configuration
TheConnectionConfig class manages API server connection settings.
- Basic
- Advanced
Sandbox Creation Configuration
TheSandbox.create() method allows configuring the sandbox environment.
API Reference
Sandbox
Main class for interacting with sandboxes.
Methods
classmethod
Creates and initializes a new sandbox instance.Parameters:
image(str): Docker image to useconnection_config(ConnectionConfig): Connection configurationtimeout(timedelta, optional): Sandbox lifetimeentrypoint(List[str], optional): Custom entrypointresource(Dict[str, str], optional): CPU/memory limitsenv(Dict[str, str], optional): Environment variablesmetadata(Dict[str, str], optional): Custom metadatanetwork_policy(NetworkPolicy, optional): Network egress ruleshealth_check(Callable, optional): Custom health check functionready_timeout(timedelta, optional): Readiness timeout
Sandbox instanceclassmethod
Resumes a paused sandbox.Parameters:
sandbox_id(str): ID of the paused sandboxconnection_config(ConnectionConfig): Connection configuration
Sandbox instanceproperty
Access to command execution operations.Returns:
CommandsClientproperty
Access to file system operations.Returns:
FilesClientasync method
Extends the sandbox expiration time.Parameters:
duration(timedelta): Extension duration
async method
Pauses the sandbox (suspends all processes).
async method
Terminates the sandbox immediately.
async method
Retrieves current sandbox information.Returns:
SandboxInfoasync method
Gets the external endpoint for a port.Parameters:
port(int): Internal port number
SandboxEndpointExamples
Running a Python Script
Network Policy Example
Port Forwarding
Error Handling
Next Steps
Code Interpreter
Execute Python, Java, Go code with state persistence
API Reference
Explore detailed API documentation
Examples
Browse more code examples
Configuration
Advanced configuration options