tufty.aitufty.ai CLI
CLI

输出模式

JSON 信封、只输出地址、下载到本地,以及 --dry-run 预估。

标准输出与标准错误

tufty 把两类信息严格分开:

  • 标准输出:只有一个 JSON 信封(或 --format url 时的地址列表),可以放心交给程序解析;
  • 标准错误:进度、积分预估、下载路径和提示。在交互终端里等待时还会打点,智能体和管道中不打点。

成功

{
  "ok": true,
  "result": {
    "tool": "pet-dressup",
    "runId": "3f6c2a1e-8b4d-4e7a-9c55-0d2b7e1f4a90",
    "status": "completed",
    "outputs": [
      { "type": "image", "url": "https://static.tufty.ai/.../result.png" }
    ]
  }
}
字段说明
tool工具 id
runId任务 id,可用于 tufty status
statuscompleted;配合 --no-wait 时为 running
outputs[].typeimage 或 video
outputs[].url成品地址,托管在 static.tufty.ai
outputs[].path配合 --save 时,本地文件的绝对路径

其他命令的 result:

命令result
tufty tools list{ tool: "tools.list", data: { locale, tools: [{ id, kind, name, description, command }] } }
tufty tools describe <id>{ tool: "tools.describe", data: 清单中的工具条目 }
tufty upload <file>{ tool: "upload", data: { url } }
tufty auth set <apiKey>{ tool: "auth.set", data: { source: "config", saved: true } }
tufty auth get{ tool: "auth.get", data: { source, apiKey } }
tufty login{ tool: "login", data: { saved: true } }
tufty logout{ tool: "logout", data: { removed } }

失败

{
  "ok": false,
  "code": "insufficient_balance",
  "message": "积分不足(这一步需要 75 积分)。",
  "details": { "status": 402, "required": 75 }
}

message 可直接展示给用户,程序判断请用 code。所有错误码见 错误码,退出码见 退出码。

--format url

tufty pet-dressup --product ./sweater.jpg --model ./corgi.jpg --format url

标准输出每行一个成品地址:

https://static.tufty.ai/.../result.png

只在结果里确实有地址时生效。tufty tools list、--no-wait 这类没有地址的结果仍输出完整信封,失败时也仍是 JSON 信封。tufty upload 和 tufty status 同样支持 --format url。

--save <dir>

tufty image-to-video --still ./corgi-sweater.png --duration 5 --save ./out

任务完成后,CLI 把成品逐个下载到目录里(目录不存在会自动创建),文件名为 <runId>-<序号><扩展名>。下载先写入 .partial 临时文件再改名,失败最多重试 3 次;本地绝对路径写回 outputs[].path。

--save 只在等待结果时生效,和 --no-wait 一起使用时不会下载。

--dry-run

tufty pet-dressup --product ./sweater.jpg --model ./corgi.jpg ./shiba.jpg --quality medium --count 2 --dry-run

只校验输入并打印请求载荷和积分预估:不上传、不扣费,也不需要登录。

{
  "ok": true,
  "result": {
    "tool": "pet-dressup",
    "dryRun": true,
    "payload": {
      "tool": "pet-dressup",
      "products": ["./sweater.jpg"],
      "models": ["./corgi.jpg", "./shiba.jpg"],
      "count": 2,
      "quality": "medium"
    },
    "estimatedCredits": 75,
    "creditBreakdown": { "generation": 72, "cutout": 3 }
  }
}

payload 里是本地路径而不是上传后的地址 —— 正式运行时 CLI 才会上传。积分怎么算见 积分。

On this page