Sandbox
MicroVM Linux isolate per il codice che eseguono i tuoi script e agenti IA. Una sandbox parte in circa un secondo, esegue Python, Node.js o bash ed è addebitata al secondo dallo stesso saldo dei tuoi server.
Cos’è una sandbox
Una piccola macchina Linux che crei via API o MCP, usi per qualche secondo o qualche giorno e poi elimini. Internet in uscita funziona (pip install, npm install, git clone). Niente porte in ingresso né SSH: comandi e file passano dall’API. Dentro: Python 3.12 con pip, Node.js 22 con npm, bash, git e curl.
Due modalità
Tariffe
| Tariffa | vCPU | RAM | Disco | Rete | All’ora | Persistente, max al mese |
|---|---|---|---|---|---|---|
| micro | 0.25 | 512 MB | 3 GB | 50 Mbit/s | $0.0165 | $9.03 |
| small | 0.5 | 1 GB | 5 GB | 100 Mbit/s | $0.033 | $18.07 |
| standard | 1 | 2 GB | 10 GB | 200 Mbit/s | $0.066 | $36.14 |
| plus | 2 | 4 GB | 15 GB | 300 Mbit/s | $0.132 | $72.27 |
| pro | 4 | 8 GB | 20 GB | 400 Mbit/s | $0.264 | $144.54 |
| max | 8 | 16 GB | 40 GB | 500 Mbit/s | $0.528 | $289.08 |
Paghi vCPU e RAM della tariffa scelta: $0.040 per vCPU-ora e $0.013 per GiB-ora. Prezzi aggiornati, senza token: GET /sandboxes/tariffs.
Limiti da conoscere
Un comando gira fino a 55 secondi; i lavori più lunghi vanno come attività in background di cui interroghi il risultato. File fino a 5 MB per richiesta, quelli più grandi (fino a 2 GB) tramite link di download e upload monouso. Un account può avere fino a 20 sandbox e 2 comandi in contemporanea.
Variabili d'ambiente
Passa segreti e impostazioni come env. Se impostate alla creazione valgono per ogni comando nella sandbox; se impostate in exec o run valgono solo per quella chiamata e sovrascrivono i valori della sandbox. Fino a 64 variabili, 32 KB per valore e 64 KB in totale. I valori sono salvati cifrati, l'API non li restituisce mai e non finiscono nei log: le risposte mostrano solo i nomi (env_keys).
API=https://api.eqvps.com/api/v1/eqvps
AUTH="Authorization: Bearer $EQVPS_API_KEY"
# env for the whole sandbox (only the names come back, as env_keys)
SB=$(curl -s -X POST $API/sandboxes -H "$AUTH" -H "Content-Type: application/json" \
-d '{"tariff":"small","env":{"DB_URL":"postgres://user:pass@db/app","MODE":"test"}}' | jq -r .id)
# env for one call, merged over the sandbox env
curl -s -X POST $API/sandboxes/$SB/exec -H "$AUTH" -H "Content-Type: application/json" \
-d '{"command":"echo $MODE $RUN_ID","env":{"RUN_ID":"42"}}'Limite di spesa
Per impostazione predefinita le sandbox non hanno limite di spesa. Puoi impostare un tetto giornaliero e mensile nella dashboard o con PUT /sandboxes/budget. Al raggiungimento del tetto, le nuove sandbox ricevono 429 budget_exceeded, quelle effimere attive vengono eliminate e quelle persistenti messe in pausa mantenendo il disco. Ripartono quando alzi il tetto o inizia un nuovo giorno o mese (UTC).
# daily cap $5, monthly cap $50 (null = no cap)
curl -s -X PUT $API/sandboxes/budget -H "$AUTH" -H "Content-Type: application/json" \
-d '{"daily_usd":5,"monthly_usd":50}'
# spent today / this month and when the caps reset (UTC)
curl -s $API/sandboxes/budget -H "$AUTH"Avvio rapido: MCP (Claude Code, Cursor e altri client)
Collega il server MCP una volta, poi chiedi all’agente quello che ti serve a parole tue. Strumenti sandbox: create_sandbox, run_code, exec_command, get_task, kill_task, get_upload_url, get_download_url, list_sandboxes, get_sandbox, kill_sandbox, sandbox_pricing.
claude mcp add --transport http eqvps https://mcp.eqvps.com/mcp \
--header "Authorization: Bearer $EQVPS_API_KEY"Crea una sandbox piccola, esegui print(2 + 2) in Python, mostrami l’output ed elimina la sandbox.Avvio rapido: REST da Python e Node.js
Non servono pacchetti extra. Metti il tuo token nella variabile d’ambiente EQVPS_API_KEY (come ottenerlo: «Collegare il tuo account»).
# first_sandbox.py — Python 3.8+, standard library only
import json, os, urllib.request
API = "https://api.eqvps.com/api/v1/eqvps"
KEY = os.environ["EQVPS_API_KEY"]
def call(method, path, body=None):
req = urllib.request.Request(API + path, method=method,
data=json.dumps(body).encode() if body is not None else None,
headers={"Authorization": "Bearer " + KEY,
"Content-Type": "application/json", "Accept": "application/json"})
with urllib.request.urlopen(req, timeout=90) as r: # HTTPError on 401/402/…
return json.loads(r.read() or b"{}")
sb = call("POST", "/sandboxes", {"tariff": "small"})
try:
r = call("POST", f"/sandboxes/{sb['id']}/run",
{"language": "python", "code": "print(2 + 2)"})
print(r["exit_code"], r["stdout"]) # 0 4
finally:
call("DELETE", f"/sandboxes/{sb['id']}")// first_sandbox.mjs — Node.js 18+ (built-in fetch), run: node first_sandbox.mjs
const API = "https://api.eqvps.com/api/v1/eqvps";
const KEY = process.env.EQVPS_API_KEY;
async function call(method, path, body) {
const r = await fetch(API + path, {
method,
headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json", Accept: "application/json" },
body: body ? JSON.stringify(body) : undefined,
});
const data = await r.json();
if (!r.ok) throw new Error(`${r.status} ${data.error ?? ""} ${data.message ?? ""}`);
return data;
}
const sb = await call("POST", "/sandboxes", { tariff: "small" });
try {
const r = await call("POST", `/sandboxes/${sb.id}/run`, { language: "node", code: "console.log(2 + 2)" });
console.log(r.exit_code, r.stdout); // 0 4
} finally {
await call("DELETE", `/sandboxes/${sb.id}`);
}SDK per Python e TypeScript
Preferisci una libreria? I pacchetti per Python e TypeScript fanno le stesse chiamate REST, ritentano da soli 429 e 503 ed eliminano sempre la sandbox alla fine del blocco. Installazione ed esempio:
# pip install -U eqvps https://pypi.org/project/eqvps/ (0.2.0+ for env)
# "eqvps sandbox create" = Sandbox.create() here · create_sandbox in MCP · POST /sandboxes in REST (no CLI)
from eqvps import Sandbox
# EQVPS_API_KEY from the environment; env = secrets for your code, stored encrypted
with Sandbox.create(tariff="small", env={"DB_URL": "postgres://user:pass@db/app"}) as sb:
r = sb.run("print(2 + 2)")
print(r.stdout, r.exit_code) # "4\n" 0
sb.upload("/root/data.csv", "a,b\n1,2\n")
print(sb.exec("wc -l /root/data.csv").stdout)
print(sb.exec("echo $RUN_ID", env={"RUN_ID": "42"}).stdout) # env for one call
# the sandbox is deleted when the block exits, also on errors// npm i @eqvps/sdk@latest https://www.npmjs.com/package/@eqvps/sdk (0.2.0+ for env)
import { Sandbox } from "@eqvps/sdk";
// EQVPS_API_KEY from the environment; env = secrets for your code, stored encrypted
await Sandbox.with({ tariff: "small", env: { DB_URL: "postgres://user:pass@db/app" } }, async (sb) => {
const r = await sb.run("print(2 + 2)");
console.log(r.stdout, r.exit_code); // "4\n" 0
console.log((await sb.exec("echo $RUN_ID", { env: { RUN_ID: "42" } })).stdout); // env for one call
}); // deleted afterwards, also on errorsCollegare il tuo account: token, configurazione, prima sandbox, saldo →
Commenti
Ancora nessun commento. Sii il primo.