サンドボックス
スクリプトや AI エージェントが実行するコードのための、隔離された Linux マイクロ VM。約 1 秒で起動し、Python・Node.js・bash を実行でき、サーバーと同じ残高から秒単位で課金されます。
サンドボックスとは
API や MCP で作成し、数秒から数日使って削除する小さな Linux マシンです。外向きのインターネットは使えます(pip install、npm install、git clone)。受信ポートと SSH はありません。コマンドとファイルは API 経由でやり取りします。中身:pip 付き Python 3.12、npm 付き Node.js 22、bash、git、curl。
2 つのモード
料金プラン
| プラン | vCPU | RAM | ディスク | ネットワーク | 1 時間あたり | パーシステント、月の上限 |
|---|---|---|---|---|---|---|
| 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 |
選んだプランの vCPU と RAM に対して支払います:vCPU 1 時間あたり $0.040、GiB 1 時間あたり $0.013。最新価格はトークンなしで:GET /sandboxes/tariffs。
知っておきたい制限
1 回のコマンドは最大 55 秒。長い処理はバックグラウンドタスクとして実行し、結果を取得します。ファイルは 1 リクエスト 5 MB まで、それより大きいもの(最大 2 GB)は使い捨てのダウンロード/アップロード用リンクで。1 アカウントで同時に最大 20 個のサンドボックスと 2 個のコマンドを実行できます。
環境変数
シークレットや設定は env で渡します。作成時に指定するとサンドボックス内のすべてのコマンドに適用され、exec や run で指定するとその呼び出しだけに適用されてサンドボックスの値を上書きします。最大 64 個、1 つの値につき 32 KB、合計 64 KB まで。値は暗号化して保存され、API から返されることはなく、ログにも書き込まれません。レスポンスには名前(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"}}'利用上限額
デフォルトではサンドボックスに利用上限はありません。ダッシュボードまたは PUT /sandboxes/budget で1日あたり・1か月あたりの上限を設定できます。上限に達すると新しいサンドボックスには 429 budget_exceeded が返され、実行中の一時サンドボックスは削除され、永続サンドボックスはディスクを保持したまま一時停止します。上限を引き上げるか、新しい日または月(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"クイックスタート:MCP(Claude Code、Cursor などのクライアント)
MCP サーバーを一度つなげば、あとはエージェントに普通の言葉で頼むだけです。サンドボックス用ツール: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"小さなサンドボックスを作って、Python で print(2 + 2) を実行し、出力を見せてからサンドボックスを削除して。クイックスタート:Python と Node.js から REST
追加パッケージは不要です。トークンを環境変数 EQVPS_API_KEY に入れてください(取得方法は「アカウントの接続」を参照)。
# 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}`);
}Python と TypeScript 用 SDK
ライブラリを使いたい場合は、Python と TypeScript のパッケージが同じ REST 呼び出しを行い、429 と 503 は自動で再試行し、ブロック終了時に必ずサンドボックスを削除します。インストールと例:
# 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 errors
コメント
まだコメントはありません。最初になりましょう。