运行命令
先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
/sandbox/v1/sandboxes/{sandbox_id}/commands● 支持请求参数
sandbox_idstring必填path: Sandbox ID returned by sandboxes.create or sandboxes.list.
cmdstring必填Shell command to execute, for example echo hi.
backgroundboolean可选When true, return 202 with the pid as soon as the process starts; it keeps running after the request ends. Read its status and output with GET /sandbox/v1/sandboxes/{sandbox_id}/commands/{pid}, stop it with DELETE. Same idea as E2B background commands.
cwdstring可选Working directory; omitted uses the sandbox user's home directory.
envsobject可选Environment overrides for this command; omitted uses the sandbox environment.
timeoutMsinteger可选Execution timeout in milliseconds, from 1 to 3600000 (1 hour); defaults to 600000 (10 minutes). In background mode this limits process runtime; expiry records exit code 124.
progressTimeoutMsinteger可选Foreground commands only, off by default: end this command once it goes this many milliseconds (1000 to 3600000) without writing a single byte to stdout or stderr, and answer COMMAND_NO_PROGRESS (504) with the output received so far and lastOutputAt. The sandbox itself keeps running, so decide afterwards whether to read what it produced or stop it with DELETE. A slow command that keeps producing output is never ended by it; if the program buffers its output, turn buffering off first, for example PYTHONUNBUFFERED=1 or stdbuf -oL. Passing it together with background true is refused with INVALID_PARAMS.
返回
200
错误按 E2B 格式返回,参见 错误码
请求示例
curl
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
curl https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/commands \
-H "X-API-Key: $PRAXIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"cmd":"echo hello","timeoutMs":10000}'Python
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
import requests
api_key = "$PRAXIS_API_KEY"
# Call /sandbox/v1 directly over HTTP.
resp = requests.post(
"https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/commands",
headers={"X-API-Key": api_key},
json={"cmd": "echo hello", "timeoutMs": 10000},
)
print(resp.status_code, resp.text)TypeScript
// 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
const apiKey = "$PRAXIS_API_KEY";
// Call /sandbox/v1 directly over HTTP.
const resp = await fetch(`https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/commands`, {
method: "POST",
headers: { "X-API-Key": apiKey, "Content-Type": "application/json" },
body: JSON.stringify({ cmd: "echo hello", timeoutMs: 10000 }),
});
console.log(resp.status, await resp.text());响应示例 200
{
"stdout": "hello\n",
"stderr": "",
"exitCode": 0
}响应
HTTP 200
Operation completed
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| stdout | string | Captured standard output as UTF-8 text. |
| stderr | string | Captured standard error as UTF-8 text. |
| exitCode | integer | Process exit code; zero means success. Nonzero exits also return this result. |