cpuos

Integration · Tool

Jupyter with cpuos sandboxes

Run JupyterLab in a cpuos sandbox: a live notebook the user can open while the agent analyzes data, isolated in a microVM.

SDK
@cpuos/sdk · pip install cpuos
Model endpoint
https://gpuos.si/v1 or any OpenAI-compatible
Status
Early access

A notebook in the sandbox

Data analysis agents work best when people can see the work. Start JupyterLab in the python template, expose its port, and the user opens the agent's notebook at a private HTTPS URL while the agent keeps working in the same sandbox.

Python
import secretsfrom cpuos import Sandboxsbx = Sandbox.create(template="python", timeout="1h")sbx.exec("uv pip install --system jupyterlab", timeout="5m")token = secrets.token_urlsafe(24)sbx.exec(    "jupyter lab --ip=0.0.0.0 --port=8888 --no-browser "    f"--IdentityProvider.token={token} --notebook-dir=/work",    background=True,)print(f"{sbx.url(8888)}/lab?token={token}")

Always set a token. The URL is private to your sandbox, but a notebook server is remote code execution by design, so treat the link like a password. For a template that starts faster, bake JupyterLab into a custom template.

cpuos is in early access: @cpuos/sdk (npm) and cpuos (PyPI) ship to early-access teams first, and read the API key from CPUOS_API_KEY. The calls on this page show the current API shape.

Let the agent write notebooks

Instead of loose scripts, the agent can append cells to /work/analysis.ipynb and execute the notebook with jupyter nbconvert --to notebook --execute --inplace. The result is a notebook with code, outputs and charts that the user can open, read and rerun.

Python
run = sbx.exec(    "cd /work && jupyter nbconvert --to notebook --execute --inplace analysis.ipynb",    timeout="5m",)if run.exit_code != 0:    feedback = run.stderr[-3000:]  # send the traceback back to the model

The model that writes the cells can run on your own GPUs: point the OpenAI Python SDK at gpuOS and keep the loop from the code interpreter guide.

Official documentation: jupyter.org

Questions

Do variables persist between agent steps?
With exec and plain scripts, each step is a new process. A running Jupyter kernel keeps variables in memory, and pausing the sandbox keeps the kernel alive until you resume.
Is the notebook URL public?
It is reachable over HTTPS at a URL unique to the sandbox. Protect it with the Jupyter token and share it only with the user who owns the session.
Can I use plain Jupyter Notebook instead of JupyterLab?
Yes. Install the notebook package and start it the same way on a port, then open sbx.url(port).

Related

Run Jupyter tool calls in a sandbox

cpuos is in early access: a Firecracker microVM per task, hosted in the EU or on your servers, billed per second and free while paused.

gpuOS · where models think

Need the model too? Run it on gpuOS

gpuOS serves open models on your own GPUs behind one OpenAI-compatible API. The model reasons on gpuOS, the agent acts in a cpuOS sandbox.