Skip to content

Getting started with the SDK

About

Use the Capsem SDK to create a VM, run commands, and inspect its activity from your application.

Installation

Requires Python 3.11 or later.

Terminal window
python -m pip install capsem

Install Capsem and start it on your computer before using the SDK.

Usage

Once Capsem is running, create a VM and run a command inside it. Use an unused VM name in place of sdk-demo.

Run these direct-await statements in a notebook or IPython.

from capsem import Hypervisor
capsem = Hypervisor()
vm = await capsem.create(name="sdk-demo", image="claude-code")
result = await vm.exec("echo hello", timeout_secs=60)
print(result)
await vm.stop()
await capsem.close()

name keeps the VM for later use: stopping it preserves your work so you can start it again or duplicate it. image selects a Capsem prebuilt container image or your own OCI image when permitted by your administrator. Learn about image selection.

The example runs echo hello, displays its output, and leaves sdk-demo stopped with its work preserved.

For more, use the SDK guides or the Python SDK reference.