boxlite serve and your create / exec / list_info / remove calls become HTTP and WebSocket requests served by real microVMs elsewhere. Swapping Boxlite.default() for Boxlite.rest(...) leaves your call sites almost unchanged.
Prerequisites
- A working BoxLite install (Python
boxliteor Node@boxlite-ai/boxlite) and a machine with hardware virtualization — see Installation.
Start a local server for integration testing (on a host with virtualization):
http://localhost:8100.
Quick Example
Minimal happy path: connect to a remote endpoint and list existing boxes. Runs as-is (startboxlite serve in another terminal first).
Key point:Boxlite.rest(...)is a synchronous constructor, but the runtime operations under the REST client (create / get / get_info / list_info / metrics / remove) must beawaited. The localBoxlitehandle behaves the same way: synchronous construction, async methods.
Create, Execute, Reclaim (End to End)
Parameters and Returns
BoxliteRestOptions(...) Constructor Parameters
Node equivalent:new BoxliteRestOptions({ url, credential, pathPrefix })(the Node field ispathPrefix).
Loading from Environment Variables (Recommended for CI/Production)
BoxliteRestOptions.from_env() reads the following environment variables and automatically wraps BOXLITE_API_KEY into an ApiKeyCredential:
REST Client Runtime Methods (All Require await)
Metrics fields are authoritative in the source:RuntimeMetricsusesnum_running_boxes / boxes_created_total / boxes_failed_total / total_commands_executed / total_exec_errors;BoxMetricsusesmemory_bytes / cpu_percent(notmemory_usage_bytes / cpu_time_ms).
Accessing State (Common Pitfall)
BoxInfo.state (a BoxStateInfo), and the inner field is status (a string). Both levels must be written correctly.

