Skip to main content

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. This example targets Capsem 0.7.1. Until its Python package is published, install the SDK from the 0.7.1 source revision; PyPI's capsem 0.3.2 does not provide this API.

python -m pip install "capsem @ git+https://github.com/google/capsem.git@3c17b44f7a4c0457cb4b168df829daf293415c12#subdirectory=sdk/python"

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

Usage

Hypervisor() connects to Capsem running on your computer without requiring you to copy a gateway URL or token.

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.

Pass labels={"suite": "eval"} to create(...) to attach advisory metadata. VM inventory includes those labels. Forks inherit them by default; fork(name, labels={}) clears them and a nonempty map replaces them.

Use managed scopes to remove temporary VMs automatically. Look up methods and options in the Python SDK reference, and handle failed commands with Errors and recovery.

Metadata

Release files for capsem 0.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for capsem 0.7.2
File Size Uploaded Provenance Actions
capsem-0.7.2.tar.gz 193.8 kB Without provenance Details for capsem-0.7.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for capsem 0.7.2
File Interpreter ABI Platform Actions
capsem-0.7.2-py3-none-any.whl Python 3 none any Details for capsem-0.7.2-py3-none-any.whl

Total release size: 370.3 kB

Release files / capsem-0.7.2.tar.gz

Download URL capsem-0.7.2.tar.gz
Size 193.8 kB
Tags Source
SHA-256 checksum
How to use checksums
68c25dbb24685e1ff505399e50e264c915d84b727fad7f9bd89aa26a70c53364
BLAKE2b-256 checksum
How to use checksums
2adb5f09a8fd65ea6ea51384a339695f6ddc18c5c4283ad01626642072af5432
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / capsem-0.7.2-py3-none-any.whl

Download URL capsem-0.7.2-py3-none-any.whl
Size 176.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcb51527de9537ece6c896ed3bd55423ca454b32434b2fefcaba822690e1d3c9
BLAKE2b-256 checksum
How to use checksums
8809ee3a2e27d9376a37d1b874f4c8a4900196c0c0f8a52dc820ff95ab14293e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for capsem 0.7.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page