Devbox¶
Asynchronous devbox resource class.
- class runloop_api_client.sdk.async_devbox.AsyncDevbox(client, devbox_id)[source]¶
High-level async interface for managing a Runloop devbox.
This class provides a Pythonic, awaitable API for interacting with devboxes, including command execution, file operations, networking, and lifecycle management.
Example
>>> devbox = await runloop.devbox.create(name="my-devbox") >>> async with devbox: ... result = await devbox.cmd.exec("echo 'hello'") ... print(await result.stdout()) # Devbox is automatically shut down on exit
- async get_info(**options)[source]¶
Retrieve current devbox status and metadata.
- Parameters:
options (
Unpack[BaseRequestOptions]) – Optional request configuration- Returns:
Current devbox state info
- Return type:
- async get_tunnel(**options)[source]¶
Retrieve the V2 tunnel information for this devbox.
- Parameters:
options (Unpack[BaseRequestOptions]) – Optional request configuration
- Returns:
Tunnel details if a tunnel is enabled, None otherwise
- Return type:
TunnelView | None
Example
>>> tunnel = await devbox.get_tunnel() >>> if tunnel: ... print(f"Tunnel key: {tunnel.tunnel_key}")
- async get_tunnel_url(port, **options)[source]¶
Get the public tunnel URL for a specific port.
Constructs the tunnel URL using the format:
https://{port}-{tunnel_key}.tunnel.runloop.ai- Parameters:
port (int) – The port number to construct the URL for
options (Unpack[BaseRequestOptions]) – Optional request configuration
- Returns:
The public tunnel URL if a tunnel is enabled, None otherwise
- Return type:
str | None
Example
>>> url = await devbox.get_tunnel_url(8080) >>> if url: ... print(f"Access your service at: {url}")
- async logs(*, execution_id=None, shell_name=None, **options)[source]¶
Retrieve logs for the devbox.
Returns all logs from a running or completed devbox. Optionally filter by execution ID or shell name.
- Parameters:
- Returns:
Log entries for the devbox
- Return type:
Example
>>> logs = await devbox.logs() >>> for log in logs.logs: ... print(f"[{log.level}] {log.message}")
- async await_running(*, polling_config=None)[source]¶
Wait for the devbox to reach running state.
- Parameters:
polling_config (PollingConfig | None, optional) – Optional polling behavior overrides, defaults to None
- Returns:
Devbox state info after it reaches running status
- Return type:
- async await_suspended(*, polling_config=None)[source]¶
Wait for the devbox to reach suspended state.
- Parameters:
polling_config (PollingConfig | None, optional) – Optional polling behavior overrides, defaults to None
- Returns:
Devbox state info after it reaches suspended status
- Return type:
- async shutdown(**options)[source]¶
Shutdown the devbox, terminating all processes and releasing resources.
- Parameters:
options (
Unpack[LongRequestOptions]) – Optional long-running request configuration- Returns:
Final devbox state info
- Return type:
- async suspend(**options)[source]¶
Suspend the devbox without destroying state.
Returns immediately after issuing the suspend request. Call
await_suspended()if you need to wait for the devbox to reach thesuspendedstate (contrast with the synchronous SDK, which blocks).- Parameters:
options (
Unpack[LongRequestOptions]) – Optional long-running request configuration- Returns:
Suspended devbox state info
- Return type:
- async resume(*, polling_config=None, **options)[source]¶
Resume a suspended devbox, restoring it to running state.
Waits for the devbox to reach running state before returning.
- Parameters:
polling_config (PollingConfig | None, optional) – Optional polling behavior overrides, defaults to None
options (Unpack[LongRequestOptions]) – Optional long-running request configuration
- Returns:
Resumed devbox state info
- Return type:
- async resume_async(**options)[source]¶
Resume a suspended devbox without waiting for it to reach running state.
Initiates the resume operation and returns immediately. Use
await_running()to wait for the devbox to reach running state if needed.- Parameters:
options (
Unpack[LongRequestOptions]) – Optional long-running request configuration- Returns:
Devbox state info immediately after resume request
- Return type:
- async keep_alive(**options)[source]¶
Extend the devbox timeout, preventing automatic shutdown.
Call this periodically for long-running workflows to prevent the devbox from being automatically shut down due to inactivity.
- Parameters:
options (
Unpack[LongRequestOptions]) – Optional long-running request configuration- Returns:
Response confirming the keep-alive request
- Return type:
- async snapshot_disk(**params)[source]¶
Create a disk snapshot of the devbox and wait for completion.
Captures the current state of the devbox disk, which can be used to create new devboxes with the same state.
- Parameters:
params (
Unpack[SDKDevboxSnapshotDiskParams]) – SeeSDKDevboxSnapshotDiskParamsfor available parameters- Returns:
Wrapper representing the completed snapshot
- Return type:
- async snapshot_disk_async(**params)[source]¶
Create a disk snapshot of the devbox asynchronously.
Starts the snapshot creation process and returns immediately without waiting for completion. Use snapshot.await_completed() to wait for completion.
- Parameters:
params (
Unpack[SDKDevboxSnapshotDiskAsyncParams]) – SeeSDKDevboxSnapshotDiskAsyncParamsfor available parameters- Returns:
Wrapper representing the snapshot request
- Return type:
- async close()[source]¶
Alias for
shutdown()to support common resource patterns.- Return type:
- property cmd: AsyncCommandInterface¶
Return the command execution interface.
- Returns:
Helper for running shell commands
- Return type:
- property file: AsyncFileInterface¶
Return the file operations interface.
- Returns:
Helper for reading/writing files
- Return type:
- property net: AsyncNetworkInterface¶
Return the networking interface.
- Returns:
Helper for SSH keys and tunnels
- Return type:
- shell(shell_name=None)[source]¶
Create a named shell instance for stateful command execution.
Named shells are stateful and maintain environment variables and the current working directory (CWD) across commands, just like a real shell on your local computer. Commands executed through the same named shell instance will execute sequentially - the shell can only run one command at a time with automatic queuing. This ensures that environment changes and directory changes from one command are preserved for the next command.
- Parameters:
shell_name (str | None, optional) – The name of the persistent shell session. If not provided, a UUID will be generated automatically.
- Returns:
An AsyncNamedShell instance for executing commands in the named shell
- Return type:
Example
>>> # Create a named shell with a custom name >>> shell = await devbox.shell("my-session") >>> # Create a named shell with an auto-generated UUID name >>> shell2 = await devbox.shell() >>> # Commands execute sequentially and share state >>> await shell.exec("cd /app") >>> await shell.exec("export MY_VAR=value") >>> result = await shell.exec("echo $MY_VAR") # Will output 'value' >>> result = await shell.exec("pwd") # Will output '/app'
- class runloop_api_client.sdk.async_devbox.AsyncCommandInterface(devbox)[source]¶
Interface for executing commands on a devbox.
Accessed via devbox.cmd property. Provides exec() for synchronous execution and exec_async() for asynchronous execution with process management.
- async exec(command, **params)[source]¶
Execute a command synchronously and wait for completion.
- Parameters:
params (
Unpack[SDKDevboxExecuteParams]) – SeeSDKDevboxExecuteParamsfor available parameters- Returns:
Wrapper with exit status and output helpers
- Return type:
Example
>>> result = await devbox.cmd.exec("echo 'hello'") >>> print(await result.stdout()) >>> print(f"Exit code: {result.exit_code}")
- async exec_async(command, **params)[source]¶
Execute a command asynchronously without waiting for completion.
Starts command execution and returns immediately with an AsyncExecution object for process management. Use execution.result() to wait for completion or execution.kill() to terminate the process.
- Parameters:
params (
Unpack[SDKDevboxExecuteAsyncParams]) – SeeSDKDevboxExecuteAsyncParamsfor available parameters- Returns:
Handle for managing the running process
- Return type:
Example
>>> execution = await devbox.cmd.exec_async("sleep 10") >>> state = await execution.get_state() >>> print(f"Status: {state.status}") >>> await execution.kill() # Terminate early if needed
- class runloop_api_client.sdk.async_devbox.AsyncFileInterface(devbox)[source]¶
Interface for file operations on a devbox.
Accessed via devbox.file property. Provides coroutines for reading, writing, uploading, and downloading files.
- async read(**params)[source]¶
Read a file from the devbox.
- Parameters:
params (
Unpack[SDKDevboxReadFileContentsParams]) – SeeSDKDevboxReadFileContentsParamsfor available parameters- Returns:
File contents
- Return type:
Example
>>> content = await devbox.file.read(path="/home/user/data.txt") >>> print(content)
- async write(**params)[source]¶
Write contents to a file in the devbox.
Creates or overwrites the file at the specified path.
- Parameters:
params (
Unpack[SDKDevboxWriteFileContentsParams]) – SeeSDKDevboxWriteFileContentsParamsfor available parameters- Returns:
Execution metadata for the write command
- Return type:
Example
>>> await devbox.file.write(file_path="/home/user/config.json", contents='{"key": "value"}')
- async download(**params)[source]¶
Download a file from the devbox.
- Parameters:
params (
Unpack[SDKDevboxDownloadFileParams]) – SeeSDKDevboxDownloadFileParamsfor available parameters- Returns:
Raw file contents
- Return type:
Example
>>> data = await devbox.file.download(path="/home/user/output.bin") >>> with open("local_output.bin", "wb") as f: ... f.write(data)
- async upload(**params)[source]¶
Upload a file to the devbox.
- Parameters:
params (
Unpack[SDKDevboxUploadFileParams]) – SeeSDKDevboxUploadFileParamsfor available parameters- Returns:
API response confirming the upload
- Return type:
Example
>>> from pathlib import Path >>> await devbox.file.upload(path="/home/user/data.csv", file=Path("local_data.csv"))
- class runloop_api_client.sdk.async_devbox.AsyncNamedShell(devbox, shell_name)[source]¶
Interface for executing commands in a persistent, stateful shell session.
Named shells are stateful and maintain environment variables and the current working directory (CWD) across commands. Commands executed through the same named shell instance will execute sequentially - the shell can only run one command at a time with automatic queuing. This ensures that environment changes and directory changes from one command are preserved for the next command.
Use
AsyncDevbox.shell()to create a named shell instance. If you use the same shell name, it will re-attach to the existing named shell, preserving its state.Example
>>> shell = await devbox.shell("my-session") >>> await shell.exec("cd /app") >>> await shell.exec("export MY_VAR=value") >>> result = await shell.exec("echo $MY_VAR") # Will output 'value' >>> result = await shell.exec("pwd") # Will output '/app'
- async exec(command, **params)[source]¶
Execute a command in the named shell and wait for it to complete.
The command will execute in the persistent shell session, maintaining environment variables and the current working directory from previous commands. Commands are queued and execute sequentially - only one command runs at a time in the named shell.
Optionally provide callbacks to stream logs in real-time. When callbacks are provided, this method waits for both the command to complete AND all streaming data to be processed before returning.
- Parameters:
command (str) – The command to execute
params (
Unpack[SDKDevboxExecuteParams]) – SeeSDKDevboxExecuteParamsfor available parameters
- Returns:
Wrapper with exit status and output helpers
- Return type:
Example
>>> shell = await devbox.shell("my-session") >>> result = await shell.exec("ls -la") >>> print(await result.stdout()) >>> # With streaming callbacks >>> result = await shell.exec("npm install", stdout=lambda line: print(f"[LOG] {line}"))
- async exec_async(command, **params)[source]¶
Execute a command in the named shell asynchronously without waiting for completion.
The command will execute in the persistent shell session, maintaining environment variables and the current working directory from previous commands. Commands are queued and execute sequentially - only one command runs at a time in the named shell.
Optionally provide callbacks to stream logs in real-time as they are produced. Callbacks fire in real-time as logs arrive. When you call execution.result(), it will wait for both the command to complete and all streaming to finish.
- Parameters:
command (str) – The command to execute
params (
Unpack[SDKDevboxExecuteAsyncParams]) – SeeSDKDevboxExecuteAsyncParamsfor available parameters
- Returns:
Handle for managing the running process
- Return type:
Example
>>> shell = await devbox.shell("my-session") >>> execution = await shell.exec_async("long-running-task.sh", stdout=lambda line: print(f"[LOG] {line}")) >>> # Do other work while command runs... >>> result = await execution.result() >>> if result.success: ... print("Task completed successfully!")
- class runloop_api_client.sdk.async_devbox.AsyncNetworkInterface(devbox)[source]¶
Interface for networking operations on a devbox.
Accessed via devbox.net property. Provides coroutines for SSH access and tunneling.
- async create_ssh_key(**options)[source]¶
Create an SSH key for remote access to the devbox.
- Parameters:
options (
Unpack[LongRequestOptions]) – Optional long-running request configuration- Returns:
Response containing SSH connection info
- Return type:
Example
>>> ssh_key = await devbox.net.create_ssh_key() >>> print(f"SSH URL: {ssh_key.url}")
- async enable_tunnel(**params)[source]¶
Enable a V2 tunnel for secure HTTP access to the devbox.
V2 tunnels provide encrypted URL-based access without exposing internal IDs. Each devbox can have one tunnel. The tunnel URL format is:
https://{port}-{tunnel_key}.tunnel.runloop.ai- Parameters:
params (
Unpack[SDKDevboxEnableTunnelParams]) – SeeSDKDevboxEnableTunnelParamsfor available parameters- Returns:
Tunnel details including the tunnel key for constructing URLs
- Return type:
Example
>>> tunnel = await devbox.net.enable_tunnel(auth_mode="open") >>> print(f"Tunnel key: {tunnel.tunnel_key}") >>> # Access via: https://8080-{tunnel.tunnel_key}.tunnel.runloop.ai
- async remove_tunnel(**params)[source]¶
Remove a tunnel from the devbox.
- Parameters:
params (
Unpack[SDKDevboxRemoveTunnelParams]) – SeeSDKDevboxRemoveTunnelParamsfor available parameters- Returns:
Response confirming the tunnel removal
- Return type:
Example
>>> await devbox.net.remove_tunnel()
Synchronous devbox resource class.
- class runloop_api_client.sdk.devbox.Devbox(client, devbox_id)[source]¶
High-level interface for managing a Runloop devbox.
This class provides a Pythonic, object-oriented API for interacting with devboxes, including command execution, file operations, networking, and lifecycle management.
The Devbox class supports context manager protocol for automatic cleanup.
Example
>>> with runloop.devbox.create(name="my-devbox") as devbox: ... result = devbox.cmd.exec("echo 'hello'") ... print(result.stdout()) # Devbox is automatically shutdown on exit
- get_info(**options)[source]¶
Retrieve current devbox status and metadata.
- Parameters:
options (
Unpack[BaseRequestOptions]) – Optional request configuration- Returns:
Current devbox state info
- Return type:
- get_tunnel(**options)[source]¶
Retrieve the V2 tunnel information for this devbox.
- Parameters:
options (Unpack[BaseRequestOptions]) – Optional request configuration
- Returns:
Tunnel details if a tunnel is enabled, None otherwise
- Return type:
TunnelView| None
Example
>>> tunnel = devbox.get_tunnel() >>> if tunnel: ... print(f"Tunnel key: {tunnel.tunnel_key}")
- get_tunnel_url(port, **options)[source]¶
Get the public tunnel URL for a specific port.
Constructs the tunnel URL using the format:
https://{port}-{tunnel_key}.tunnel.runloop.ai- Parameters:
port (int) – The port number to construct the URL for
options (Unpack[BaseRequestOptions]) – Optional request configuration
- Returns:
The public tunnel URL if a tunnel is enabled, None otherwise
- Return type:
str | None
Example
>>> url = devbox.get_tunnel_url(8080) >>> if url: ... print(f"Access your service at: {url}")
- logs(*, execution_id=None, shell_name=None, **options)[source]¶
Retrieve logs for the devbox.
Returns all logs from a running or completed devbox. Optionally filter by execution ID or shell name.
- Parameters:
- Returns:
Log entries for the devbox
- Return type:
Example
>>> logs = devbox.logs() >>> for log in logs.logs: ... print(f"[{log.level}] {log.message}")
- await_running(*, polling_config=None)[source]¶
Wait for the devbox to reach running state.
Blocks until the devbox is running or the polling timeout is reached.
- Parameters:
polling_config (PollingConfig | None, optional) – Optional configuration for polling behavior (timeout, interval), defaults to None
- Returns:
Devbox state info after it reaches running status
- Return type:
- await_suspended(*, polling_config=None)[source]¶
Wait for the devbox to reach suspended state.
Blocks until the devbox is suspended or the polling timeout is reached.
- Parameters:
polling_config (PollingConfig | None, optional) – Optional configuration for polling behavior (timeout, interval), defaults to None
- Returns:
Devbox state info after it reaches suspended status
- Return type:
- shutdown(**options)[source]¶
Shutdown the devbox, terminating all processes and releasing resources.
- Parameters:
options (
Unpack[LongRequestOptions]) – Long-running request configuration (timeouts, retries, etc.)- Returns:
Final devbox state info
- Return type:
- suspend(**options)[source]¶
Suspend the devbox, pausing execution while preserving state.
This saves resources while maintaining the devbox state for later resumption. Waits for the devbox to reach suspended state before returning.
- Parameters:
options (
Unpack[LongPollingRequestOptions]) – Optional long-running request and polling configuration- Returns:
Suspended devbox state info
- Return type:
- resume(**options)[source]¶
Resume a suspended devbox, restoring it to running state.
Waits for the devbox to reach running state before returning.
- Parameters:
options (
Unpack[LongPollingRequestOptions]) – Optional long-running request and polling configuration- Returns:
Resumed devbox state info
- Return type:
- resume_async(**options)[source]¶
Resume a suspended devbox without waiting for it to reach running state.
Initiates the resume operation and returns immediately. Use
await_running()to wait for the devbox to reach running state if needed.- Parameters:
options (
Unpack[LongRequestOptions]) – Optional long-running request configuration- Returns:
Devbox state info immediately after resume request
- Return type:
- keep_alive(**options)[source]¶
Extend the devbox timeout, preventing automatic shutdown.
Call this periodically for long-running workflows to prevent the devbox from being automatically shut down due to inactivity.
- Parameters:
options (
Unpack[LongRequestOptions]) – Optional long-running request configuration- Returns:
Response confirming the keep-alive request
- Return type:
- snapshot_disk(**params)[source]¶
Create a disk snapshot of the devbox and wait for completion.
Captures the current state of the devbox disk, which can be used to create new devboxes with the same state.
- Parameters:
params (
Unpack[SDKDevboxSnapshotDiskParams]) – SeeSDKDevboxSnapshotDiskParamsfor available parameters- Returns:
Wrapper representing the completed snapshot
- Return type:
- snapshot_disk_async(**params)[source]¶
Create a disk snapshot of the devbox asynchronously.
Starts the snapshot creation process and returns immediately without waiting for completion. Use snapshot.await_completed() to wait for completion.
- Parameters:
params (
Unpack[SDKDevboxSnapshotDiskAsyncParams]) – SeeSDKDevboxSnapshotDiskAsyncParamsfor available parameters- Returns:
Wrapper representing the snapshot (may still be processing)
- Return type:
- close()[source]¶
Alias for
shutdown()to support common resource patterns.- Return type:
- property cmd: CommandInterface¶
Return the command execution interface.
- Returns:
Helper for running shell commands
- Return type:
- property file: FileInterface¶
Return the file operations interface.
- Returns:
Helper for reading/writing files
- Return type:
- property net: NetworkInterface¶
Return the networking interface.
- Returns:
Helper for SSH keys and tunnels
- Return type:
- shell(shell_name=None)[source]¶
Create a named shell instance for stateful command execution.
Named shells are stateful and maintain environment variables and the current working directory (CWD) across commands, just like a real shell on your local computer. Commands executed through the same named shell instance will execute sequentially - the shell can only run one command at a time with automatic queuing. This ensures that environment changes and directory changes from one command are preserved for the next command.
- Parameters:
shell_name (str | None, optional) – The name of the persistent shell session. If not provided, a UUID will be generated automatically.
- Returns:
A NamedShell instance for executing commands in the named shell
- Return type:
Example
>>> # Create a named shell with a custom name >>> shell = devbox.shell("my-session") >>> # Create a named shell with an auto-generated UUID name >>> shell2 = devbox.shell() >>> # Commands execute sequentially and share state >>> shell.exec("cd /app") >>> shell.exec("export MY_VAR=value") >>> result = shell.exec("echo $MY_VAR") # Will output 'value' >>> result = shell.exec("pwd") # Will output '/app'
- class runloop_api_client.sdk.devbox.CommandInterface(devbox)[source]¶
Interface for executing commands on a devbox.
Accessed via devbox.cmd property. Provides exec() for synchronous execution and exec_async() for asynchronous execution with process management.
- exec(command, **params)[source]¶
Execute a command synchronously and wait for completion.
- Parameters:
params (
Unpack[SDKDevboxExecuteParams]) – SeeSDKDevboxExecuteParamsfor available parameters- Returns:
Wrapper with exit status and output helpers
- Return type:
Example
>>> result = devbox.cmd.exec("ls -la") >>> print(result.stdout()) >>> print(f"Exit code: {result.exit_code}")
- exec_async(command, **params)[source]¶
Execute a command asynchronously without waiting for completion.
Starts command execution and returns immediately with an Execution object for process management. Use execution.result() to wait for completion or execution.kill() to terminate the process.
- Parameters:
params (
Unpack[SDKDevboxExecuteAsyncParams]) – SeeSDKDevboxExecuteAsyncParamsfor available parameters- Returns:
Handle for managing the running process
- Return type:
Example
>>> execution = devbox.cmd.exec_async("sleep 10") >>> state = execution.get_state() >>> print(f"Status: {state.status}") >>> execution.kill() # Terminate early if needed
- class runloop_api_client.sdk.devbox.FileInterface(devbox)[source]¶
Interface for file operations on a devbox.
Accessed via devbox.file property. Provides methods for reading, writing, uploading, and downloading files.
- read(**params)[source]¶
Read a file from the devbox.
- Parameters:
params (
Unpack[SDKDevboxReadFileContentsParams]) – SeeSDKDevboxReadFileContentsParamsfor available parameters- Returns:
File contents
- Return type:
Example
>>> content = devbox.file.read("/home/user/data.txt") >>> print(content)
- write(**params)[source]¶
Write contents to a file in the devbox.
Creates or overwrites the file at the specified path.
- Parameters:
params (
Unpack[SDKDevboxWriteFileContentsParams]) – SeeSDKDevboxWriteFileContentsParamsfor available parameters- Returns:
Execution metadata for the write command
- Return type:
Example
>>> devbox.file.write(file_path="/home/user/config.json", contents='{"key": "value"}')
- download(**params)[source]¶
Download a file from the devbox.
- Parameters:
params (
Unpack[SDKDevboxDownloadFileParams]) – SeeSDKDevboxDownloadFileParamsfor available parameters- Returns:
Raw file contents
- Return type:
Example
>>> data = devbox.file.download("/home/user/output.bin") >>> with open("local_output.bin", "wb") as f: ... f.write(data)
- upload(**params)[source]¶
Upload a file to the devbox.
- Parameters:
params (
Unpack[SDKDevboxUploadFileParams]) – SeeSDKDevboxUploadFileParamsfor available parameters- Returns:
API response confirming the upload
- Return type:
Example
>>> from pathlib import Path >>> devbox.file.upload("/home/user/data.csv", Path("local_data.csv"))
- class runloop_api_client.sdk.devbox.NamedShell(devbox, shell_name)[source]¶
Interface for executing commands in a persistent, stateful shell session.
Named shells are stateful and maintain environment variables and the current working directory (CWD) across commands. Commands executed through the same named shell instance will execute sequentially - the shell can only run one command at a time with automatic queuing. This ensures that environment changes and directory changes from one command are preserved for the next command.
Use
Devbox.shell()to create a named shell instance. If you use the same shell name, it will re-attach to the existing named shell, preserving its state.Example
>>> shell = devbox.shell("my-session") >>> shell.exec("cd /app") >>> shell.exec("export MY_VAR=value") >>> result = shell.exec("echo $MY_VAR") # Will output 'value' >>> result = shell.exec("pwd") # Will output '/app'
- exec(command, **params)[source]¶
Execute a command in the named shell and wait for it to complete.
The command will execute in the persistent shell session, maintaining environment variables and the current working directory from previous commands. Commands are queued and execute sequentially - only one command runs at a time in the named shell.
Optionally provide callbacks to stream logs in real-time. When callbacks are provided, this method waits for both the command to complete AND all streaming data to be processed before returning.
- Parameters:
command (str) – The command to execute
params (
Unpack[SDKDevboxExecuteParams]) – SeeSDKDevboxExecuteParamsfor available parameters
- Returns:
Wrapper with exit status and output helpers
- Return type:
Example
>>> shell = devbox.shell("my-session") >>> result = shell.exec("ls -la") >>> print(result.stdout()) >>> # With streaming callbacks >>> result = shell.exec("npm install", stdout=lambda line: print(f"[LOG] {line}"))
- exec_async(command, **params)[source]¶
Execute a command in the named shell asynchronously without waiting for completion.
The command will execute in the persistent shell session, maintaining environment variables and the current working directory from previous commands. Commands are queued and execute sequentially - only one command runs at a time in the named shell.
Optionally provide callbacks to stream logs in real-time as they are produced. Callbacks fire in real-time as logs arrive. When you call execution.result(), it will wait for both the command to complete and all streaming to finish.
- Parameters:
command (str) – The command to execute
params (
Unpack[SDKDevboxExecuteAsyncParams]) – SeeSDKDevboxExecuteAsyncParamsfor available parameters
- Returns:
Handle for managing the running process
- Return type:
Example
>>> shell = devbox.shell("my-session") >>> execution = shell.exec_async("long-running-task.sh", stdout=lambda line: print(f"[LOG] {line}")) >>> # Do other work while command runs... >>> result = execution.result() >>> if result.success: ... print("Task completed successfully!")
- class runloop_api_client.sdk.devbox.NetworkInterface(devbox)[source]¶
Interface for network operations on a devbox.
Accessed via devbox.net property. Provides methods for SSH access and tunneling.
- create_ssh_key(**options)[source]¶
Create an SSH key for remote access to the devbox.
- Parameters:
options (
Unpack[LongRequestOptions]) – Optional long-running request configuration- Returns:
Response containing SSH connection info
- Return type:
Example
>>> ssh_key = devbox.net.create_ssh_key() >>> print(f"SSH URL: {ssh_key.url}")
- enable_tunnel(**params)[source]¶
Enable a V2 tunnel for secure HTTP access to the devbox.
V2 tunnels provide encrypted URL-based access without exposing internal IDs. Each devbox can have one tunnel. The tunnel URL format is:
https://{port}-{tunnel_key}.tunnel.runloop.ai- Parameters:
params (
Unpack[SDKDevboxEnableTunnelParams]) – SeeSDKDevboxEnableTunnelParamsfor available parameters- Returns:
Tunnel details including the tunnel key for constructing URLs
- Return type:
Example
>>> tunnel = devbox.net.enable_tunnel(auth_mode="open") >>> print(f"Tunnel key: {tunnel.tunnel_key}") >>> # Access via: https://8080-{tunnel.tunnel_key}.tunnel.runloop.ai
- remove_tunnel(**params)[source]¶
Remove a tunnel from the devbox.
- Parameters:
params (
Unpack[SDKDevboxRemoveTunnelParams]) – SeeSDKDevboxRemoveTunnelParamsfor available parameters- Returns:
Response confirming the tunnel removal
- Return type:
Example
>>> devbox.net.remove_tunnel()