连接电脑
先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
POST
/agent/v1/computers/{computer_id}/connect● 支持请求参数
computer_idstring必填path: Computer id (cmp_...), as returned by computers.create or computers.list.
needstring可选默认为 light。light 使用轻量 shell,或使用正在运行的重型实例。heavy 请求完整 Linux 电脑以运行交互程序;重型运行时间按秒计入每日预算。
返回
200
Praxis 自有扩展:Managed Agents 没有持久 Computer 连接。返回 SDK 可用的公开 sandbox_id、envd_access_token 和 template_id,以及兼容保留的 tier 字段(电脑只有一台机器,tier 不代表可选的另一台机器)与让机器保持服务的租约 lease_id、lease_expires_at。连接保持打开期间每 20 秒续租一次(POST .../leases/{lease_id}/renew),关闭时释放(DELETE .../leases/{lease_id});不续租则租约到期,整机在到期后才会被回收。归档电脑仍可连接;跨租户或不存在返回 404。连接凭证不可缓存。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
请求示例
curl
# 先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
curl -X POST https://api.deepraxis.com/agent/v1/computers/cmp_123/connect \
-H "Authorization: Bearer $PRAXIS_API_KEY"Python
# 先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
import requests
opts = dict(
base_url="https://api.deepraxis.com/agent",
api_key="$PRAXIS_API_KEY",
)
from e2b import Sandbox
resp = requests.post(f"{opts['base_url']}/v1/computers/cmp_123/connect", headers={"Authorization": f"Bearer {opts['api_key']}"})
resp.raise_for_status()
connection = resp.json()
sandbox = Sandbox.connect(connection["sandbox_id"], api_key=opts["api_key"], api_url=opts["base_url"].removesuffix("/agent") + "/e2b", domain="sandbox.praxisusercontent.com")
result = sandbox.commands.run("echo hello")
print(result.stdout)TypeScript
// 先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
const opts = {
baseURL: "https://api.deepraxis.com/agent",
apiKey: "$PRAXIS_API_KEY",
};
import { Sandbox } from "e2b";
const resp = await fetch(`${opts.baseURL}/v1/computers/cmp_123/connect`, { method: "POST", headers: { Authorization: `Bearer ${opts.apiKey}` } });
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
const connection = await resp.json();
const sandbox = await Sandbox.connect(connection.sandbox_id, { apiKey: opts.apiKey, apiUrl: opts.baseURL.replace(/\/agent$/, "/e2b"), domain: "sandbox.praxisusercontent.com" });
const result = await sandbox.commands.run("echo hello");
console.log(result.stdout);响应示例 200
{
"sandbox_id": "sbi0ea40aa2b7c9e79800fdb6bd",
"envd_access_token": "<redacted>",
"template_id": "light",
"tier": "light",
"lease_id": "lease_eb115096-bc9b-4cde-9a09-2daf6a47f26e",
"lease_expires_at": "2026-10-23T21:20:47.090Z"
}响应
HTTP 200
Computer result
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| sandbox_id | string | Public id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created. |
| envd_access_token | string | Access token for the sandbox's environment daemon, returned by the connect call; treat it as a secret. |
| template_id | string | Sandbox template the computer's sandbox was created from. |
| tier | string | Machine the connection reached: light (the always-present file machine) or heavy (the full machine started on demand and kept while leases are held). |
| lease_id | string | null | Id of the lease that keeps this connection's machine in service; renew it while the connection is open and release it on close. Null when no lease exists. |
| lease_expires_at | string | null | Time the lease lapses unless renewed, as an ISO 8601 timestamp; renew at about a third of the time remaining. |