Tag each step
Send the step ID with each request. Later, get all the events of that step.
GET /v1/events?step_id=report.3● Works today
Give your chat model or workflow a run-code tool. Each call runs in its own microVM on your servers, and you get back stdout, stderr and the exit code. The code cannot reach your app, your keys or your network.
Any language you install in the template
Each step shows the call, the reply and the lines it adds to the activity log. You can read the whole log withGET /v1/sandboxes/$S/events.
YOUR APP
Your chat app or workflow engine gets a tool call with code in it. Treat that code as untrusted. The model wrote it, and a user's prompt can steer the model.
{
"type": "tool_use",
"id": "call_7f3",
"name": "run_python",
"input": {
"code": "import pandas as pd\ndf = pd.read_csv('sales.csv')\nprint(df.groupby('region').total.sum())"
}
}SPAWNBOX API
py is a template you build once, with Python and pandas. Send the tool call ID in X-Spawnbox-Step. The events of the request get this ID, so you can find them later with ?step_id=. With a warm pool, the sandbox is ready in about 8 ms. This one cannot reach the internet.
POST /v1/sandboxes
X-Spawnbox-Step: call_7f3
{"template": "py", "timeout_s": 3600,
"egress": {"mode": "deny_all"}}SPAWNBOX API
Write each file with one request. A relative path starts at /workspace. Spawnbox replaces a file only after it gets the full body.
PUT /v1/sandboxes/$S/files?path=main.py
PUT /v1/sandboxes/$S/files?path=sales.csvIN THE SANDBOX
Set a time limit, so a loop cannot run forever. If the code tries to reach a website, the DNS answer is REFUSED and the log keeps a record.
POST /v1/sandboxes/$S/exec
X-Spawnbox-Step: call_7f3
{"cmd": "python3 main.py", "timeout_s": 30}{"stdout": "region\neu 18240\nus 31977\n...",
"stderr": "", "exit_code": 0,
"timed_out": false, "duration_ms": 412}YOUR APP
Return stdout as the tool result, or stderr and the exit code if it failed. Keep the sandbox for the next turn of the chat: its files stay. After 10 minutes with no requests, it pauses by itself and frees its CPU and memory. The next request wakes it in about 65 ms. Spawnbox deletes it when its timeout_s ends. Paused time does not count.
{
"type": "tool_result",
"tool_use_id": "call_7f3",
"content": "region\neu 18240\nus 31977\n..."
}Send the step ID with each request. Later, get all the events of that step.
GET /v1/events?step_id=report.3Copy a running sandbox with its memory, processes and files. Up to 16 copies in less than 1 s.
POST /v1/sandboxes/$S:fork
{"count": 3}Mount a volume. Its files stay after the sandbox is deleted, for the next step to use.
"volumes": [{"volume": "reports",
"path": "/data"}]