Installation
Core Classes
Sandbox
Main entrypoint for creating and managing sandbox instances.Class Methods
create()
Create a new sandbox instance with the specified configuration.Container image specification. Can be a string (e.g.,
"python:3.11") or a SandboxImageSpec object with authentication.Maximum sandbox lifetime before automatic termination.
Maximum time to wait for sandbox to become ready.
Environment variables for the sandbox.
Custom metadata tags for the sandbox.
Resource limits (CPU, memory, etc.).
Optional outbound network policy (egress).
Opaque extension parameters passed through to the server.
Command to run as entrypoint.
Optional list of volume mounts for persistent storage.
Connection configuration for API server.
Custom async health check function.
Time between health check attempts.
If True, do not wait for sandbox readiness/health.
Fully configured and ready Sandbox instance.
connect()
Connect to an existing sandbox instance by ID.ID of the existing sandbox.
Connection configuration.
Custom async health check function.
Maximum time to wait for sandbox readiness/health after connecting.
Polling interval while waiting for readiness/health.
If True, do not wait for readiness/health.
Connected Sandbox instance.
resume()
Resume a paused sandbox by ID and return a new Sandbox instance.ID of the paused sandbox to resume.
Connection configuration.
Optional custom async health check function.
Maximum time to wait for sandbox readiness/health after resuming.
Polling interval while waiting for readiness/health.
If True, do not wait for readiness/health.
Resumed Sandbox instance.
Instance Methods
get_info()
Get the current status of the sandbox.Current sandbox status including state and metadata.
get_endpoint()
Get a specific network endpoint for the sandbox.The port number to get the endpoint for.
Endpoint information including connection details.
get_metrics()
Get the current resource usage metrics for the sandbox.Current sandbox metrics including CPU, memory, and I/O statistics.
renew()
Renew the sandbox expiration time to delay automatic termination.Duration to add to the current time to set the new expiration.
Renew response including the new expiration time.
pause()
Pause the sandbox while preserving its state.kill()
Send a termination signal to the remote sandbox instance.close()
Close local resources associated with the sandbox.is_healthy()
Check if the sandbox is healthy and responsive.True if sandbox is healthy, False otherwise.
Properties
files
Provides access to file system operations within the sandbox.File system operations interface.
commands
Provides access to command execution operations.Command execution interface.
metrics
Provides access to sandbox metrics and monitoring.Metrics and monitoring interface.
SandboxManager
Administrative interface for managing multiple sandbox instances.Class Methods
create()
Create a SandboxManager instance.Connection configuration for the manager.
Configured sandbox manager instance.
Instance Methods
list_sandbox_infos()
List sandboxes with filtering options.Filter criteria for sandbox listing.
Paged sandbox information matching the filter criteria.
get_sandbox_info()
Get information for a single sandbox by ID.Sandbox ID to retrieve information for.
SandboxInfo for the specified sandbox.
kill_sandbox()
Terminate a single sandbox.Sandbox ID to terminate.
renew_sandbox()
Renew expiration time for a single sandbox.Sandbox ID to renew.
Duration to add to the current time to set the new expiration.
Renew response including the new expiration time.
pause_sandbox()
Pause a single sandbox while preserving its state.Sandbox ID to pause.
resume_sandbox()
Resume a previously paused sandbox.Sandbox ID to resume.
close()
Close local resources associated with the sandbox manager.Service Interfaces
Commands
Command execution service for sandbox environments.run()
Execute a shell command in the sandbox environment.Shell command text to execute.
Command execution options (e.g., background, working_directory).
Optional async handlers for streaming events (stdout/stderr/result/init/complete/error).
An Execution handle representing the running command instance.
interrupt()
Interrupt and terminate a running command execution.Unique identifier of the execution to interrupt.
get_command_status()
Get the current running status for a command.Unique identifier of the execution to query.
CommandStatus describing running state and exit code if available.
get_background_command_logs()
Get background command logs (non-streamed).Unique identifier of the execution to query.
Optional line cursor for incremental reads.
CommandLogs containing raw output and latest cursor.
Filesystem
Filesystem operations service for sandbox environments.read_file()
Read the content of a file as a string.The absolute or relative path to the file to read.
Character encoding for the file content.
HTTP byte range to read (e.g., “bytes=0-1023”).
The file content as a string.
read_bytes()
Read the content of a file as bytes.The absolute or relative path to the file to read.
HTTP byte range to read (e.g., “bytes=0-1023”).
The file content as bytes.
read_bytes_stream()
Stream file content as bytes chunks.The absolute or relative path to the file to read.
Size of each chunk in bytes.
HTTP byte range to read (e.g., “bytes=0-1023”).
Async iterator yielding bytes chunks.
write_files()
Write content to files based on the provided write entries.List of WriteEntry objects specifying files to write and their content.
write_file()
Write content to a single file (convenience method).Destination file path.
Content to write.
Character encoding.
Unix file permissions.
Owner username.
Group name.
create_directories()
Create directories based on the provided entries.List of WriteEntry objects specifying directories to create.
delete_files()
Delete the specified files.List of file paths to delete.
delete_directories()
Delete the specified directories.List of directory paths to delete.
move_files()
Move files from source to destination paths.List of MoveEntry objects specifying source and destination paths.
set_permissions()
Set file system permissions for the specified entries.List of SetPermissionEntry objects specifying files and their new permissions.
replace_contents()
Replace content in files based on search and replace patterns.List of ContentReplaceEntry objects specifying replacement operations.
search()
Search for files and directories based on the specified criteria.SearchEntry object containing search parameters and criteria.
List of EntryInfo objects containing metadata for matching files/directories.
get_file_info()
Retrieve file information for the specified paths.List of file/directory paths to get information for.
Map where keys are file paths and values are EntryInfo objects.
Configuration
ConnectionConfig
Connection configuration for API server communication.API Key for authentication (can also be set via
OPEN_SANDBOX_API_KEY environment variable).The endpoint domain of the sandbox service (can also be set via
OPEN_SANDBOX_DOMAIN environment variable).HTTP protocol (http/https).
Timeout for API requests.
Enable debug logging for HTTP requests.
Custom HTTP headers.
Shared httpx transport (pool/proxy/retry).
Use sandbox server as proxy for execd/endpoint requests.
Synchronous API
The SDK also provides synchronous versions of the main classes:SandboxSync, SandboxManagerSync, and ConnectionConfigSync classes.
Exception Handling
The SDK raisesSandboxException and its subclasses for various error conditions: