Skip to main content
Wrenn runs your code inside isolated virtual machines called capsules. This guide walks you through installing the SDK, authenticating, and running your first command — all in a few minutes.
The Wrenn SDK requires Python 3.13 or later.
1

Install the SDK

Install the wrenn package from PyPI:
pip install wrenn
2

Set your API key

Generate an API key from the Wrenn dashboard and export it as an environment variable:
export WRENN_API_KEY="wrn_your_api_key_here"
The SDK reads WRENN_API_KEY automatically — you don’t need to pass it in code.
Pass wait=True when creating a capsule to block until it reaches the running state before you start sending commands.
3

Create a capsule and run a command

Use Capsule as a context manager. When the with block exits, the capsule is automatically destroyed.
from wrenn import Capsule

with Capsule(template="minimal", wait=True) as capsule:
    result = capsule.commands.run("echo hello")
    print(result.stdout)   # "hello\n"
    print(result.exit_code)  # 0
capsule.commands.run() runs the command in the foreground and returns a result with stdout, stderr, exit_code, and duration_ms.
4

Try the code interpreter

For stateful Python execution backed by a persistent Jupyter kernel, use wrenn.code_interpreter:
from wrenn.code_interpreter import Capsule

with Capsule(wait=True) as capsule:
    result = capsule.run_code("print('hello')")
    print("".join(result.logs.stdout))  # "hello\n"
Variables, imports, and function definitions persist across run_code calls within the same capsule session.