Skip to main content
A capsule is an isolated Firecracker microVM managed by Wrenn. Each capsule gets its own kernel, filesystem, and network namespace, so code running inside one capsule cannot affect any other. You interact with capsules through the Capsule class in the Python SDK — creating them, running commands, reading files, and opening terminals — then destroy them when you’re done.

Creating a capsule

The simplest way to create a capsule is to construct a Capsule directly. The SDK reads your API key from the WRENN_API_KEY environment variable and starts the capsule immediately.
You can pass configuration parameters at creation time:
The wait=True parameter blocks until the capsule reaches running status before returning:
Capsule.create() is a classmethod that is exactly equivalent to calling Capsule() directly:

Context manager

Use a capsule as a context manager to ensure it is destroyed automatically when the block exits, even if an exception is raised:

Connecting to an existing capsule

Attach to a capsule that is already running (or paused) using its ID. If the capsule is paused, connect resumes it automatically before returning.
Capsule IDs always start with the cl- prefix (for example, cl-abc123).

Listing and inspecting capsules

On an instance, get_info() refreshes and returns the latest metadata:

Destroying a capsule

Destroying a capsule is permanent. All data on the capsule’s filesystem is deleted.

What’s next

Lifecycle

Pause, resume, and monitor capsule state.

Commands

Run foreground, background, and streaming commands.

Filesystem

Read, write, and stream files inside a capsule.

Terminal

Open interactive PTY sessions inside a capsule.