跳转到内容
EN

上传电脑附件

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

POST/agent/v1/computers/{computer_id}/attachments● 支持

请求参数

  • computer_idstring必填

    path: Computer id (cmp_...), as returned by computers.create or computers.list.

  • namestring必填

    query: 单个文件名,最多 255 个 UTF-8 字节,不含斜杠、点路径段和控制字符。

返回

201

Praxis 扩展:Managed Agents 没有持久 Computer 附件目录。用户上传可以覆盖同名附件,智能体始终只读;运行令牌调用上传返回 403 READ_ONLY。name 是单个文件名、最多 255 UTF-8 字节,MIME 始终按扩展名推断,上传的 Content-Type 不持久保存,digest 可省略。上限 16 MiB,超限 413、非法名字 400;归档电脑也可上传,跨租户 404。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

请求示例

curl
# 先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
curl -X POST "https://api.deepraxis.com/agent/v1/computers/cmp_123/attachments?name=sample.txt" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" -H "Content-Type: text/plain" --data-binary @sample.txt
Python
# 先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
import requests

opts = dict(
    base_url="https://api.deepraxis.com/agent",
    api_key="$PRAXIS_API_KEY",
)

with open("sample.txt", "rb") as file:
    resp = requests.post(f"{opts['base_url']}/v1/computers/cmp_123/attachments?name=sample.txt", headers={"Authorization": f"Bearer {opts['api_key']}", "Content-Type": "text/plain"}, data=file)
resp.raise_for_status()
print(resp.json())
TypeScript
// 先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。
const opts = {
  baseURL: "https://api.deepraxis.com/agent",
  apiKey: "$PRAXIS_API_KEY",
};

const { readFile } = await import("node:fs/promises");
const resp = await fetch(`${opts.baseURL}/v1/computers/cmp_123/attachments?name=sample.txt`, { method: "POST", headers: { Authorization: `Bearer ${opts.apiKey}`, "Content-Type": "text/plain" }, body: await readFile("sample.txt") });
if (!resp.ok) throw new Error(await resp.text());
console.log(await resp.json());

响应示例 201

{
  "path": "/attachments/sample.txt",
  "name": "sample.txt",
  "type": "file",
  "size": 11,
  "mime_type": "text/plain",
  "read_only": true,
  "digest": "17c8f4932d26f6434e3be45968859b3bac3f133b3ca024004659cc20af325ae2",
  "updated_at": "2026-10-11T10:34:57.989Z"
}

响应

HTTP 201

Computer result

application/json

名称 类型 说明
path string Absolute path of the entry on the computer.
name string Name of the entry or object.
type string Kind of entry: a file, a directory or a symbolic link.
size integer Size in bytes.
mime_type string MIME type of the file.
read_only boolean True when the entry cannot be modified through the API.
digest string | null Content digest of the file; null when not computed.
updated_at string | null RFC 3339 time at which the object was last modified.