Docs

Sandboxes

Start an isolated container, run commands or code in it, read and write its files, then terminate it.

For agents: this page as markdown

Create a sandbox

A sandbox is a container you drive from your code: useful for running code an LLM wrote or a player uploaded, apart from everything else. Every customer's work runs sandboxed, apart from other customers and from the machine.

from klio_compute import Sandbox, Image

sandbox = Sandbox(cpu=1, memory="1Gi", image=Image(python_version="python3.12")).create()
try:
    result = sandbox.process.run_code("print(2 + 2)")
    print(result.result)
finally:
    sandbox.terminate()

sandbox.process.exec(...) runs a command, and sandbox.fs uploads and downloads files. A sandbox can have a GPU with gpu=. You pay for the seconds it runs; terminate() stops it.

© 2026 Klio