Skip to content

AsyncSandboxesClient

Source: leap0/_async/sandbox.py

AsyncSandboxesClient(transport: AsyncTransport, *, sandbox_domain: str | None = None, sandbox_factory: SandboxFactory[SandboxData | SandboxStatus, AsyncSandboxT] | None = None)

Create, inspect, pause, and delete sandboxes asynchronously.

Attributes: None.

async create(*, template_name: str = DEFAULT_TEMPLATE_NAME, vcpu: int = DEFAULT_VCPU, memory_mib: int = DEFAULT_MEMORY_MIB, timeout_min: int = DEFAULT_TIMEOUT_MIN, auto_pause: bool = False, otel_export: bool = False, env_vars: dict[str, str] | None = None, network_policy: NetworkPolicyDict | None = None, http_timeout: float | None = None) -> AsyncSandboxT | SandboxData | SandboxStatus

Create a new sandbox from a template.

Args: template_name: Name of the template to use. vcpu: Number of virtual CPUs (1 to 8). memory_mib: Memory in MiB (512 to 8192, must be even). timeout_min: Sandbox timeout in minutes (1 to 480). auto_pause: Whether the sandbox should auto-pause on timeout. otel_export: Inject OpenTelemetry exporter environment into the sandbox. Requires OTEL_EXPORTER_OTLP_ENDPOINT in the local environment and also forwards OTEL_EXPORTER_OTLP_HEADERS when present. env_vars: Environment variables to set inside the sandbox. network_policy: Outbound network policy for the sandbox. http_timeout: Optional HTTP request timeout in seconds for this SDK call.

Returns: AsyncSandboxT | SandboxData | SandboxStatus: Created sandbox object.

async pause(sandbox: SandboxRef, http_timeout: float | None = None) -> AsyncSandboxT | SandboxData | SandboxStatus

Pause the sandbox and return updated metadata.

Args: sandbox: Sandbox ID or object. http_timeout: Optional HTTP request timeout in seconds for this SDK call.

Returns: AsyncSandboxT | SandboxData | SandboxStatus: Updated sandbox object.

async get(sandbox: SandboxRef, http_timeout: float | None = None) -> AsyncSandboxT | SandboxData | SandboxStatus

Get the latest sandbox metadata.

Args: sandbox: Sandbox ID or object. http_timeout: Optional HTTP request timeout in seconds for this SDK call.

Returns: AsyncSandboxT | SandboxData | SandboxStatus: Current sandbox object.

async delete(sandbox: SandboxRef, http_timeout: float | None = None) -> None

Terminate and delete a sandbox.

Args: sandbox: Sandbox ID or object.

invoke_url(sandbox: SandboxRef, path: str = '/', *, port: int | None = None) -> str

Build an HTTPS URL for this sandbox.

Args: sandbox: Sandbox ID or object. path: Path used by this operation. port: Port number for the generated URL.

Returns: object: Result returned by this operation.

websocket_url(sandbox: SandboxRef, path: str = '/', *, port: int | None = None) -> str

Build a websocket URL for this sandbox.

Args: sandbox: Sandbox ID or object. path: Path used by this operation. port: Port number for the generated URL.

Returns: object: Result returned by this operation.