WBX Sandbox
How do I…

How do I upload a file and download the result?

Put your file into a sandbox, process it there with any tool you like and take the result back – a chart, a converted document or a ZIP.

Steps

  1. Create a sandbox.
  2. Write your file into it, for example to /home/user/sales.csv.
  3. Process it – install what you need and run your script.
  4. Download the result and delete the sandbox.

No code: copy this into Claude or ChatGPT with WBX Sandbox connected and change it to fit.

I'm attaching sales.csv. Put it into a WBX sandbox, make a bar chart of the totals per month with pandas and matplotlib, and give me the chart as a PNG file to download.

Big files do not have to go through the chat. See Files in and out through your assistant.

pip install wbxsandbox, your key in WBXSANDBOX_API_KEY.

from wbxsandbox import Sandbox

with Sandbox.create() as sb:
    sb.files.write("/home/user/sales.csv", open("sales.csv", "rb").read())   # your file in
    sb.run("pip install -q pandas matplotlib")
    sb.run_code("""
import pandas as pd
df = pd.read_csv('/home/user/sales.csv')
ax = df.groupby(df.columns[0]).sum(numeric_only=True).plot(kind='bar')
ax.figure.savefig('/home/user/chart.png', dpi=150, bbox_inches='tight')
""").check()                                       # raises if the script failed
    sb.files.download("/home/user/chart.png", "chart.png")                   # the result out

npm install wbxsandbox (Node.js 20+); save as .mts for top-level await.

import { readFile, writeFile } from "node:fs/promises";
import { WBX } from "wbxsandbox";

const wbx = new WBX();
const sandbox = await wbx.sandboxes.create();
try {
  await sandbox.files.write("/home/user/sales.csv", await readFile("sales.csv"));   // your file in
  await sandbox.commands.run("pip install -q pandas matplotlib", { timeoutMs: 180_000 });
  const r = await sandbox.runCode(`
import pandas as pd
df = pd.read_csv('/home/user/sales.csv')
ax = df.groupby(df.columns[0]).sum(numeric_only=True).plot(kind='bar')
ax.figure.savefig('/home/user/chart.png', dpi=150, bbox_inches='tight')
`);
  if (r.exitCode !== 0) throw new Error(r.stderr);
  await writeFile("chart.png", await sandbox.files.read("/home/user/chart.png"));   // the result out
} finally {
  await sandbox.kill();
}

Just curl and jq; your key in WBXSANDBOX_API_KEY.

H="Authorization: Bearer $WBXSANDBOX_API_KEY"
SB=$(curl -s -X POST https://sandbox.wbx.cz/v1/sandboxes -H "$H" -d '{}' | jq -r .id)
curl -s -X PUT "https://sandbox.wbx.cz/v1/sandboxes/$SB/files?path=/home/user/sales.csv" -H "$H" --data-binary @sales.csv
curl -s -X POST https://sandbox.wbx.cz/v1/sandboxes/$SB/exec -H "$H" -d '{"cmd": "wc -l /home/user/sales.csv > /home/user/lines.txt"}'
curl -s "https://sandbox.wbx.cz/v1/sandboxes/$SB/files?path=/home/user/lines.txt" -H "$H" -o lines.txt
curl -s -X DELETE https://sandbox.wbx.cz/v1/sandboxes/$SB -H "$H"

How to tell it worked

  • chart.png is on your computer and opens as a picture.
  • The chart has one bar for each value in the first column of your CSV.

If it doesn't work

What you seeWhat to do
FileNotFoundErrorThe path in the script is not where you wrote the file. Use the full path, for example /home/user/sales.csv.
ModuleNotFoundErrorThe package is not installed yet – run pip install first, in the same sandbox.
The install stops after a whileLong commands need a longer time limit: timeout= in Python, timeoutMs in TypeScript, timeout_ms in curl.
The assistant cannot take a big fileChats limit attachment sizes. See Files in and out through your assistant for large files.

What it costs

A sandbox is billed while it runs, by its vCPU and memory. The default template base (2 vCPU, 512 MB) costs about US$0.07 (€0.06, 1.6 Kč) an hour. A sleeping sandbox uses no compute; only its disk is billed as storage. Current prices: Pricing.

Next steps