This page needs JavaScript. For agents, the same page as Markdown: https://instabox.sh/blog/python-sdk.md (below); the whole site: https://instabox.sh/llms.txt.

# InstaBox in Python

https://instabox.sh/blog/python-sdk.md

2026-11-07 · Tony Chang · Product

Run pip install instabox-sdk and drive InstaBox from Python. Create a box, run commands in it, move files and folders, pause it, snapshot it and delete it.

InstaBox now has a Python SDK. Run `pip install instabox-sdk`, and your code can create boxes and work in them.

![A terminal: pip install instabox-sdk installs version 0.4.0, then a six-line script creates a box, runs python3 in it, prints the exit code and output 0 42, and deletes the box](https://instabox.sh/blog/images/2026-11-07-python-sdk/python-sdk.webp)

**Why**

Most agent code is Python. Until now it had to call the CLI or the API by hand.

**Get started**

```sh
pip install instabox-sdk
export INSTABOX_API_KEY=ibk_...
```

```python
from instabox import Client

client = Client()
box = client.machines.create(name="py-demo")
r = client.machines.exec(box.id, "python3 -c 'print(6 * 7)'")
print(r.exit_code, r.stdout)  # 0 42
client.machines.delete(box.id)
```

**What you get**

- **The whole lifecycle.** Create, pause, resume, stop, start, restore and delete. Each call waits until it's done.
- **Commands with results.** `exec` returns stdout, stderr and the exit code. A failing command doesn't raise.
- **Files and folders.** Stream big files, and copy a whole folder in one call.
- **Pick up where you left off.** `ensure_running` starts or resumes a box, whatever its state.
- **Snapshots.** Save a box and create new ones from it.
- **Typed errors.** Catch exactly the errors you expect.

Python 3.9 and newer. See the [Python SDK docs](https://instabox.sh/docs/reference/python-sdk).

We'd love to hear what you think! Email us at [support@instabox.sh](mailto:support@instabox.sh), or join our [Discord](https://discord.gg/instabox).