读取任务日志
先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
GET
/sandbox/v1/sandboxes/{sandboxID}/tasks/{taskID}/log● 支持请求参数
sandboxIDstring必填path: 沙箱 ID。
taskIDstring必填path: Task id returned by sandboxes.tasks.start; a task id is opaque and is not the sandbox id.
namestring可选query: Which stream to read: output is the task's own stdout and stderr and is the default; any other value must be one of the file names passed to sandboxes.tasks.start. 1 to 32 characters of a-z, 0-9 or a hyphen.
offsetinteger可选query: First byte of the range, counted from the start of the stream. Omit to start at 0; resume with the previous answer's nextOffset.
limitinteger可选query: How many bytes to return, at most 4 MiB; omit for 1 MiB. A smaller limit follows a running task with less data per call.
返回
200
错误按 E2B 格式返回,参见 错误码
请求示例
curl
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
curl https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/tasks/tsk_example/log \
-H "X-API-Key: $PRAXIS_API_KEY"Python
# 先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。
import requests
api_key = "$PRAXIS_API_KEY"
# Call /sandbox/v1 directly over HTTP.
resp = requests.get(
"https://api.deepraxis.com/sandbox/v1/sandboxes/sbx_123/tasks/tsk_example/log",
headers={"X-API-Key": api_key},
)
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/tasks/tsk_example/log`, {
headers: { "X-API-Key": apiKey },
});
console.log(resp.status, await resp.text());响应示例 200
{
"text": "hello from a task\n",
"nextOffset": 18,
"done": true,
"exitCode": 0,
"size": 18
}响应
HTTP 200
The requested range, and where to continue
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| text | string | The requested bytes decoded as UTF-8, backing up to a whole character when the range would split one. Concatenate successive pages; a page never ends mid-character. |
| nextOffset | integer | Byte offset to pass as offset on the next call. It advances past what text delivered, so repeating a page is not needed; when done is true it equals size. |
| done | boolean | True once the task's final marker exists and the whole stream has been read. Only then are exitCode and size the task's outcome; false means more may still arrive, not that the task failed. |
| exitCode | integer | null | The task's exit status, from the final marker: 0 for success, non-zero for failure, null while the task has not finished. It is how the task ended, not how one page was read. |
| size | integer | null | Total bytes the stream will hold, from the final marker; null while the task runs and the total is not yet known. It is the bound for offset, and equals nextOffset when done. |