API 参考

从你自己的代码中租用 GPU 和 CPU 设备,并管理你出租的设备。

基础信息

基础地址
https://suanzu.ai
OpenAPI 文件
/openapi.yaml
供 AI 工具读取
/llms.txt

认证

在控制台(控制台 → API 密钥)中创建 API 密钥,并在每个请求中携带:Authorization: Bearer sz_live_...。只接受此请求头;查询字符串中的密钥会被忽略。市场接口不带密钥也可使用。

每个密钥有一个或多个权限范围:

权限范围允许的操作
renter:read读取你的实例、余额、流水、租金余额充值记录、计算任务模板、实例计算任务、标签和钱包/变量。
renter:writerenter:read + 租用、停止、修改启动命令、重启容器、获取连接信息,管理计算任务模板、实例计算任务、标签和钱包/变量。
host:read读取你的设备、GPU、消息、命令结果与进度、可安装的驱动版本、标签、模板(及使用它们的设备)、钱包/变量、历史曲线、故障历史、分组、收益、账户、账单(含按天明细)和服务费充值记录。
host:writehost:read + 设置价格(直接设置或套用模板)、上架 / 下架、重命名、打标签、设置计算任务、超频和自动风扇、管理模板(价格、计算任务、超频、自动风扇)、标签和钱包/变量、暂停 / 恢复 / 重启计算任务、拉取任务日志。
host:exechost:write + 重启设备、升级 Agent、安装 NVIDIA 驱动、开启远程访问(设备上的 root shell)并更换其密码。

密钥可以限定为部分分组,并可设置 IP 白名单。没有设置 IP 白名单的密钥可以从任何 IP 使用;设置了的,来自其他 IP 的请求返回 403 api_key_ip_denied。不在密钥范围内的设备和分组视同不存在(返回 404,或不出现在列表中)。对于其他账户共享给你的分组,你在该分组中的角色仍然适用,且所有者必须为你开启 API 访问。限定了分组的密钥不能修改账户级的设置:账户级模板(group_id: null)、账户级钱包/变量和你的标签库(403 group_forbidden);仍可读取它们,并在其分组内使用。

密钥只能看到你自己账户的金额。 余额、流水、账单和收益始终是你自己账户的。对于其他账户共享给你的分组,无论你是什么角色,密钥都看不到所有者的收益:收益字段为 null(summary.earnings、groups.<id>.earnings),租用记录的 show_income: false,GET /api/v1/host/earnings / earnings/leases 传这类分组的 group 时返回 404 group_not_found。这些分组中的设备与状态数据仍按你的角色返回。

涉及多台设备的写操作必须在同一分组内。 使用 API 密钥时,指定多台设备的出租方请求(price、price-template、listing、listing/precheck、tags、tasks/apply、tasks/restart、tasks/redownload、tasks/pause、tasks/resume、oc-template、oc/reapply、autofan-template、commands/reboot、commands/upgrade)只能指定同一分组中的设备;否则整个请求会被拒绝并返回 400 cross_group,且不执行任何操作。未分组的设备算作一个分组。你无法查看的设备不计入(它们会逐个以 machine_not_found 失败)。

约定

  • 金额为以 USDT 计的十进制字符串(例如 "0.053"),不会是 JSON 数字。
  • 时间为 UNIX 秒(整数)。
  • 响应里的 ID 都是字符串。整数 ID(租约、流水行)是十进制字符串,例如 "57"。
  • 错误格式始终为 {"ok": false, "code": "...", "error": "..."}。请根据 code 判断;error 是供人阅读的英文文本,可能会变化。
  • 以下所有接口都可能返回 500 internal;各接口中不再单独列出。
  • 所有接口对未知的查询参数、重复传入的查询参数、未知的请求体字段、超出范围的值一律返回 400 bad_request,error 会写出是哪个参数。(只有市场列表的 gpu 和 cpu 可以重复传。)请求体超过大小上限返回 413 body_too_large。
  • 请求执行过久(GET 5 秒,其他方法 30 秒)返回 503 request_timeout。写操作遇到它表示结果未知:重新发送前先读取当前状态。
  • 写操作返回 200 表示改动已保存。多数设置随设备下一次心跳送达。需要确认设备确实已执行时(租用交付、命令、超频、计算任务),按下文「异步操作与轮询」轮询对应字段。
  • GPU 型号名称:市场接口用短名(CMP 50HX、RTX 4090:去掉前缀 NVIDIA 、GeForce 、Tesla )。出租方接口的 gpus[].name、gpu 筛选、gpu_counts、/host/gpus 用驱动报告的全名(NVIDIA CMP 50HX、NVIDIA GeForce RTX 4090)。价格模板 prices.gpu 的键和超频模板 models 的键用 GPU 型号名:显卡有 show_name 时用它(例如驱动报成 Graphics Device 的 CMP 170HX),否则用 name。驱动通用名(Graphics Device、NVIDIA Graphics Device)不能作为模板键(400 template_invalid)。

分页

写法接口下一页
cursor + pageSize(默认 50,大于 200 按 200 处理)GET /api/v1/market/machines把 next 作为 cursor 传入,筛选条件和 sort 保持不变;最后一页 next 为空
page + per_page实例(默认 50,历史 20,最大 1000)、实例扣费记录(默认 20,最大 50)、出租方设备、设备消息、显卡(默认 50,最大 1000)page 加 1,直到 page = total_pages。页码超出末页时返回末页(设备、实例)或空列表(扣费记录)
page + page_size(默认 20,最大 100)租用方流水、充值记录、出租方流水、收益租约page 加 1,直到取满 total 条
before + limit(默认 20,最大 100)GET /api/v1/host/machines/{machine_id}/leases把 next_before 作为 before 传入;最后一页为 null
只有 limit(默认 10,最大 200)GET /api/v1/host/machines/{machine_id}/timeline没有下一页:加大 limit。最多只能读到最新的 200 条

GET /api/v1/account/deposits/pending 不分页(最多 50 条,按时间倒序)。

限流

每个密钥在每个限流类下都有每分钟的请求额度(见各接口的 x-rate-limit-class)。超出限制时返回 429 rate_limited,并带有 Retry-After 响应头(秒)。

限流类每个密钥每分钟请求数适用接口
read120市场、出租方设备列表 / 详情 / 任务、GPU、标签、预置镜像
read_pg30余额、流水、收益、账单、实例列表、上架检查、分组、预检查、命令时间线与进度、驱动版本、消息、模板、钱包/变量、历史曲线、故障历史
write30写操作:停止、价格、上架、名称、标签、模板、任务设置与控制、任务日志、超频、自动风扇、钱包/变量、重启、升级 Agent、安装驱动、远程访问开启 / 关闭 / 换密码
order10租用设备
remote20获取带密码的连接信息

read_pg 和市场请求还共享一个较小的全服务器并发池;繁忙时,即使未超出每分钟额度,也可能收到 429 rate_limited 和 Retry-After: 1。限流规则在正式发布前可能变化。

密钥错误

任何携带 API 密钥的请求都可能在接口执行前失败:401 api_key_invalid、401 api_key_expired(请创建新密钥)、403 api_key_route_not_allowed(该接口不对 API 密钥开放)、403 api_key_scope_denied、403 api_key_ip_denied、429 rate_limited。未携带密钥请求需要密钥的接口时,返回 401 unauthorized。

异步操作与轮询

设备约每 15 秒上报一次心跳。最后一次心跳(last_heartbeat_at)在 120 秒内时设备为 online;超过后 connectivity 变为 offline,status_reasons 出现 offline,实时值为 null。命令和设置一般随设备下一次心跳送达;有人正在查看该设备或其分组时(带 group 的设备列表,或设备详情),设备约 1 秒内被唤醒。

操作轮询直到间隔通常 / 上限失败时
租用交付GET /api/v1/renter/leases(tab=current)phase 为 running(pulling → preparing → starting → running)10 秒镜像拉取自下单起最长 1800 秒;拉取完成后准备与启动合计最长 300 秒实例离开 current 标签,出现在 tab=history,带 end_reason: delivery_failed 和 fail_code,不收费。交付期间的 retry_code 是本轮失败、正在重试的步骤
停止实例GET /api/v1/renter/leases(tab=history)phase 为 released15 秒至少两轮设备循环(约 30 秒)。没有时限:设备离线时一直保持 stopping,直到它重新上线不论处于哪个阶段,停止时即停止计费。stopping 只表示设备尚未确认清理完成
启动命令GET /api/v1/renter/leasesstartup.rev 等于返回的 startup_rev,且 startup.state 不再是 pending10 秒下一次心跳startup.state: failed 或带 exit_code 的 exited;读取 GET .../container-log
命令(reboot、upgrade、task_restart、task_logs)GET /api/v1/host/machines/{machine_id}/timelinecmd_id 对应的那一项 state 为 ok 或 error10-15 秒随下一次心跳领取(约 15-20 秒)。离线设备须在 600 秒内(expire_at)上线并开始执行state: error 并带 note(见下方词典);原因在 latest_title,日志在 GET .../messages(payload_gz)
重启同命令state: ok、note: rebooted15 秒设备重新上线且 boot_time 更新即完成重启开始后 600 秒内未回来则 note: timeout
升级 Agent先看时间线,再看 GET /api/v1/host/machines/{machine_id}state: ok,然后 agent_version 显示新版本(安装完成后的下一次心跳)15 秒主要是下载时间;单次下载最长 1800 秒state: error,原因在 latest_title(例如 Upgrade failed (exit 1));到 expire_at + 1800 秒仍无结果为 note: timeout;期间设备重启为 interrupted
安装驱动时间线;进度看 GET /api/v1/host/machines/{machine_id}/commands/{cmd_id}/progressstate: ok、note: rebooted(带着新的 driver_version 重新上线)15 秒(进度 5 秒)下载加安装,再重启一次。上限:开始到重启 120 分钟,重启后 10 分钟内上线state: error,原因码在 latest_title 的方括号里([driver_download_failed]、[driver_install_timeout]、[driver_reboot_timeout]、[driver_version_mismatch] 等)。重启前失败时旧驱动不变;[driver_reboot_required] = 驱动已装好,但到重启时已超过时限,请自己重启设备
超频GET /api/v1/host/machines/{machine_id}oc.applied_revision 等于 oc.revision。单台调用(/machines/{machine_id}/oc…、/machines/{machine_id}/autofan)会返回这个 revision;批量调用(/machines/oc-template、/machines/oc/reapply、/machines/autofan-template)只返回 results[],调用后读取设备的 oc.revision15 秒保存后一到两次心跳。deferred: rented 在租用结束后才应用;deferred: offline 在设备上线后应用oc.rejected(整份配置被拒)、oc.result[].results[].code 不是 ok / unchanged、oc.verify_error。applied_revision 为 null 表示设备从未回报
计算任务GET /api/v1/host/machines/{machine_id}/tasks(租用方:GET .../leases/{lease_id}/tasks)states[] 中你的 binding_id 那一项 state: running,且 revision 等于任务的 revision15 秒下一次心跳,加上程序包下载时间state 为 retrying、gpu_missing、unsupported、held;exits_1h ≥ 3 表示反复崩溃。查看任务日志(租用方:GET .../tasks/{binding_id}/log)和 latest
任务统计(算力)同上stats_at 有值且 stats[] 中有你的 binding_id30 秒通常在任务进入 running 后 15-35 秒出现。仅 HiveOS 任务(kind: hive);自定义任务不上报统计任务不是 running 时没有统计;设备停止上报 1200 秒后统计消失

任务接口返回 syncing: true 表示任务列表仍在写入,几秒后再读。统计和状态对应设备最后一次上报的任务列表:修改后请等到 states[] 显示新的 revision。

状态与代码词典

设备 status(出租方接口;状态筛选用同样的值):

status含义你能做什么平台会做什么
unpriced未设价格、未上架、没有问题设置价格后上架不做处理
unlisted已设价格但未上架、没有问题上架不做处理
available已上架,可租用与租用相关的改动对新的租用生效在市场展示
noncompliant未上架,且有问题(status_reasons)先解决问题;上架会以 not_eligible 失败不做处理
fault已上架,但有问题(status_reasons,含离线)解决问题后自动恢复问题消失前从市场隐藏(保留上架)
rented有尚未释放的租约(含交付中、停止中)见下文「被租用的设备」遇到标为 stop 的问题时停租

status_reasons 代码。 各列为问题出现在上架前 / 上架中 / 租用中时的后果。reject = 拒绝上架或租用;hide = 从市场隐藏(fault);refresh = 更新上架规格,仍可租用;stop = 停租并下架;notice = 只通知你;- = 该状态不检查。GET .../checks 中的 outcome 与此相同。

代码含义未上架上架中租用中
offline120 秒无心跳rejecthidenotice
offline_rented租用中设备离线满 600 秒(计费截止到最后一次心跳)--stop
price_unset已上架但没有对应单位的价格reject--
group_invalid所属分组已删除rejecthidenotice
gpu_dropped有 GPU 未被驱动识别rejecthidestop
gpu_driver驱动读不到某块 GPUrejecthidestop
gpu_ecc_uncorrected存在未纠正的 ECC 错误rejecthidestop
gpu_probe_failedGPU 数据读取失败(连续 2 轮)rejecthidestop
gpu_count_lowGPU 少于上架时(或少于 expected_gpu_count)rejecthidestop
gpu_mixedGPU 型号不止一种rejecthidenotice
gpu_changed上架后 GPU 型号或显存变了-hidestop
driver_changed上架后驱动或 CUDA 版本变了-hidestop
cpu_changedCPU 型号或颗数变了-hidestop
ram_low内存少于上架时-hidestop
ram_more内存多于上架时-refresh-
disk_changed磁盘容量变化超过 1%,或磁盘类型变了-hidestop
os_changed操作系统或内核变了-refreshstop
pcie_degraded某块 GPU 的 PCIe 代数或宽度低于上架时-refreshstop
pcie_changedPCIe 链路变了,但没有变低-refreshnotice
pcie_unstable24 小时内 PCIe 链路变化 3 次及以上rejecthidenotice
docker_downDocker 未安装或未运行rejecthidestop
nvidia_runtime_missing有 NVIDIA GPU 但没有 NVIDIA 容器运行时rejecthidestop
runc_outdatedrunc 低于 1.2.8 或读不到版本rejecthidestop
nvidia_toolkit_outdated有 NVIDIA GPU,但 NVIDIA 容器工具包低于 1.19.1 或读不到版本rejecthidenotice
disk_low系统盘可用空间不足 5 GiBrejecthidenotice
collect_invalid读不到 CPU、内存或磁盘信息rejecthidenotice
rent_env_unsupported不是物理机或虚拟机(容器、WSL)rejecthidenotice
agent_outdatedAgent 低于 1.2.0rejecthidenotice
tools_missingAgent 工具包仍在下载rejecthidenotice
identity_conflict两台设备用同一身份上报rejecthidenotice
owner_inactive所有者账户已停止出租rejecthidenotice
data_invalid设备数据损坏rejecthidenotice
oc_rental_tampered租用期间超频被其他程序改动--stop
rent_container_lost租用方的容器不见了--stop
rent_isolation_failed租用的网络隔离无法检查或恢复--stop

表中没有的代码按 hide 处理。CheckRow.result:pass、fail、na(当前不适用)、pending(本轮有变化,下一轮确认)。CheckRow.outcome 每一行都有,表示在设备当前状态下该项不通过时的后果(null = 不处理)。GET .../checks 的 action 为 ok、hide 或 stop。

实例 phase:pulling(下载镜像;progress 0-99)、preparing(GPU 与超频检查)、starting(容器启动中)、running(计费中)、stopping(已结束,等待设备清理)、released(已清理)。只有 running 可以使用;在 stopping 之前的任何阶段都可以停止。

end_reason:renter(你停止的;交付期间取消的带 fail_code: renter_cancel,不收费)、balance_exhausted(余额付不了下一分钟)、offline_rented(设备离线满 600 秒)、verdict(上表中标为 stop 的硬件或驱动问题)、admin(平台停止)、delivery_failed(见 fail_code)。

fail_code:平台判定的:pull_timeout、prepare_timeout、start_timeout、oc_failed、gpu_busy(出租方正在使用该设备;设备会被下架)、agent_outdated、renter_cancel;设备上报的:pull_failed、disk_insufficient、image_too_large、image_no_shell、start_failed、gpu_mismatch、network_isolation_failed、rent_job_failed。也可能出现其他小写代码。

命令 state / note(时间线):pending(尚未开始)、running(已开始,还没有结果)、ok、error。已结束命令的 note:rebooted(重启完成)、powered_off、expired(600 秒内未开始)、timeout(已开始,未按时出结果)、interrupted(执行期间设备重启了)、not_delivered(没有发出,可直接重发)、rebooted_no_gpu / rebooted_gpu_unreadable(驱动已装好重启,但设备没有 NVIDIA GPU / GPU 都读不到,未核对版本);其余情况为 null,设备上报的 error 也是 null(原因在 latest_title)。

计算任务 state(states[].state):running(程序在运行)、preparing(下载或启动中)、retrying(程序退出或准备失败,按退避重启,最长间隔 60 秒)、gpu_missing(它的 GPU 不见了)、paused、held(被设备本身暂缓,例如开机后 GPU 初始化或安装驱动期间;见 reason)、overheat(被风扇控制因过热停止)、yielded(设备被租用,出租方任务让出)、unsupported(设备缺少工具,见 missing)、stopped(已移除)。state 为 running 且 revision 等于任务的 revision 时,任务在运行。started_at 是本次运行的开始时间;exits_1h 是最近一小时的退出次数。

重试与批量操作

类别接口超时或 5xx 时
可放心重复(同样的请求体,同样的结果)价格、套用价格模板、修改模板和标签(PUT / PATCH)、上架、预检查、标签、PUT .../tasks、tasks/apply(replace、clear;add 会跳过已有任务)、任务暂停 / 恢复、oc/manual-only、重命名、钱包/变量 PUT、PUT .../startup、停止实例、用同一个 Idempotency-Key 租用直接重发
谨慎重复PUT .../oc、oc-template、oc/reapply、PUT .../autofan、autofan-template每次调用都会提高 revision 并让设备重新应用(值相同,无害)。先读 oc.revision
不要盲目重复commands/reboot、commands/upgrade、commands/driver_install、commands/task_restart、commands/task_logs、tasks/restart、tasks/redownload、startup/restart、rebuild、租用方任务 restart / reinstall、更换密码、新建模板、钱包/变量或标签先查结果:命令看时间线(你的 cmd_id,或该 type 最新一条且 issued_by_mine 的项),其余看对应列表。503 command_push_failed 例外:什么都没发出,可直接重发
  • 429 rate_limited:等待 Retry-After 秒(每分钟额度为到下一分钟开始,共享池繁忙时为 1 秒),再加 0-1000 毫秒随机抖动,避免并行的程序同时重试。
  • 读操作遇到 503 device_index_rebuilding 或 request_timeout:按 2、4、8、16 秒退避,5 次后放弃。写操作遇到 503 request_timeout:先读取状态(见上)。
  • 每个新订单用一个新的 Idempotency-Key,重试该订单时沿用它:幂等键永久保留,同键同请求体返回同一订单,请求体不同返回 422 idempotency_mismatch。
  • 使用 API 密钥做多台设备的写操作:按 group_id(来自 GET /api/v1/host/machines)拆分 machine_ids,每个分组发一个请求;否则请求以 400 cross_group 失败。每个请求的上限:price、price-template、listing、listing/precheck、tasks/apply、tasks/restart、tasks/redownload、tasks/pause、tasks/resume、oc-template、oc/reapply、autofan-template 为 500 台;tags 为 1000 台;commands/reboot 和 commands/upgrade 为 100 台(去重后);commands/task_restart、commands/task_logs 和 commands/driver_install 恰好 1 台。结果按设备给出:务必检查 results[](或 rejected[]),返回 200 不代表每台都已完成。
  • 每台设备同一时间只能有一个大操作(重启、关机、升级 Agent、修改网络、安装驱动)未结束;在它结束前,再发会以 command_pending 被拒。计算任务命令不受它限制,也不限制它。

业务规则

  • 价格与抽成。出租方设置的价格(price_per_gpu_hr / price_per_cpu_hr)是出租方的到手价。市场和租用方看到的是加上平台抽成后的价格:单价 × (1 + 抽成比例),向上取到 3 位小数,再乘以 GPU(或 CPU 颗)数。抽成比例由平台设定。两种价格都在下单时固定;之后改价只对新的租用生效。
  • 计费。租金从镜像就绪(billing_from)起按分钟扣费,直到你停止,只计设备在线的时间,按累计金额向上取整到分。下单时余额须至少够一小时租金。没有宽限期:余额付不了下一分钟时,你的所有实例都会停止,end_reason: balance_exhausted(剩余不足 120 分钟和 30 分钟时会通知你)。
  • 没有租用时长。订单没有时长;实例一直运行,直到你停止(POST .../stop)、余额耗尽或平台停止。用完请在你的代码里停止它。
  • 充值。API 不能生成充值地址或转移资金;请在控制台充值。用 GET /api/v1/account/deposits/pending 查看正在到账的充值,用 GET /api/v1/account/deposits / GET /api/v1/renter/account 查看已入账。提现和余额转让不对 API 密钥开放。
  • Agent 版本。当前正式版号是 https://down.suanzu.ai/VERSION 的纯文本内容(公开,无需密钥),格式固定为 MAJOR.MINOR.PATCH。commands/upgrade 一律安装这个版本,不看设备当前版本:比它新的正式版或 beta 会被装回这个版本(1.5.8-beta.2 变成 1.5.7),已是这个版本的会重新安装一次。所以只对需要装正式版的设备下发。按语义化版本比较:MAJOR、MINOR、PATCH 逐段按数字比;带 -beta.N 的版本低于同号正式版、高于上一个正式版(1.5.7 < 1.5.8-beta.2 < 1.5.8)。agent_version 为 null 表示尚未上报。
  • 出租方服务费。earn_balance 低于 0 即为欠费。服务费余额和赠送额度先抵扣服务费,之后的充值、收到的转让和赠送也会自动抵扣欠费。欠费时,GET /api/v1/host/account 带 overdue_since 和 freeze_at(= overdue_since + 3 天)。届时仍欠费则账户受限(restricted: true):修改计算任务、超频和钱包/变量会以 account_overdue_restricted 失败,直到你充值。
  • 被租用的设备。设备有租约时(status: rented,含交付中和停止中):commands/reboot、commands/upgrade、commands/driver_install、commands/task_restart、commands/task_logs、tasks/restart、tasks/redownload、开启远程访问、oc/reapply 和恢复出租方任务(单个任务或 tasks/resume)会以 rented 被拒;超频、超频模板、自动风扇和 oc/manual-only 会保存,在租用结束后应用(deferred: rented);出租方计算任务可以修改,但会让给租用方(state: yielded);可以改价(进行中的租用保持原价);可以下架,下架不会停止租用。

计算任务模板

模板分 custom(你自己的启动命令)和 hive(HiveOS 自定义程序包)两种。出租方任务在设备上运行;租用方任务在实例里运行。

  • 自定义任务。custom.start_command(必填,最多 16 KiB)用 bash -c 运行。填了 custom.package_url 时先下载该文件:.tar.gz、.tgz、.tar.xz 和 .tar 在 extract 为 true(默认)时解压到工作目录;其他文件(包括 .zip)原样放在那里并设为可执行。程序退出后等 3 到 60 秒重新启动;连续运行满 300 秒后等待时间重新计算。
  • 变量(vars,仅自定义任务)。每一项成为程序的一个环境变量,值原样传入(不做 shell 展开)。最多 64 个。key 须匹配 ^[A-Za-z_][A-Za-z0-9_]*$,不能以 SUANZU_ 开头,也不能是 CUDA_DEVICE_ORDER、CUDA_VISIBLE_DEVICES、NVIDIA_VISIBLE_DEVICES、BASH_ENV、ENV、PATH。value 必填(可以为空),最多 4 KiB。带 vars 的 HiveOS 模板会返回 400 hive_vars_unsupported。
  • 取自钱包/变量的值。把 ref 设为你某条钱包/变量的 id,并发送 value: "":值总会被替换成那条钱包/变量的当前值,修改该值会重启用到它的任务。不是你的 id 会返回 400 wallet_var_unavailable。HiveOS 用 wallet_ref 对 hive.wallet 做同样的事(发送 wallet: "")。
  • 为程序设置的变量。SUANZU_TASK_ID、SUANZU_TASK_DIR、SUANZU_WORKER_NAME、SUANZU_GPU_BUSIDS(任务所用 GPU 的总线号,逗号分隔)和 CUDA_DEVICE_ORDER=PCI_BUS_ID。任务只用部分 GPU 时,CUDA_VISIBLE_DEVICES 和 NVIDIA_VISIBLE_DEVICES 为这些 GPU 的 UUID。CPU 任务(gpus: [])带 SUANZU_TASK_CPU=1,没有 GPU。
  • HiveOS 字段。install_url 必须是 http(s) 链接,指向包含 <miner>/h-manifest.conf 和 <miner>/h-run.sh 的 .tar.gz / .tgz 包。miner 留空时从文件名推出:去掉扩展名,取最后一个 - 之前的部分(pearlfortune-1.2.3.tar.gz 得到 pearlfortune)。coin 和 algo 以 DIGITAL_CASH 和 CUSTOM_ALGO 传给程序包。template、url、pass 和 user_config 里的宏 %WAL%(钱包)、%WORKER_NAME%、%URL%、%URL_HOST% 和 %URL_PORT%(取自 url 中的第一个地址)会被替换;其他 %...% 原样保留。用了 %WAL% 但钱包为空且没有 wallet_ref 时返回 400 hive_wallet_required。
  • 跟随最新版。下载地址(hive.install_url / custom.package_url)是带版本标签的 GitHub 发布附件时,可把 follow 设为 latest(只跟正式版)或 latest_beta(含预发布)。出了更新的版本,SuanZu 会把模板的下载地址换成新版本(开了下载加速的等缓存好再换,最晚到新版本发布满 1 小时),并发送 tpl.auto_updated 通知。模板以 current_tag 返回正在使用的版本。
  • 是否在运行?任务的 states[] 项为 state: running 且 revision 与任务相同时,任务在运行。只有 HiveOS 任务上报统计(TaskStats,来自程序包的 h-stats.sh)。
错误返回示例
{
  "ok": false,
  "code": "balance_too_low",
  "error": "balance is below one hour of rent"
}

常用流程

租用设备、连接、停止

  1. 1.
    GET获取市场列表的筛选值

    可选。获取可用于筛选的 GPU 和 CPU 型号名称。

  2. 2.
    GET列出可租用的设备

    查找设备。记下其 machine_id 和 device_no。

  3. 3.
    GET列出预置镜像

    选择一个预置 image_id,或使用你自己的公开镜像。

  4. 4.
    POST租用设备

    使用新的 Idempotency-Key 租用。你的余额必须至少足够支付一小时租金。记下返回的 id。

  5. 5.
    GET列出你的实例

    轮询,直到实例的 phase 变为 running。

  6. 6.
    GET获取实例的 SSH 连接信息

    获取 SSH 命令和密码。请将其作为机密妥善保管。

  7. 7.
    POST停止实例

    使用完毕后停止实例。租金结算至当前时间。

为设备定价并上架到市场

  1. 1.
    GET列出你的设备

    查找你的设备的 machine_id(使用 group 限定在同一分组内)。

  2. 2.
    POST设置或清除租金价格

    设置 price_per_gpu_hr(GPU 设备)或 price_per_cpu_hr(纯 CPU 设备)。

  3. 3.
    POST检查设备能否上架

    查看哪些设备可以上架;reasons 列出存在的问题。

  4. 4.
    GET对设备执行上架检查

    可选。查看未通过检查的设备的逐条规则详情。

  5. 5.
    POST上架或下架设备

    发送 listed: true 将设备上架到市场。

修改启动命令,或重新执行

  1. 1.
    PUT修改启动命令

    保存新命令。再次保存相同的命令不会有任何操作,因此可以放心重试。

  2. 2.
    POST重启容器

    要重新执行同一条命令,请改为重启容器。每次调用都会重启一次,因此不要自动重试。

  3. 3.
    GET列出你的实例

    轮询,直到 startup.rev 等于返回的 startup_rev,且 startup.state 不再是 pending。

设置单台设备的超频

  1. 1.
    GET获取单台设备

    读取 gpus[].busid 和当前的 oc(revision、cards)。

  2. 2.
    PUT设置单台设备的超频参数

    为每块要修改的 GPU 发送全部 6 项值。返回 409 oc_task_managed 时,带上 manual_only: true 重新发送。

  3. 3.
    GET获取单台设备

    轮询,直到 oc.applied_revision 等于返回的 revision;失败原因见 oc.rejected 和 oc.result。

升级 Agent 并跟踪进度

  1. 1.
    GET列出你的设备

    查找 agent_version 低于 https://down.suanzu.ai/VERSION 正式版的设备(见业务规则「Agent 版本」;命令不看当前版本,比正式版新的正式版或 beta 也会被装回正式版)。按 group_id 拆分 machine_id,每个请求最多 100 台。

  2. 2.
    POST升级设备 Agent

    每个分组发一个请求。记下 issued[].cmd_id;rejected[].reason 列出没有下发命令的设备(例如 rented、command_pending)。

  3. 3.
    GET列出设备的命令与消息

    每 15 秒轮询一次,直到带你的 cmd_id 的项 state 为 ok 或 error。为 error 时,原因见 latest_title 和 note(expired、timeout、interrupted)。

  4. 4.
    GET列出设备的消息

    可选。升级失败时,从 payload_gz 读取安装日志。

  5. 5.
    GET列出你的设备

    得到 ok 后,从下一次心跳起 agent_version 显示新版本。

重启设备并确认恢复

  1. 1.
    GET列出你的设备

    查找设备,例如 reason=gpu_dropped。按 group_id 拆分,每个请求最多 100 台。

  2. 2.
    POST重启设备

    记下 issued[].cmd_id。被租用的设备会以 rented 被拒(用 POST /api/v1/host/machines/listing 下架不会结束租用)。

  3. 3.
    GET列出设备的命令与消息

    每 15 秒轮询一次,直到带你的 cmd_id 的项为 state: ok 且 note: rebooted(设备已重新开机并上线)。note: timeout = 600 秒内没有恢复。

  4. 4.
    GET获取单台设备

    确认问题已消失,例如查看 gpus[].dropped 和 status_reasons。

监控离线设备

  1. 1.
    GET获取设备汇总(总体及各分组)

    每 5 分钟读取一次 all 和 groups 中各分组的 offline。为 0 时到此为止。

  2. 2.
    GET列出你的设备

    用 connectivity=offline 和 per_page=1000 列出,按 page 翻到 total_pages。last_heartbeat_at 表示从何时起离线;最后一次心跳后 120 秒判为离线。被租用的设备离线满 600 秒会停租。

  3. 3.
    GET列出设备的命令与消息

    可选。读取设备离线前的最新消息。

跨多个分组列出设备

  1. 1.
    GET列出你的分组

    获取密钥可用的每个分组的 id(你自己的和共享给你的,shared: true)。

  2. 2.
    GET列出你的设备

    不传 group 时,一个列表返回密钥可见的全部设备。传 group 时每个分组一个请求;按 page 翻到 total_pages(per_page 最大 1000)。

  3. 3.
    GET获取设备汇总(总体及各分组)

    可选。一次调用拿到各分组的汇总。

运行使用已保存钱包的租用方任务

  1. 1.
    POST保存钱包/变量

    保存钱包地址。记下 wallet_var.id。

  2. 2.
    POST新建计算任务模板

    自定义任务:添加一个 vars 项,ref 设为该 id,value: ""。HiveOS 任务:wallet_ref 设为该 id,hive.wallet 设为 ""。记下 template.id。

  3. 3.
    PUT设置实例的计算任务

    把模板设到一个 running 状态的实例上。

  4. 4.
    GET获取实例的计算任务

    每 15 秒轮询一次,直到 states[] 中你的 binding_id 为 state: running 且 revision 相同。之后 HiveOS 任务会上报 stats(算力见 params.khs)。

  5. 5.
    PUT修改钱包/变量

    可选。修改值会重启所有用到它的任务。

拉取计算任务日志

  1. 1.
    GET列出设备的计算任务

    找到任务的 binding_id。

  2. 2.
    POST拉取计算任务日志

    对这一台设备和这个任务发送命令。记下 issued[0].cmd_id;出现 rejected[].reason(例如 rented、task_not_found)表示没有下发命令。

  3. 3.
    GET列出一条命令的消息

    每 10 秒轮询一次,直到出现 ok 或 error 消息。日志是 ok 消息的 payload_gz(gzip + base64,最后 500 行)。

为一台设备安装或更换 NVIDIA 驱动

  1. 1.
    POST上架或下架设备

    设备已上架时,先发送 listed: false 下架(被租用的设备不能安装驱动)。

  2. 2.
    GET列出设备可安装的 NVIDIA 驱动版本

    从 options 里选一个 version;返回 409 时 code 说明设备现在为什么不能安装。cuda_block 不为 null 时用 cuda: false。

  3. 3.
    POST安装或更换设备的 NVIDIA 驱动

    对这一台设备发送。记下 issued[0].cmd_id;出现 rejected[].reason 表示没有下发命令。不要盲目重试。

  4. 4.
    GET查看长命令的进度与日志

    可选。执行中每 5 秒读一次阶段、下载百分比和新增日志(offset = next_offset)。

  5. 5.
    GET列出设备的命令与消息

    每 15 秒轮询一次,直到你的 cmd_id 的 state 为 ok(note: rebooted,设备已带着新驱动回来)或 error(原因码在 latest_title 的方括号里)。

市场

已上架可供租用的设备。公开接口,无需密钥。

GET/api/v1/market/machines

列出可租用的设备

返回一页当前可租用的设备。要获取下一页,将本页的 next 值作为 cursor 传入,并使用相同的筛选条件和 sort。所有筛选条件均为可选,以 AND 组合;重复的参数(gpu、cpu)匹配其中任一值。未知的查询参数会被拒绝并返回 400。

示例:8 卡 CMP 50HX 设备,每 GPU 每小时最高 0.100 USDT,按价格从低到高排序:GET /api/v1/market/machines?gpu=CMP%2050HX&count=8&priceMax=0.100&sort=price_asc

权限
公开
API 密钥
可选
限流类
read

参数

  • sortstring· query

    排序方式。排序值相同时按设备 ID 排序。

    可选值price_ascprice_desctotal_asctotal_desccores_desc默认price_asc示例price_asc

  • pageSizeinteger· query

    每页设备数。大于 200 的值按 200 处理。

    范围0 – 200默认50

  • cursorstring· query

    上一页的 next 值。获取第一页时省略。仅在 sort 相同时有效。

  • gpustring[]· query

    GPU 型号,须与 GET /api/v1/market/facets 返回的 gpu_models[].name 完全一致(例如 CMP 50HX,需 URL 编码)。重复传入可匹配多个型号中的任一个。

    示例CMP 50HX可重复

  • cpustring[]· query

    CPU 型号,须与 GET /api/v1/market/facets 返回的 cpu_models[].name 完全一致。重复传入可匹配多个型号中的任一个。

    可重复

  • cpuOnlystring· query

    仅限无 GPU 的设备。

    可选值1true0false

  • countinteger· query

    GPU 数量,精确匹配。0 = 不限。

    范围≥ 0示例8

  • vramMininteger· query

    每块 GPU 的最小显存,单位 GB。

    范围≥ 0

  • cudaMinnumber· query

    驱动支持的最低 CUDA 版本,例如 12.8。

    范围≥ 0

  • priceMaxstring· query

    单价上限,单位为 USDT/小时(GPU 设备按每块 GPU 计,纯 CPU 设备按每颗 CPU 计)。十进制字符串,最多 3 位小数。0 = 不限。

    示例0.100格式^\d{1,7}(\.\d{1,3})?$

  • minSocketsinteger· query

    最少 CPU 颗数。

    范围≥ 0

  • minCoresinteger· query

    最少 CPU 总核数。

    范围≥ 0

  • ramMininteger· query

    最小内存,单位 GB。

    范围≥ 0

  • storageMininteger· query

    最小磁盘总容量,单位 GB。

    范围≥ 0

  • storageTypestring· query

    磁盘类型。(USB 可能出现在结果中,但不能用作筛选条件。)

    可选值NVMeSSDHDD

返回

  • 200OK

    一页设备。

    返回字段(38)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    request_timeout。请稍后重试。(查询失败返回 500 internal。)

    • request_timeout

示例

curl 'https://suanzu.ai/api/v1/market/machines?sort=price_asc&gpu=CMP%2050HX&count=8&priceMax=0.100'
GET/api/v1/market/machines/{machine_id}

获取单台可租用设备

返回的字段与市场列表中的单项相同。未上架、当前不可租用或不存在的设备,均返回 404 machine_not_found。

权限
公开
API 密钥
可选
限流类
read

参数

  • machine_idstring· path必填

    市场列表中的 machine_id(UUID)。不接受设备编号(SZ-000014)。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

返回

  • 200OK

    该设备。

    返回字段(34)
  • 404Not Found

    machine_not_found。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    request_timeout。请稍后重试。(查询失败返回 500 internal。)

    • request_timeout

示例

curl 'https://suanzu.ai/api/v1/market/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58'
GET/api/v1/market/facets

获取市场列表的筛选值

返回市场上当前的 GPU 和 CPU 型号、各数值筛选条件的范围以及价格范围。最多缓存 10 秒。

count 是当前可租用的设备数量;等于 GET /api/v1/market/machines?gpu=<name>(或 ?cpu=<name>)的 total。将 name 按返回原样传给列表的 gpu / cpu 参数(大小写和空格保持一致;空格需 URL 编码)。没有数据的范围不会出现在 ranges 中。市场上没有设备时,price_range 为 null。

权限
公开
API 密钥
可选
限流类
read

返回

  • 200OK

    筛选值。

    返回字段(11)
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    request_timeout。请稍后重试。(查询失败返回 500 internal。)

    • request_timeout

示例

curl 'https://suanzu.ai/api/v1/market/facets'

租用方

租用设备,并管理你的实例、余额和充值。需要 renter:read 或 renter:write。

GET/api/v1/renter/images

列出预置镜像

可用于租用的预置容器镜像(即 POST /api/v1/renter/leases 中的 image_id)。gpu: true 的镜像用于 GPU 设备,gpu: false 的镜像用于纯 CPU 设备。min_cuda 是设备驱动必须支持的最低 CUDA 版本(为空表示无要求)。

权限
renter:read
API 密钥
必填
限流类
read

返回

  • 200OK

    预置镜像。

    返回字段(6)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/renter/images' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/renter/leases

列出你的实例

分页列出你租用的实例(page / per_page)。tab=current(默认)列出尚未结束的实例,包括仍在交付中的实例;tab=history 列出已结束的实例。页码超过最后一页时返回最后一页。

在 current 标签下,counts 和 gpu_models 涵盖你所有当前实例,不受筛选条件影响;hourly_total 是正在计费的实例的每小时价格总和。通过 phase 区分交付中(pulling → preparing → starting)与 running。

权限
renter:read
API 密钥
必填
限流类
read_pg

参数

  • tabstring· query

    可选值currenthistory默认current

  • phasestring· query

    仅限 current 标签。delivery = pulling、preparing、starting 中的任一个。

    可选值runningdeliverypullingpreparingstarting

  • gpustring· query

    仅限 current 标签。确切的 GPU 型号,与 gpu_models 中一致。

  • sortstring· query

    仅限 current 标签。

    可选值machinegpuModelsimagegpuUtilcpumemoryratestartedstatus默认machine

  • orderstring· query

    仅限 current 标签。

    可选值ascdesc

  • reasonstring· query

    仅限 history 标签。仅返回因该 end_reason 结束的实例。

    可选值renterbalance_exhaustedoffline_rentedverdictadmindelivery_failed

  • daysinteger· query

    仅限 history 标签。仅返回最近 N 天内结束的实例。0 = 不限。

    可选值073090

  • tagsstring· query

    以逗号分隔的标签 ID(来自 GET /api/v1/renter/tags);匹配带有其中任一标签的实例。

    示例12,15

  • qstring· query

    在设备编号、GPU 型号、镜像和标签名称中搜索,不区分大小写。最多 64 个字符。

    长度≤ 64

  • pageinteger· query

    范围1 – 1000000默认1

  • per_pageinteger· query

    current 标签默认 50,history 标签默认 20。

    范围1 – 1000

返回

  • 200OK

    一页实例。history 标签仅包含 items 和分页字段。

    返回字段(138)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/renter/leases?tags=12,15' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/leases

租用设备

租用一整台设备。实例交付后开始计费,按分钟扣费。你的余额必须至少足够支付一小时租金。新实例的初始阶段为 pulling;轮询 GET /api/v1/renter/leases 获取其状态。

使用 API 密钥时必须提供 Idempotency-Key。 如果请求超时,使用相同的幂等键和请求体重新发送:你会得到同一个订单(200,相同的 id),而不会重复租用,即使该订单此后已结束。失败的订单不会占用该幂等键。

权限
renter:write
API 密钥
必填
限流类
order

参数

  • Idempotency-Keystring· header必填

    由你自定的任意唯一字符串,1-64 个可见 ASCII 字符(不含空格)。每个新订单使用一个新值。

    长度1 – 64示例order-20261106-0001格式^[\x21-\x7e]{1,64}$

请求体application/json

image_id 和 image 必须且只能提供一个。startup_cmd 和 tasks 不能同时设置。请求体最大 64 KiB。

  • machine_idstring必填

    来自市场列表。

  • device_nostring必填

    来自市场列表;必须与 machine_id 对应。

  • price_hrstring必填

    你看到的整机每小时价格:市场列表的 total_price_hr 原样传入(十进制字符串)。与现价不同时不下单,返回 409 price_changed 并带上现价。

    格式^(0|[1-9][0-9]{0,15})(\.[0-9]{1,3})?$

  • image_idstring

    GET /api/v1/renter/images 返回的预置镜像 ID。

  • imagestring

    来自公共镜像仓库的你自己的镜像,例如 docker.io/library/ubuntu:22.04。

  • startup_cmdstring

    实例启动后在其内部执行的 shell 命令。最多 4096 字节 UTF-8,不能包含 NUL。

    长度≤ 4096

  • tasksobject[]

    交付后要运行的计算任务,来自你自己的任务模板(id 取自 GET /api/v1/renter/task-templates)。每个模板最多使用一次;下单时 gpus 必须为 null(全部 GPU)。

    长度≤ 16

  • tasks[].template_idstring必填

    GET /api/v1/renter/task-templates 返回的模板 id。

  • tasks[].gpusnull

返回

  • 200OK

    已下单(对于重复的 Idempotency-Key,返回同一订单)。

    返回字段(2)
  • 400Bad Request

    bad_request(字段缺失或无效,或 Idempotency-Key 格式错误)、idempotency_key_required、image_invalid(image_id 不存在时也返回此错误)、image_registry_unsupported、image_gpu_mismatch、image_cuda_too_old、startup_cmd_invalid、task_limit_reached、task_template_duplicate、task_gpus_invalid、task_config_too_large。

    • bad_request
    • idempotency_key_required
    • image_invalid
    • image_registry_unsupported
    • image_gpu_mismatch
    • image_cuda_too_old
    • startup_cmd_invalid
    • task_limit_reached
    • task_template_duplicate
    • task_gpus_invalid
    • task_config_too_large
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    own_machine(不能租用自己的设备),或 API 密钥错误(api_key_scope_denied、api_key_ip_denied、api_key_route_not_allowed)。

    • own_machine
  • 404Not Found

    template_not_found:tasks 中的某个任务模板不存在或不属于你。

    • template_not_found
  • 409Conflict

    machine_not_rentable、machine_rented、machine_configuration_changed(刷新市场后重试)、price_changed(你加载市场之后出租方或平台改了价格;回包带现价 price_hr(整机)和 price_per_hr(每张卡或每颗 CPU,可能没有);用新的 price_hr 和新的 Idempotency-Key 重新下单)、balance_too_low(余额不足一小时租金)。

    • machine_not_rentable
    • machine_rented
    • machine_configuration_changed
    • price_changed
    • balance_too_low
  • 422Unprocessable Content

    idempotency_mismatch:该幂等键已用于另一个订单。

    • idempotency_mismatch
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Idempotency-Key: order-20261106-0001' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_id": "314d1670-872d-4d8d-be94-a4ceea1c0c58",
  "device_no": "SZ-000014",
  "price_hr": "0.848",
  "image_id": "cuda-12-runtime"
}'
GET/api/v1/renter/leases/{lease_id}/settles

列出单个实例的扣费记录

返回实例的计费摘要(lease)及其扣费记录,按时间倒序,默认每页 20 条。传入 at(某个 period_end 值)代替 page,可获取包含该扣费记录的页。超出末页时返回空的 items。

权限
renter:read
API 密钥
必填
限流类
read_pg

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

  • pageinteger· query

    范围1 – 1000000默认1

  • per_pageinteger· query

    范围1 – 50默认20

  • atinteger· query

    某条扣费记录的 period_end。不能与 page 同时使用。

    范围≥ 1

返回

  • 200OK

    计费摘要和一页扣费记录。

    返回字段(17)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found:租约不存在,或不属于你。

    • lease_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/renter/leases/57/settles' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/renter/leases/{lease_id}/container-log

读取容器日志

返回容器日志(docker logs:启动命令的输出,以及写到 /proc/1/fd/1 的内容;最后 200 行、最多 64 KiB)的最新完整一份。日志按请求获取:先调用 POST .../container-log,然后轮询本接口,直到 log.req 等于返回的 req。日志到达前 log 为 null。仅在实例处于 running 时可用。租用结束后日志即删除。

权限
renter:read
API 密钥
必填
限流类
read_pg

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

返回

  • 200OK

    最新日志。

    返回字段(8)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found:租约不存在,或不属于你。

    • lease_not_found
  • 409Conflict

    lease_not_running:实例不处于 running 阶段。

    • lease_not_running
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/renter/leases/57/container-log' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/leases/{lease_id}/container-log

请求实例发送最新容器日志

请求设备发送当前的容器日志尾部。返回请求编号 req;通过 GET .../container-log 读取日志。每个实例最多每 5 秒请求一次。仅在实例处于 running 时可用。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

返回

  • 200OK

    请求已发送。

    返回字段(2)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found:租约不存在,或不属于你。

    • lease_not_found
  • 409Conflict

    lease_not_running:实例不处于 running 阶段。

    • lease_not_running
  • 429Too Many Requests

    container_log_rate_limited(距上次请求不足 5 秒;响应体中还包含以秒为单位的 retry_after),或 rate_limited。两者都会返回 Retry-After 响应头。

    • container_log_rate_limited
    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases/57/container-log' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/renter/leases/{lease_id}/access

获取实例的 SSH 连接信息

返回密码。 提供实例容器的 SSH 命令和密码。请将响应作为机密处理:不要记录到日志中。

仅当 status 为 ready 时才会填写 ssh_command;只要实例在运行,就会返回 password。用户始终为 root(在你的容器内)。需要 renter:write(只读密钥无法获取密码)。

权限
renter:write
API 密钥
必填
限流类
remote

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

返回

  • 200OK

    连接信息。

    返回字段(8)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found:租约不存在,或不属于你。

    • lease_not_found
  • 409Conflict

    lease_not_running,或 remote_not_ready(连接尚未建立,请稍后重试)。

    • lease_not_running
    • remote_not_ready
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    remote_unconfigured、remote_relay_failed 或 request_timeout。

    • remote_unconfigured
    • remote_relay_failed
    • request_timeout

示例

curl 'https://suanzu.ai/api/v1/renter/leases/57/access' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/leases/{lease_id}/stop

停止实例

停止实例,并结算截至当前的租金。交付期间(开始计费前)停止会取消订单,不收费。对已结束的实例再次停止,同样返回 200。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found:租约不存在,或不属于你。

    • lease_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases/57/stop' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/leases/{lease_id}/access/password

修改实例的 SSH 密码

设置新的 SSH 密码,并断开当前所有 SSH 会话。响应中不包含新密码,请通过 GET .../access 获取。仅在实例处于 running 状态时可用。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found:租约不存在,或不属于你。

    • lease_not_found
  • 409Conflict

    lease_not_running 或 remote_not_ready。

    • lease_not_running
    • remote_not_ready
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    remote_unconfigured 或 request_timeout。

    • remote_unconfigured
    • request_timeout

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases/57/access/password' \
  -H 'Authorization: Bearer sz_live_...'
PUT/api/v1/renter/leases/{lease_id}/startup

修改启动命令

保存新的启动命令,并用该命令重启容器。命令与当前相同时不做任何操作:不重启容器,startup_rev 不变,因此可以放心重试。要重新执行同一条命令,请使用 POST .../startup/restart。传入空字符串会清除命令。设置命令会删除该实例的所有计算任务。仅在实例处于 running 状态时可用。返回当前的 startup_rev。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

请求体application/json

  • startup_cmdstring必填

    UTF-8 编码,最多 4096 字节,不能包含 NUL。为空表示无命令。

    长度≤ 4096

返回

  • 200OK

    已保存,容器正在重启。如果命令没有变化,则不做任何操作,startup_rev 不变。

    返回字段(2)
  • 400Bad Request

    bad_request(缺少 startup_cmd 或其不是字符串)、startup_cmd_invalid。

    • bad_request
    • startup_cmd_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found:租约不存在,或不属于你。

    • lease_not_found
  • 409Conflict

    lease_not_running,或 rebuild_in_progress(正在重建,结束后再试)。

    • lease_not_running
    • rebuild_in_progress
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PUT 'https://suanzu.ai/api/v1/renter/leases/57/startup' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "startup_cmd": "python3 /workspace/train.py"
}'
POST/api/v1/renter/leases/{lease_id}/startup/restart

重启容器

重启容器。容器内的进程会被结束,文件会保留。如果设置了启动命令,命令不变,容器启动后会重新执行,startup.runs 从 1 重新计数。有没有启动命令都可以用,仅在实例处于 running 状态时可用。返回新的 startup_rev。每次成功调用都会重启一次容器,请不要自动重试。 如果请求超时,请先调用 GET /api/v1/renter/leases:如果 startup.rev 已经等于之前的 startup_rev + 1,说明重启已经生效。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

返回

  • 200OK

    容器正在重启。

    返回字段(2)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found:租约不存在,或不属于你。

    • lease_not_found
  • 409Conflict

    lease_not_running:实例不在运行中。rebuild_in_progress:正在重建,结束后再试。

    • lease_not_running
    • rebuild_in_progress
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases/57/startup/restart' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/leases/{lease_id}/rebuild

重建实例

在同一台设备上重建 running 实例的容器:换一个镜像(image_id 或 image,同下单),或用现有镜像重建(发送 {};会重新拉取镜像,标签已指向新版本时会更新)。容器内的文件会全部删除。 显卡、SSH 连接信息和租金不变,计费不停。

拉取新镜像期间旧容器照常运行。拉取失败时旧容器不变。新容器启动失败时会保留供你排查,旧容器已删除;请再次重建或停止租用。结果看 GET /api/v1/renter/leases 每项的 rebuild(pending → pulling → switching → done / failed)。

可选的 startup_cmd 在同一步设置新容器的启动命令(规则同 PUT .../startup;不传表示保留当前命令,传空字符串表示清除)。设置非空命令会删除该实例的所有计算任务。重建进行中时,startup/restart、PUT .../startup 和再次重建都返回 409 rebuild_in_progress。

每次成功调用都会重建一次实例,请不要自动重试。 如果请求超时,请先调用 GET /api/v1/renter/leases:如果 rebuild.rev 已经等于之前的值 + 1,说明重建已被受理。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

请求体application/json

image_id 和 image 最多提供一个;都不提供({})表示用现有镜像重建。请求体最大 64 KiB。

  • image_idstring

    GET /api/v1/renter/images 返回的预置镜像 ID。

  • imagestring

    来自公共镜像仓库的你自己的镜像,例如 docker.io/library/ubuntu:22.04。

  • startup_cmdstring

    新容器的启动命令。不传表示保留当前命令;为空表示无命令。最多 4096 字节 UTF-8,不能包含 NUL。

    长度≤ 4096

返回

  • 200OK

    已受理,设备会在几秒内开始重建。

    返回字段(2)
  • 400Bad Request

    bad_request(不是 JSON 对象、有未知字段、同时提供 image_id 和 image,或其中一个为空)、image_unchanged(就是当前镜像;要重新拉取请发送 {})、image_invalid、image_registry_unsupported、image_gpu_mismatch、image_cuda_too_old、startup_cmd_invalid。

    • bad_request
    • image_unchanged
    • image_invalid
    • image_registry_unsupported
    • image_gpu_mismatch
    • image_cuda_too_old
    • startup_cmd_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found:租约不存在,或不属于你。

    • lease_not_found
  • 409Conflict

    lease_not_running、rebuild_in_progress(请等待当前重建结束)或 agent_outdated(设备的 agent 版本过低,需要出租方升级)。

    • lease_not_running
    • rebuild_in_progress
    • agent_outdated
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases/57/rebuild' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "image": "ghcr.io/foo/bar:1.2"
}'
GET/api/v1/renter/account

获取你的租用方余额

你的租用方余额(USDT)。账户从未产生流水时,updated_at 为 null。

权限
renter:read
API 密钥
必填
限流类
read_pg

返回

  • 200OK

    余额。

    返回字段(2)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/renter/account' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/renter/ledger

列出租用方余额流水

充值、租金扣费和推荐分润,按时间倒序。租金记录的 amount 为负数,实例持续计费时会原地更新(updated_at)。referral 是你邀请的用户租用设备时给你的推荐分润,进入租用方余额(source 为 referral)。注意:此接口使用 page_size 分页,而不是 per_page。

权限
renter:read
API 密钥
必填
限流类
read_pg

参数

  • pageinteger· query

    范围1 – 1000000默认1

  • page_sizeinteger· query

    范围1 – 100默认20

  • typestring· query

    按类型筛选。referral = 进入租用方余额的推荐分润。

    可选值depositrentreferral

返回

  • 200OK

    一页流水。

    返回字段(10)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/renter/ledger' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/renter/task-templates

列出你的计算任务模板

你自己的计算任务模板,按创建时间正序。租用时(POST /api/v1/renter/leases)或设置任务时(PUT /api/v1/renter/leases/{lease_id}/tasks)把 id 填进 tasks[].template_id。

权限
renter:read
API 密钥
必填
限流类
read_pg

返回

  • 200OK

    模板列表。

    返回字段(36)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/renter/task-templates' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/task-templates

新建计算任务模板

在你的账户下新建计算任务模板。kind: custom 运行你自己的程序(custom.start_command,可选 custom.package_url);kind: hive 使用 HiveOS 格式的设置(hive)。请求体最大 256 KiB,模板本身最大 64 KiB。ref / wallet_ref 只能指向你自己的钱包/变量(GET /api/v1/renter/wallet-vars)。

权限
renter:write
API 密钥
必填
限流类
write

请求体application/json

计算任务模板。kind 为 custom 时提供 custom,kind 为 hive 时提供 hive。变量、宏和程序包规则见简介中的「计算任务模板」。

  • namestring必填
  • kindstring必填

    可选值customhive

  • descriptionstring
  • varsobject[]

    仅自定义任务。程序的环境变量(最多 64 个)。设置 ref 可从你的某条钱包/变量取值;此时 value 发送空字符串,它会被替换。

  • vars[].keystring必填

    须匹配 ^[A-Za-z_][A-Za-z0-9_]*$;不能以 SUANZU_ 开头,不能是保留名。

  • vars[].valuestring必填

    最多 4 KiB。带 ref 时也必填(发送空字符串)。

  • vars[].refstring | null

    你的某条钱包/变量的 id,或 null。

  • customobject
  • custom.start_commandstring

    用 bash -c 运行。最多 16 KiB。

  • custom.package_urlstring

    可选。启动前下载的程序包。

  • custom.extractboolean

    默认true

  • hiveobject
  • hive.minerstring

    程序包目录名。留空 = 从 install_url 的文件名推出。

  • hive.coinstring

    以 DIGITAL_CASH 传入。

  • hive.walletstring

    替换 %WAL%。带 wallet_ref 时发送空字符串。

  • hive.install_urlstring

    指向 .tar.gz / .tgz 程序包的 http(s) 链接。

  • hive.algostring

    以 CUSTOM_ALGO 传入。

  • hive.templatestring

    这个字段以及 url、pass、user_config 中的宏会被替换。

  • hive.urlstring
  • hive.passstring
  • hive.user_configstring
  • accelobject
  • accel.downloadboolean

    程序包下载加速(仅限 GitHub 发布附件)。

  • wallet_refstring | null

    仅 HiveOS。从你的某条钱包/变量取 hive.wallet。

  • followstring

    跟随最新版:latest = 只跟正式版,latest_beta = 含预发布。只用于带版本标签的 GitHub 发布附件下载地址,否则返回 400 follow_github_only。不带 = ""(模板整份替换,不带就会关掉跟随)。

    可选值latestlatest_beta默认

返回

  • 200OK

    已新建。template 的字段与 GET /api/v1/renter/task-templates 的列表项相同。

    返回字段(2)
  • 400Bad Request

    bad_request、template_invalid(error 文本指出是哪个字段)、hive_vars_unsupported、hive_wallet_required、wallet_var_unavailable(某个 ref / wallet_ref 不是你的)、task_config_too_large、package_url_private_host、package_url_github_query、accel_download_github_only 或 follow_github_only(跟随最新版只用于带版本标签的 GitHub 发布地址)。

    • bad_request
    • template_invalid
    • hive_vars_unsupported
    • hive_wallet_required
    • wallet_var_unavailable
    • task_config_too_large
    • package_url_private_host
    • package_url_github_query
    • accel_download_github_only
    • follow_github_only
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/task-templates' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Pearl",
  "kind": "custom",
  "description": "",
  "vars": [
    {
      "key": "WALLET",
      "value": "prl1qexamplewallet0000"
    }
  ],
  "custom": {
    "start_command": "./run.sh",
    "package_url": "https://github.com/example/miner/releases/download/v1.0/miner.tar.gz",
    "extract": true
  },
  "accel": {
    "download": true
  }
}'
PUT/api/v1/renter/task-templates/{template_id}

替换计算任务模板

整份替换模板(与新建一样发送全部字段)。下发到设备的内容有变化时,version 加 1,使用该模板的运行中实例随下一次心跳应用新设置。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • template_idstring· path必填

    你的计算任务模板的 id(来自 GET /api/v1/renter/task-templates)。

    示例9c2e5b7a1d3f4e6a格式^[0-9a-f]{16}$

请求体application/json

计算任务模板。kind 为 custom 时提供 custom,kind 为 hive 时提供 hive。变量、宏和程序包规则见简介中的「计算任务模板」。

  • namestring必填
  • kindstring必填

    可选值customhive

  • descriptionstring
  • varsobject[]

    仅自定义任务。程序的环境变量(最多 64 个)。设置 ref 可从你的某条钱包/变量取值;此时 value 发送空字符串,它会被替换。

  • vars[].keystring必填

    须匹配 ^[A-Za-z_][A-Za-z0-9_]*$;不能以 SUANZU_ 开头,不能是保留名。

  • vars[].valuestring必填

    最多 4 KiB。带 ref 时也必填(发送空字符串)。

  • vars[].refstring | null

    你的某条钱包/变量的 id,或 null。

  • customobject
  • custom.start_commandstring

    用 bash -c 运行。最多 16 KiB。

  • custom.package_urlstring

    可选。启动前下载的程序包。

  • custom.extractboolean

    默认true

  • hiveobject
  • hive.minerstring

    程序包目录名。留空 = 从 install_url 的文件名推出。

  • hive.coinstring

    以 DIGITAL_CASH 传入。

  • hive.walletstring

    替换 %WAL%。带 wallet_ref 时发送空字符串。

  • hive.install_urlstring

    指向 .tar.gz / .tgz 程序包的 http(s) 链接。

  • hive.algostring

    以 CUSTOM_ALGO 传入。

  • hive.templatestring

    这个字段以及 url、pass、user_config 中的宏会被替换。

  • hive.urlstring
  • hive.passstring
  • hive.user_configstring
  • accelobject
  • accel.downloadboolean

    程序包下载加速(仅限 GitHub 发布附件)。

  • wallet_refstring | null

    仅 HiveOS。从你的某条钱包/变量取 hive.wallet。

  • followstring

    跟随最新版:latest = 只跟正式版,latest_beta = 含预发布。只用于带版本标签的 GitHub 发布附件下载地址,否则返回 400 follow_github_only。不带 = ""(模板整份替换,不带就会关掉跟随)。

    可选值latestlatest_beta默认

返回

  • 200OK

    已保存。template 为更新后的模板。

    返回字段(2)
  • 400Bad Request

    bad_request、template_invalid(error 文本指出是哪个字段)、hive_vars_unsupported、hive_wallet_required、wallet_var_unavailable(某个 ref / wallet_ref 不是你的)、task_config_too_large、package_url_private_host、package_url_github_query、accel_download_github_only 或 follow_github_only(跟随最新版只用于带版本标签的 GitHub 发布地址)。

    • bad_request
    • template_invalid
    • hive_vars_unsupported
    • hive_wallet_required
    • wallet_var_unavailable
    • task_config_too_large
    • package_url_private_host
    • package_url_github_query
    • accel_download_github_only
    • follow_github_only
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    template_not_found:模板不存在,或不属于你。

    • template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PUT 'https://suanzu.ai/api/v1/renter/task-templates/9c2e5b7a1d3f4e6a' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Pearl",
  "kind": "custom",
  "description": "",
  "vars": [
    {
      "key": "WALLET",
      "value": "prl1qexamplewallet0000"
    }
  ],
  "custom": {
    "start_command": "./run.sh --fast",
    "package_url": "https://github.com/example/miner/releases/download/v1.0/miner.tar.gz",
    "extract": true
  },
  "accel": {
    "download": true
  }
}'
DELETE/api/v1/renter/task-templates/{template_id}

删除计算任务模板

删除没有实例在用的模板。仍有实例在用时返回 409 task_template_in_use 并带 machine_count;请先从这些实例中移除该任务。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • template_idstring· path必填

    你的计算任务模板的 id(来自 GET /api/v1/renter/task-templates)。

    示例9c2e5b7a1d3f4e6a格式^[0-9a-f]{16}$

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    template_not_found:模板不存在,或不属于你。

    • template_not_found
  • 409Conflict

    task_template_in_use:仍有实例在用该模板;machine_count 为实例数。

    • task_template_in_use
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X DELETE 'https://suanzu.ai/api/v1/renter/task-templates/9c2e5b7a1d3f4e6a' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/renter/leases/{lease_id}/tasks

获取实例的计算任务

实例的计算任务及其最新消息、统计和状态,并附上设备的 GPU(gpus,用于在 PUT .../tasks 中选卡)。交付期间也可调用。实例尚未上报当前任务列表的统计时,stats_at 为 null,stats / states 为空。

权限
renter:read
API 密钥
必填
限流类
read_pg

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

返回

  • 200OK

    任务。

    返回字段(57)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found:租约不存在,或不属于你。

    • lease_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/renter/leases/57/tasks' \
  -H 'Authorization: Bearer sz_live_...'
PUT/api/v1/renter/leases/{lease_id}/tasks

设置实例的计算任务

整份设置一个实例的任务列表;tasks: [] 移除全部任务。最多 16 个任务,每个模板最多使用一次。要让某个任务保持原样运行,请带上它的 binding_id,并使用相同的模板和 GPU:它会保留 ID 且不会重启。gpus 为 null = 全部 GPU;否则填 GET .../tasks 中 gpus 的总线号。设置任务会清除启动命令。仅在实例处于 running 时可用。再次保存相同的列表不会有任何变化,因此可以放心重试。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

请求体application/json

  • tasksobject[]必填

    任务,每项来自你的一个模板。每个模板最多使用一次。

    长度≤ 16

  • tasks[].binding_idstring

    可选。要保留的现有任务(来自 GET .../tasks)。

  • tasks[].template_idstring必填

    GET /api/v1/renter/task-templates 返回的 id。

  • tasks[].gpusstring[] | null

    GPU 总线号,升序且不重复。null = 全部 GPU。

返回

  • 200OK

    已保存。列出新增、更新、移除和保留的任务。

    返回字段(12)
  • 400Bad Request

    bad_request、task_limit_reached(超过 16 个任务)、task_template_duplicate、task_gpus_invalid(某个总线号不是该实例的 GPU)或 task_config_too_large。

    • bad_request
    • task_limit_reached
    • task_template_duplicate
    • task_gpus_invalid
    • task_config_too_large
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found,或 template_not_found(某个模板不属于你或不存在)。

    • lease_not_found
    • template_not_found
  • 409Conflict

    lease_not_running:实例不处于 running 阶段。

    • lease_not_running
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PUT 'https://suanzu.ai/api/v1/renter/leases/57/tasks' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "tasks": [
    {
      "binding_id": "3f9a0c1d2e4b5a60",
      "template_id": "9c2e5b7a1d3f4e6a",
      "gpus": null
    }
  ]
}'
POST/api/v1/renter/leases/tasks

批量修改多个实例的计算任务

对你的 1-500 个实例执行同一个操作。add 保留每个实例的任务并追加所给模板(实例已有的模板会跳过);replace 把所给模板作为完整列表;pause、resume、restart 作用于全部任务;clear 移除全部任务。tasks 只用于 add / replace。每个实例单独成功或失败:见 results[].ok 和 results[].code(例如 lease_not_found、lease_not_running、task_gpus_invalid)。restart 每次都会重启,请不要自动重试。

权限
renter:write
API 密钥
必填
限流类
write

请求体application/json

  • lease_idsstring[]必填

    租约 ID,十进制字符串(GET /api/v1/renter/leases 返回的 id)。1-500 项;重复项会合并。

    长度1 – 500格式^[1-9][0-9]{0,17}$

  • actionstring必填

    可选值addreplacepauseresumerestartclear

  • tasksobject[]

    任务,每项来自你的一个模板。每个模板最多使用一次。

    长度≤ 16

  • tasks[].binding_idstring

    可选。要保留的现有任务(来自 GET .../tasks)。

  • tasks[].template_idstring必填

    GET /api/v1/renter/task-templates 返回的 id。

  • tasks[].gpusstring[] | null

    GPU 总线号,升序且不重复。null = 全部 GPU。

返回

  • 200OK

    每个实例一条结果,按请求顺序。

    返回字段(14)
  • 400Bad Request

    bad_request、task_limit_reached(超过 16 个任务)、task_template_duplicate、task_gpus_invalid(某个总线号不是该实例的 GPU)或 task_config_too_large。

    • bad_request
    • task_limit_reached
    • task_template_duplicate
    • task_gpus_invalid
    • task_config_too_large
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    template_not_found:模板不存在,或不属于你。

    • template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases/tasks' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "lease_ids": [
    "57",
    "58"
  ],
  "action": "add",
  "tasks": [
    {
      "template_id": "9c2e5b7a1d3f4e6a",
      "gpus": null
    }
  ]
}'
POST/api/v1/renter/leases/{lease_id}/tasks/{binding_id}/pause

暂停计算任务

停止该任务并保持暂停,直到你恢复它。仅在实例处于 running 时可用。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

  • binding_idstring· path必填

    任务的 binding_id,来自 GET /api/v1/renter/leases/{lease_id}/tasks。

    示例3f9a0c1d2e4b5a60格式^[0-9a-f]{16}$

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found,或 task_not_found(该实例上不存在此任务)。

    • lease_not_found
    • task_not_found
  • 409Conflict

    lease_not_running:实例不处于 running 阶段。

    • lease_not_running
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases/57/tasks/3f9a0c1d2e4b5a60/pause' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/leases/{lease_id}/tasks/{binding_id}/resume

恢复计算任务

重新启动已暂停的任务。仅在实例处于 running 时可用。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

  • binding_idstring· path必填

    任务的 binding_id,来自 GET /api/v1/renter/leases/{lease_id}/tasks。

    示例3f9a0c1d2e4b5a60格式^[0-9a-f]{16}$

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found,或 task_not_found(该实例上不存在此任务)。

    • lease_not_found
    • task_not_found
  • 409Conflict

    lease_not_running:实例不处于 running 阶段。

    • lease_not_running
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases/57/tasks/3f9a0c1d2e4b5a60/resume' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/leases/{lease_id}/tasks/{binding_id}/restart

重启计算任务

重启任务程序。每次成功调用都会重启一次,请不要自动重试。仅在实例处于 running 且任务未暂停时可用。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

  • binding_idstring· path必填

    任务的 binding_id,来自 GET /api/v1/renter/leases/{lease_id}/tasks。

    示例3f9a0c1d2e4b5a60格式^[0-9a-f]{16}$

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found,或 task_not_found(该实例上不存在此任务)。

    • lease_not_found
    • task_not_found
  • 409Conflict

    lease_not_running,或 task_paused(请先恢复任务)。

    • lease_not_running
    • task_paused
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases/57/tasks/3f9a0c1d2e4b5a60/restart' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/leases/{lease_id}/tasks/{binding_id}/reinstall

重新下载并安装计算任务的程序包

重新下载任务的程序包、安装并重启任务。仅适用于有程序包的任务;仅在实例处于 running 且任务未暂停时可用。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

  • binding_idstring· path必填

    任务的 binding_id,来自 GET /api/v1/renter/leases/{lease_id}/tasks。

    示例3f9a0c1d2e4b5a60格式^[0-9a-f]{16}$

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found,或 task_not_found(该实例上不存在此任务)。

    • lease_not_found
    • task_not_found
  • 409Conflict

    lease_not_running、task_paused(请先恢复任务),或 task_no_package(该任务没有可重新安装的程序包)。

    • lease_not_running
    • task_paused
    • task_no_package
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases/57/tasks/3f9a0c1d2e4b5a60/reinstall' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/renter/leases/{lease_id}/tasks/{binding_id}/log

读取计算任务日志

返回该任务的最新完整日志。日志按请求获取:先调用 POST .../log,然后轮询本接口,直到 log.req 等于返回的 req。日志到达前 log 为 null。仅在实例处于 running 时可用。

权限
renter:read
API 密钥
必填
限流类
read_pg

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

  • binding_idstring· path必填

    任务的 binding_id,来自 GET /api/v1/renter/leases/{lease_id}/tasks。

    示例3f9a0c1d2e4b5a60格式^[0-9a-f]{16}$

返回

  • 200OK

    最新日志。形状与启动命令日志相同。

    返回字段(8)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found,或 task_not_found(该实例上不存在此任务)。

    • lease_not_found
    • task_not_found
  • 409Conflict

    lease_not_running:实例不处于 running 阶段。

    • lease_not_running
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/renter/leases/57/tasks/3f9a0c1d2e4b5a60/log' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/leases/{lease_id}/tasks/{binding_id}/log

请求实例发送最新任务日志

请求实例发送该任务的当前日志。返回请求编号 req;通过 GET .../log 读取日志。仅在实例处于 running 且任务未暂停时可用。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • lease_idstring· path必填

    租约 ID(GET /api/v1/renter/leases 返回的 id)。不带前导零的正整数。

    示例57格式^[1-9][0-9]{0,17}$

  • binding_idstring· path必填

    任务的 binding_id,来自 GET /api/v1/renter/leases/{lease_id}/tasks。

    示例3f9a0c1d2e4b5a60格式^[0-9a-f]{16}$

返回

  • 200OK

    请求已发送。

    返回字段(2)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found,或 task_not_found(该实例上不存在此任务)。

    • lease_not_found
    • task_not_found
  • 409Conflict

    lease_not_running,或 task_paused(请先恢复任务)。

    • lease_not_running
    • task_paused
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases/57/tasks/3f9a0c1d2e4b5a60/log' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/renter/tags

列出你的实例标签

你的标签。按标签筛选实例请用 GET /api/v1/renter/leases?tags=。lease_count 统计带有该标签的你的全部实例,包括已结束的。

权限
renter:read
API 密钥
必填
限流类
read_pg

返回

  • 200OK

    标签列表。

    返回字段(6)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/renter/tags' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/tags

新建实例标签

新建标签。name 去除首尾空白后为 1-32 个字符,在你的账户内不区分大小写唯一;color 为 0-7。每个账户最多 1000 个标签。

权限
renter:write
API 密钥
必填
限流类
write

请求体application/json

  • namestring必填

    长度1 – 32

  • colorinteger必填

    范围0 – 7

返回

  • 200OK

    已新建。

    返回字段(2)
  • 400Bad Request

    bad_request、tag_name_invalid(去除首尾空白后 1-32 个字符)或 tag_color_invalid(0-7)。

    • bad_request
    • tag_name_invalid
    • tag_color_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 409Conflict

    tag_name_taken,或 tag_limit(已有 1000 个标签)。

    • tag_name_taken
    • tag_limit
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/tags' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "training",
  "color": 2
}'
PATCH/api/v1/renter/tags/{tag_id}

重命名或修改实例标签颜色

发送 name、color 或两者;规则与新建相同。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • tag_idstring· path必填

    你的标签的 id(来自 GET /api/v1/renter/tags)。

    示例12格式^[1-9][0-9]{0,17}$

请求体application/json

  • namestring

    长度1 – 32

  • colorinteger

    范围0 – 7

返回

  • 200OK

    完成。

    返回字段(1)
  • 400Bad Request

    bad_request、tag_name_invalid(去除首尾空白后 1-32 个字符)或 tag_color_invalid(0-7)。

    • bad_request
    • tag_name_invalid
    • tag_color_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    tag_not_found:标签不存在,或不属于你。

    • tag_not_found
  • 409Conflict

    tag_name_taken。

    • tag_name_taken
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PATCH 'https://suanzu.ai/api/v1/renter/tags/12' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "inference"
}'
DELETE/api/v1/renter/tags/{tag_id}

删除实例标签

删除该标签,并从你的所有实例上移除。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • tag_idstring· path必填

    你的标签的 id(来自 GET /api/v1/renter/tags)。

    示例12格式^[1-9][0-9]{0,17}$

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    tag_not_found:标签不存在,或不属于你。

    • tag_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X DELETE 'https://suanzu.ai/api/v1/renter/tags/12' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/leases/tags

为多个实例添加或移除标签

为你的 1-500 个实例添加(mode: add)或移除(mode: remove)1-30 个标签,要么全部成功,要么全部不做。每个实例最多 30 个标签;超出时整个请求被拒绝,返回 409 tag_lease_limit 并带该实例的 lease_id。添加实例已有的标签或移除实例没有的标签不算错误。

权限
renter:write
API 密钥
必填
限流类
write

请求体application/json

  • lease_idsstring[]必填

    租约 ID,十进制字符串(GET /api/v1/renter/leases 返回的 id)。1-500 项;重复项会合并。

    长度1 – 500格式^[1-9][0-9]{0,17}$

  • tag_idsstring[]必填

    标签 ID,十进制字符串。1-30 项;重复项会合并。

    长度1 – 30格式^[1-9][0-9]{0,17}$

  • modestring必填

    可选值addremove

返回

  • 200OK

    完成。n 为实例数(合并重复项之后)。

    返回字段(2)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    lease_not_found(某个实例不属于你),或 tag_not_found(某个标签不属于你)。

    • lease_not_found
    • tag_not_found
  • 409Conflict

    tag_lease_limit:某个实例的标签将超过 30 个;lease_id 指出是哪一个。

    • tag_lease_limit
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/leases/tags' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "lease_ids": [
    "57",
    "58"
  ],
  "tag_ids": [
    "12"
  ],
  "mode": "add"
}'
GET/api/v1/renter/wallet-vars

列出你的钱包/变量

你保存的钱包/变量。在计算任务模板中把 id 填进 vars[].ref 或 wallet_ref,模板就始终使用当前的 value。templates 列出使用每一条的模板。

权限
renter:read
API 密钥
必填
限流类
read_pg

返回

  • 200OK

    钱包/变量列表。

    返回字段(9)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/renter/wallet-vars' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/renter/wallet-vars

保存钱包/变量

保存一个钱包地址或其他值。name 去除首尾空白后为 1-64 个字符,在你的账户内唯一;description 最多 256 个字符;value 不能为空白,最大 4 KiB,不能包含 NUL。

权限
renter:write
API 密钥
必填
限流类
write

请求体application/json

  • namestring必填

    长度1 – 64

  • descriptionstring

    长度≤ 256

  • valuestring必填

    不能为空白,最大 4 KiB,不能包含 NUL。按原样保存和显示。

返回

  • 200OK

    已保存。

    返回字段(10)
  • 400Bad Request

    bad_request,或 wallet_var_invalid(error 文本指出是哪个字段)。

    • bad_request
    • wallet_var_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 409Conflict

    wallet_var_name_taken。

    • wallet_var_name_taken
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/renter/wallet-vars' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Pearl wallet",
  "description": "",
  "value": "prl1qexamplewallet0000"
}'
PUT/api/v1/renter/wallet-vars/{wallet_var_id}

修改钱包/变量

替换 name、description 和 value(三项都要发送)。value 有变化时,使用它的每个模板都会更新,使用这些模板的运行中实例随下一次心跳应用新值;template_count 和 lease_count 为相应数量。新值会使某个实例的任务超过 64 KiB 时,不做任何修改(400 task_config_too_large)。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • wallet_var_idstring· path必填

    你的钱包/变量的 id(来自 GET /api/v1/renter/wallet-vars)。

    示例5b1c9e2d7a3f4e60格式^[0-9a-f]{16}$

请求体application/json

  • namestring必填

    长度1 – 64

  • descriptionstring

    长度≤ 256

  • valuestring必填

    不能为空白,最大 4 KiB,不能包含 NUL。按原样保存和显示。

返回

  • 200OK

    已保存。

    返回字段(12)
  • 400Bad Request

    bad_request、wallet_var_invalid(error 文本指出是哪个字段)或 task_config_too_large。

    • bad_request
    • wallet_var_invalid
    • task_config_too_large
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    wallet_var_not_found:钱包/变量不存在,或不属于你。

    • wallet_var_not_found
  • 409Conflict

    wallet_var_name_taken。

    • wallet_var_name_taken
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PUT 'https://suanzu.ai/api/v1/renter/wallet-vars/5b1c9e2d7a3f4e60' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Pearl wallet",
  "description": "main",
  "value": "prl1qnewwallet00000000"
}'
DELETE/api/v1/renter/wallet-vars/{wallet_var_id}

删除钱包/变量

删除没有模板在用的钱包/变量。仍有模板在用时返回 409 wallet_var_in_use 并带 templates;请先修改这些模板。

权限
renter:write
API 密钥
必填
限流类
write

参数

  • wallet_var_idstring· path必填

    你的钱包/变量的 id(来自 GET /api/v1/renter/wallet-vars)。

    示例5b1c9e2d7a3f4e60格式^[0-9a-f]{16}$

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    wallet_var_not_found:钱包/变量不存在,或不属于你。

    • wallet_var_not_found
  • 409Conflict

    wallet_var_in_use:仍有模板在用;templates 列出这些模板。

    • wallet_var_in_use
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X DELETE 'https://suanzu.ai/api/v1/renter/wallet-vars/5b1c9e2d7a3f4e60' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/account/deposits

列出已入账的充值

已入账的链上 USDT 充值,按时间倒序。target=rent_balance 列出充值到租金余额的记录,需要 renter:read;target=fee_credit 列出充值到出租方服务费余额的记录,需要 host:read(否则返回 403 api_key_scope_denied)。

权限
renter:read / host:read
API 密钥
必填
限流类
read_pg

参数

  • targetstring· query必填

    rent_balance = 充值到租金余额(需要 renter:read);fee_credit = 充值到出租方服务费余额(需要 host:read)。

    可选值rent_balancefee_credit

  • pageinteger· query

    范围1 – 1000000默认1

  • page_sizeinteger· query

    范围1 – 100默认20

返回

  • 200OK

    一页充值记录。

    返回字段(6)
  • 400Bad Request

    bad_target(缺少 target 或其无效)、bad_request。

    • bad_target
    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied(target=rent_balance 需要 renter:read,target=fee_credit 需要 host:read)、api_key_ip_denied、api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/account/deposits?target=rent_balance' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/account/deposits/pending

列出链上已出现但尚未入账的充值

最多 50 笔已上链但仍在等待确认的充值。无法精确显示链上金额时,amount 为 null。所需权限范围按 target 而定,同 GET /api/v1/account/deposits。

权限
renter:read / host:read
API 密钥
必填
限流类
read_pg

参数

  • targetstring· query必填

    rent_balance = 充值到租金余额(需要 renter:read);fee_credit = 充值到出租方服务费余额(需要 host:read)。

    可选值rent_balancefee_credit

返回

  • 200OK

    待入账的充值。

    返回字段(5)
  • 400Bad Request

    bad_target。

    • bad_target
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied(target=rent_balance 需要 renter:read,target=fee_credit 需要 host:read)、api_key_ip_denied、api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/account/deposits/pending?target=rent_balance' \
  -H 'Authorization: Bearer sz_live_...'

出租方

管理你出租的设备。需要 host:read、host:write 或 host:exec。

GET/api/v1/host/machines

列出你的设备

列出你可见的设备:你自己的设备,以及共享给你的分组中的设备(需所有者允许 API 访问),并受密钥的分组限制。不传 group 时为「全部分组」视图。使用 page / per_page 分页;页码超出末页时返回最后一页。星标设备排在最前,然后按 sort 列排序(空值始终排在最后),最后按显示名称排序。

summary 统计权限范围内的所有设备,不受 connectivity、status 和 q 影响。*_counts 字段按筛选值统计设备数量,用于构建筛选菜单。使用限定分组的密钥时,看不到你未分组的设备。未知的查询参数会返回 400。

权限
host:read
API 密钥
必填
限流类
read

参数

  • groupstring· query

    分组 ID(GET /api/v1/host/device-groups 返回的 id)。为空表示全部分组。

  • connectivitystring· query

    可选值onlineoffline

  • statusstring· query

    逗号分隔,可选值:available、rented、unlisted、unpriced、fault、noncompliant。

    示例available,rented

  • reasonstring· query

    仅返回 status_reasons 中包含该代码的设备。

    格式^[a-z0-9_]{1,64}$

  • gpustring· query

    逗号分隔的 GPU 型号名称(与 gpus[].name 中的完整名称一致),最多 32 个。

  • tagstring· query

    none(无标签),或逗号分隔的标签 ID(最多 1000 个)。

  • taskstring· query

    逗号分隔:none 或计算任务模板 ID(32 位十六进制)。最多 32 个。模板 ID 也匹配运行它调试版本的设备(传来源模板 ID,不传调试版本的 ID)。

  • ocstring· query

    超频模板筛选。逗号分隔:none、manual 或模板 ID(32 位十六进制)。最多 32 个。

  • fanstring· query

    风扇模板筛选。格式同 oc。

  • pricestring· query

    价格模板筛选。格式同 oc。

  • oc_vstring· query

    not_latest 或版本号。要求 oc 中恰好有一个模板 ID。

  • fan_vstring· query

    与 oc_v 相同,用于 fan。

  • price_vstring· query

    与 oc_v 相同,用于 price。

  • algostring· query

    仅返回计算任务上报该算法的设备。需要高级功能。

    长度≤ 64

  • attentionstring· query

    仅返回存在该任务问题的设备。需要高级功能。

    可选值zero_hashrategpu_missingstart_failed

  • qstring· query

    不区分大小写,搜索设备 ID 前缀、显示名称、主机名、worker 名称、别名、局域网 IP、GPU 型号和标签名称。最多 64 个字符。

    长度≤ 64

  • sortstring· query

    排序列,取下列键之一或 taskHash:<template id>。gpuCount 按应有显卡张数(expected_gpu_count,这台设备检测到过的最大张数)排序,掉卡的设备仍按原来的张数排;离线设备照常参与排序,纯 CPU 设备按 0 排。sharesAcc、sharesRej、sharesInv 按在跑计算任务的接受、拒绝、无效份额排序。taskHash:<template id>(计算任务模板的 32 位小写十六进制 ID)按这个模板任务的算力排序;其他写法回 bad_request。没有值的设备不论升序降序都排在最后。

    可选值machinegpuStatusgpuModelsgpuCountgpuUtilvramUsagegpuTempcpucpuCorescpuTempmemorymemoryTotalmemoryUseddiskdiskSizediskTypenetworkpoweruptimeosdrivercudaagentoomlanIppublicIpstatusrestartssharesAccsharesRejsharesInv默认machine格式^taskHash:[0-9a-f]{32}$

  • orderstring· query

    可选值ascdesc默认asc

  • pageinteger· query

    范围≥ 1默认1

  • per_pageinteger· query

    范围1 – 1000默认50

返回

  • 200OK

    一页设备,以及汇总和筛选计数。

    返回字段(379)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled(使用了 algo / attention,但权限范围内没有设备开通高级功能),或 API 密钥错误。

    • advanced_not_enabled
  • 404Not Found

    group_not_found:分组不存在,或你无法使用(不属于你、角色权限不足、不在该密钥的分组范围内,或不允许 API 访问)。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    device_index_rebuilding:设备数据正在重建,请稍后重试。也可能返回 request_timeout。

    • device_index_rebuilding
    • request_timeout

示例

curl 'https://suanzu.ai/api/v1/host/machines?status=available,rented' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/machines/summary

获取设备汇总(总体及各分组)

你可见的所有设备的汇总(all),以及每个包含可见设备的分组的汇总(groups,以分组 ID 为键)。与设备列表中的 Summary 对象相同。all.earnings 为你整个账户的收益,即使使用限定分组的密钥也是如此。共享给你的分组,groups.<id>.earnings 为 null(密钥看不到其他账户的收益)。

权限
host:read
API 密钥
必填
限流类
read

返回

  • 200OK

    汇总。

    返回字段(131)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    device_index_rebuilding:设备数据正在重建,请稍后重试。也可能返回 request_timeout。

    • device_index_rebuilding
    • request_timeout

示例

curl 'https://suanzu.ai/api/v1/host/machines/summary' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/machines/{machine_id}

获取单台设备

包含列表项的全部字段,以及网络、驱动、已移除 GPU 和集成显卡的详细信息,均平铺在同一对象中。仅当所有者开通高级功能且设备有 GPU 时,才会填充 oc 和 autofan。

权限
host:read
API 密钥
必填
限流类
read

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

返回

  • 200OK

    该设备。

    返回字段(321)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    device_index_rebuilding:设备数据正在重建,请稍后重试。也可能返回 request_timeout。

    • device_index_rebuilding
    • request_timeout

示例

curl 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58' \
  -H 'Authorization: Bearer sz_live_...'
PATCH/api/v1/host/machines/{machine_id}

重命名设备

修改设备名称(alias)或应有显卡数(expected_gpu_count)。至少提供一个字段。改名立即生效并保存:新名称下发到设备,系统主机名当场改成这个名称(容器中只改名称,任务里的 HOSTNAME 变量为新名称);之后内网 IP 或分组变化都不会再改名。同名再次保存也会修改系统主机名。alias 不能为空。名称只能包含字母、数字和连字符,以字母或数字开头、不以连字符结尾,最多 63 个字符。Agent 低于 1.6.4-beta.2 的设备,名称以数字开头时计算任务里使用的 worker 名称暂为 worker-<id8>(<id8> = machine_id 前 8 位),系统主机名也暂不修改(apply_hostname = false)。修改已上架设备的 expected_gpu_count 会同时更新其上架信息。共享分组需要操作员角色。

权限
host:write
API 密钥
必填
限流类
write

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

请求体application/json

至少提供一个字段。未知字段会被拒绝。请求体最大 4 KiB。

  • aliasstring

    新名称;系统主机名也改成它(容器除外)。Agent 低于 1.6.4-beta.2 且名称以数字开头时,暂不修改系统主机名(apply_hostname = false)。

    长度1 – 63

  • expected_gpu_countinteger

    设备应有的显卡数;不能少于检测到的数量。

    范围1 – 64

返回

  • 200OK

    保存后的名称。

    返回字段(7)
  • 400Bad Request

    bad_request(没有字段、含未知字段)、alias_invalid(含 alias 为空)、expected_gpu_count_invalid(少于检测到的显卡数或超过 64)。

    • bad_request
    • alias_invalid
    • expected_gpu_count_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(需要操作员角色),或 API 密钥错误。

    • group_forbidden
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PATCH 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "alias": "rig-01"
}'
GET/api/v1/host/machines/{machine_id}/tasks

列出设备的计算任务

设备的计算任务及其最新统计数据。使用 binding_id 暂停、恢复或重启任务。syncing: true(列表为空)表示任务配置仍在写入,请稍后重试。需要设备所有者开通高级功能。

权限
host:read
API 密钥
必填
限流类
read

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

返回

  • 200OK

    任务。

    返回字段(48)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled(设备所有者未开通高级功能),或 API 密钥错误。

    • advanced_not_enabled
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    device_index_rebuilding:设备数据正在重建,请稍后重试。也可能返回 request_timeout。

    • device_index_rebuilding
    • request_timeout

示例

curl 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/tasks' \
  -H 'Authorization: Bearer sz_live_...'
PUT/api/v1/host/machines/{machine_id}/tasks

整台保存设备的计算任务

设置一台设备的完整计算任务列表:不在 items 中的任务会被移除,新任务会被添加,选卡变化的任务会被更新(未变化的任务继续运行)。items 为空表示移除全部任务。每一项为 {template_id, gpus};gpus 为 null(全部 GPU)或本设备 GPU 总线号列表。同一模板在一台设备上只能用一次;最多 16 个任务。模板 ID 从 GET /api/v1/host/task-templates 获取。该设备所在分组的调试版本(debug: true 的任务的 template_id)也可以在这里使用;只有这个接口能把调试版本设到设备上。离线设备在重新上线后收到改动(deferred: offline)。共享分组需要管理员角色;设备所有者须已开通高级功能、账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

请求体application/json

  • itemsobject[]必填

    长度≤ 16

  • items[].template_idstring必填
  • items[].gpusstring[] | null必填

    GPU 总线号,例如 0000:01:00.0。null = 全部 GPU。

返回

  • 200OK

    已保存。added 含新任务的 binding_id;updated、removed 和 kept 为任务 ID。

    返回字段(8)
  • 400Bad Request

    bad_request(某一项无效、总线号无效)、task_template_duplicate、task_limit_reached、task_config_too_large。

    • bad_request
    • task_template_duplicate
    • task_limit_reached
    • task_config_too_large
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该共享分组中的角色权限不足)、advanced_not_enabled、account_overdue_restricted 或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    machine_not_found,或 template_not_found(模板不存在,或不能用于这台设备)。

    • machine_not_found
    • template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PUT 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/tasks' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "items": [
    {
      "template_id": "9c2e5b7a1d3f4e6a8b0c2d4e6f8a0b1c",
      "gpus": null
    }
  ]
}'
GET/api/v1/host/machines/{machine_id}/checks

对设备执行上架检查

所有上架检查项及其结果。pre 为上架前检查的项(price_unset、group_invalid、offline、gpu_dropped、gpu_driver、gpu_count_low、gpu_ecc_uncorrected、nvidia_runtime_missing、nvidia_toolkit_outdated、rent_env_unsupported、tools_missing、docker_down、runc_outdated、gpu_mixed、gpu_probe_failed、collect_invalid、disk_low、pcie_unstable)。compare 将设备与其上架规格进行比较(gpu_count_low、gpu_changed、cpu_changed、ram_low、disk_changed、driver_changed、pcie_degraded、pcie_changed、os_changed),设备没有上架快照时为空。current 和 required 因检查项而异(数字、字符串或列表),未知时为 null。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

返回

  • 200OK

    检查结果。

    返回字段(20)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    device_index_rebuilding:设备数据正在重建,请稍后重试。也可能返回 request_timeout。

    • device_index_rebuilding
    • request_timeout

示例

curl 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/checks' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/machines/{machine_id}/leases

列出设备的租用记录

该设备在当前所有者名下的租用记录,按时间倒序。使用游标分页:将 next_before 作为 before 传入以获取下一页;最后一页的 next_before 为 null。使用 API 密钥时,只有你自己的设备显示 income;共享给你的分组中的设备,show_income 为 false,所有 income 均为 null。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

  • beforeinteger· query

    仅返回 ID 更小的租约。省略则返回最新记录。

    范围≥ 1

  • limitinteger· query

    范围1 – 100默认20

返回

  • 200OK

    一页租用记录。

    返回字段(9)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/leases' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/machines/{machine_id}/timeline

列出设备的命令与消息

按时间倒序。可用来查看你下发的命令:找到 kind: cmd 且 cmd_id 为 POST /api/v1/host/machines/commands/reboot、upgrade、driver_install 或 task_restart 返回值(issued[].cmd_id)的那一项。state 为 pending(设备尚未领取)、running、ok 或 error;note 说明结束原因,如 expired、timeout、rebooted、interrupted、not_delivered;latest_title 是最新一条结果消息。建议每 10-15 秒轮询一次。只接受 limit(不分页):最多最新 200 条。kind: msg 的项是设备的其他消息。使用 API 密钥时 script_preview 始终为 null。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

  • limitinteger· query

    返回的条数。

    范围1 – 200默认10

返回

  • 200OK

    时间线条目。

    返回字段(28)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/timeline' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/machines/{machine_id}/commands/{cmd_id}/messages

列出一条命令的消息

一条命令的全部消息,按时间正序:进度(info)、结果(ok 或 error)及其日志附件(payload_gz,gzip + base64 编码,或 null)。task_logs 的任务日志在 ok 消息中。不属于这台设备的命令返回空列表。使用 API 密钥时,不返回脚本命令的消息(空列表)。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

  • cmd_idstring· path必填

    命令回包或时间线中的 cmd_id。

    示例6b1f0f2e-4c1a-4f5e-9d3e-2a7b8c9d0e1f

返回

  • 200OK

    该命令的消息。

    返回字段(7)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/commands/6b1f0f2e-4c1a-4f5e-9d3e-2a7b8c9d0e1f/messages' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/machines/{machine_id}/history

获取设备历史曲线

一台设备 1 小时、6 小时、1 天、3 天、7 天或 30 天的时间序列(保留 30 天),按固定网格:第 i 个点在 start + i × step,代表其前 step 秒(1h:60 个点、每点 60 秒;6h:360 个、60 秒;1d:720 个、120 秒;3d:864 个、300 秒;7d:672 个、900 秒;30d:720 个、3600 秒)。没有上报的位置为 null。每张图每块 GPU 一条线(id = 总线号),或整机一条线(id 为空),网络为 rx / tx;total 为所有 GPU 的合计(整机图为 null)。指标:gpu_power、gpu_fan、gpu_temp、gpu_mem_temp、gpu_util、gpu_mem_used(另带 GB 单位的 used 和 total)、hashrate(每种算法一张图,算法在 key,单位按上报原样)、cpu_temp、cpu_util、mem_used、net。events 为同一时段的设备消息(最多 1000 条,保留最新的;使用 API 密钥时不含脚本命令的消息)。带 metrics=hashrate 时只返回算力图,events 为 null。每次请求约做 13 次查询;轮询间隔不要短于 step。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

  • rangestring· query必填

    可选值1h6h1d3d7d30d

  • tointeger· query

    时段的结束时间(UNIX 秒)。省略则为当前时间。会向后调整,使时段起点不早于 30 天前。30d 覆盖整个 30 天,始终返回最新一段。

    范围≥ 1

  • metricsstring· query

    hashrate = 只返回算力图。

    可选值hashrate

返回

  • 200OK

    曲线和活动。

    返回字段(21)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    history_unavailable(历史数据存储暂时不可用,请稍后重试)、device_index_rebuilding、request_timeout。

    • history_unavailable
    • device_index_rebuilding
    • request_timeout

示例

curl 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/history?range=1h' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/machines/{machine_id}/faults

列出设备的故障历史

设备出现过的问题(status_reasons 中的代码),每次出现一项,按时间倒序:出现时间(raised_at)、解除时间(cleared_at,持续中为 null)、当时的设备 status(state)和当时平台的处理(action:ok、hide 或 stop)。使用游标分页:将 next_before 作为 before 传入;最后一页的 next_before 为 null。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

  • beforeinteger· query

    上一页的 next_before。省略则从最新开始。

    范围≥ 1

  • limitinteger· query

    范围1 – 100默认20

返回

  • 200OK

    一页故障。

    返回字段(8)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/faults' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/machines/{machine_id}/remote

获取远程访问状态和连接信息

返回 root 密码。 一台设备同时最多 3 个远程会话:网页控制台一个、每把 API 密钥各一个,各开各关。remote 是这把密钥的会话(这把密钥没有打开会话时为 null)。你仍拥有操作员角色时包含 remote.connect(SSH 命令、密码、主机密钥指纹),否则不含 connect 键。others 列出这台设备的其他会话(网页控制台、你的其他密钥或其他账户),不含密码和 SSH 命令。该密码可获得整台设备的 root shell:请将响应视为机密,不要记录到日志。state 为 ready 前,ssh_command 为空。需要 host:exec。

权限
host:exec
API 密钥
必填
限流类
remote

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

返回

  • 200OK

    远程访问状态。

    返回字段(26)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    device_index_rebuilding:设备数据正在重建,请稍后重试。也可能返回 request_timeout。

    • device_index_rebuilding
    • request_timeout

示例

curl 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/remote' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/host/machines/{machine_id}/remote

打开设备的远程访问

打开远程访问会话(通过中转以 root 身份 SSH)。响应仅包含 session_id;请通过 GET .../remote 获取 SSH 命令和密码(等待 state: ready)。用同一把密钥再次打开会复用它自己的会话(密码不变)。网页控制台和每把密钥各有自己的会话,每台设备最多 3 个,再开新的返回 409 remote_too_many。其他账户已打开会话时返回 409 remote_busy。设备被租用期间不允许打开。会话在空闲 600 秒后、被关闭时,或打开它的密钥被删除或过期时关闭。密钥从新 IP 打开远程访问时会发送安全通知。需要 host:exec 和操作员角色。

权限
host:exec
API 密钥
必填
限流类
write

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

返回

  • 200OK

    会话已打开。

    返回字段(2)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(需要操作员角色)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 409Conflict

    rented、remote_busy(其他账户已打开会话)、remote_too_many(已有 3 个会话且这把密钥没有)、agent_unsupported(agent 版本过旧)。

    • rented
    • remote_busy
    • remote_too_many
    • agent_unsupported
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    remote_unconfigured、remote_relay_unavailable(没有确认可用的中转,未打开任何会话)或 request_timeout。

    • remote_unconfigured
    • remote_relay_unavailable
    • request_timeout

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/remote' \
  -H 'Authorization: Bearer sz_live_...'
DELETE/api/v1/host/machines/{machine_id}/remote

关闭设备的远程访问

不带 scope 时只关闭这把密钥自己的会话并断开它的连接;网页控制台或其他密钥打开的会话不受影响。需要操作员角色。这把密钥没有会话时返回 200,closed: 0。带 scope=all 时关闭这台设备上的全部远程会话(网页控制台、所有密钥以及其他账户的);全部属于你的账户时需要操作员角色,有其他账户的会话时需要管理员角色。closed 为关闭的会话数,每个会话都会记录到设备时间线。

权限
host:exec
API 密钥
必填
限流类
write

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

  • scopestring· query

    all 关闭这台设备上的全部会话。不带时只关闭这把密钥自己的会话。

    可选值all

返回

  • 200OK

    已关闭。

    返回字段(2)
  • 400Bad Request

    invalid_scope(scope 不是 all),或 bad_request。

    • invalid_scope
    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(需要操作员角色;scope=all 且有其他账户的会话时需要管理员角色),或 API 密钥错误。

    • group_forbidden
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X DELETE 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/remote' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/device-groups

列出你的分组

先列出你自己的分组,再列出共享给你的分组(shared: true),各自按创建时间排序。只列出该密钥可用的分组。响应为 JSON 数组。

权限
host:read
API 密钥
必填
限流类
read_pg

返回

  • 200OK

    分组。

    返回字段(25)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/device-groups' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/memberships

列出共享给你的分组

其他账户共享给你的分组,按授权时间从早到晚排列。仅列出该密钥可用的分组(所有者允许 API 访问,且在该密钥的分组范围内)。

权限
host:read
API 密钥
必填
限流类
read_pg

返回

  • 200OK

    成员关系。

    返回字段(7)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/memberships' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/account

获取你的出租方余额

earn_balance(租金收入与邀请分润)、credit_balance(服务费余额)、gift_balance(赠送额度)、三者合计、可转让金额以及可提现金额。earn_balance 低于 0(欠费)时会设置 overdue_since / freeze_at:到 freeze_at 时仍欠费,账户变为 restricted,修改计算任务、超频和钱包/变量会以 account_overdue_restricted 失败,直到你充值。始终为你自己的账户,即使使用限定分组的密钥。

权限
host:read
API 密钥
必填
限流类
read_pg

返回

  • 200OK

    余额。

    返回字段(13)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/account' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/ledger

列出你的出租方余额流水

按时间倒序。amount 入账为正,出账为负。对于 rent 行,可通过 GET /api/v1/host/rent-payouts/{ledger_id} 获取按租约的明细。type=transfer 同时匹配 transfer_out 和 transfer_in。始终为你自己的账户。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • pageinteger· query

    范围1 – 1000000默认1

  • page_sizeinteger· query

    范围1 – 100默认20

  • typestring· query

    可选值feerentdepositoffsetgiftimportwithdrawwithdraw_refundtransferreferral

返回

  • 200OK

    一页流水。

    返回字段(13)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/ledger' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/rent-payouts/{ledger_id}

获取租金到账对应的租约

将出租方流水中的一条 rent 行按租约拆分。可能包含任意分组的设备。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • ledger_idstring· path必填

    GET /api/v1/host/ledger 中某条 rent 行的 id。正整数,不带前导零。

    示例2201格式^[1-9][0-9]{0,17}$

返回

  • 200OK

    到账记录及其租约。

    返回字段(12)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    payout_not_found:该行不存在、不属于你,或不是 rent 行。

    • payout_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/rent-payouts/2201' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/earnings

获取某时段的租金收益

收益合计,以及按天、按设备、按分组的明细。时段以 UTC 日计;from 包含,to 不包含。上个月按分组统计请用 range=last_month 并读 groups[]。(滚动卡片 last_24h_usd、last_7d_usd 和 total_usd 在 GET /api/v1/host/machines/summary 的 all.earnings / groups.<id>.earnings 和设备列表的 summary.earnings 中,不在这里。)不传 group 时覆盖整个账户(即使使用限定分组的密钥)。使用 API 密钥时,group 必须是你自己的分组;共享给你的分组返回 404 group_not_found(密钥看不到其他账户的收益)。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • rangestring· query

    7d 和 30d 截至今天(UTC);month = 本 UTC 月;last_month = 上一个 UTC 月。

    可选值7d30dmonthlast_month默认7d

  • groupstring· query

    分组 ID。不传则为整个账户。

返回

  • 200OK

    收益。

    返回字段(39)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    group_not_found:分组不存在、不属于你,或不在该密钥的分组范围内。使用 API 密钥时,共享给你的分组也返回此错误。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/earnings' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/earnings/leases

列出某时段内有收益的租约

该时段内有收益的租约,分页返回。range / group 规则与 GET /api/v1/host/earnings 相同。超出末页时返回空的 items。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • rangestring· query

    7d 和 30d 截至今天(UTC);month = 本 UTC 月;last_month = 上一个 UTC 月。

    可选值7d30dmonthlast_month默认7d

  • groupstring· query

    分组 ID。不传则为整个账户。

  • machinestring· query

    仅限此 machine_id。

  • qstring· query

    在设备显示名称和分组名称中搜索,不区分大小写。最多 64 个字符。

    长度≤ 64

  • sortstring· query

    recent = 按开始时间从新到旧,income = 按总额从高到低,hours = 按时长从长到短,name = 按显示名称。

    可选值recentincomehoursname默认recent

  • pageinteger· query

    范围1 – 1000000默认1

  • page_sizeinteger· query

    范围1 – 100默认20

返回

  • 200OK

    一页租约。

    返回字段(16)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    group_not_found:分组不存在、不属于你,或不在该密钥的分组范围内。使用 API 密钥时,共享给你的分组也返回此错误。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/earnings/leases' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/billing

获取本月服务费汇总

当前 UTC 月的服务费:计费分钟数、应付和已扣金额、免费设备、折扣档位以及免费期(如有)。due 和 charged 保留 6 位小数。始终为你自己的账户。

权限
host:read
API 密钥
必填
限流类
read_pg

返回

  • 200OK

    服务费汇总。

    返回字段(17)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/billing' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/billing/days/{day}

获取某天的服务费账单

某个 UTC 日的服务费账单:当天的 summary,以及每台计费设备一项(按 machine_id 排序)。day 为当天 UTC 0 点的 UNIX 秒(例如 GET /api/v1/host/billing 返回的 through_day)。金额为保留 6 位小数的十进制字符串。始终为你自己的账户。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • dayinteger· path必填

    UTC 0 点的 UNIX 秒(86400 的整数倍)。

    示例1762300800

  • pageinteger· query

    范围1 – 1000000默认1

  • per_pageinteger· query

    范围1 – 500默认100

返回

  • 200OK

    当天的账单。

    返回字段(26)
  • 400Bad Request

    bad_request(day 不是 UTC 0 点,或 page / per_page 无效)。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    bill_day_not_found:这一天没有账单。

    • bill_day_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/billing/days/1762300800' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/host/machines/price

设置或清除租金价格

为 1-500 台设备设置租金价格。GPU 设备使用 price_per_gpu_hr,纯 CPU 设备使用 price_per_cpu_hr(按 CPU 颗数计);设备类型混合时可同时传两者。null 清除价格(设备已上架时不允许)。价格为十进制字符串,大于 0 且不超过 100,最多 3 位小数。

rent_power_limit_w(每块 GPU,null = 不限)和 rent_fan_mode 仅适用于 GPU 设备,且仅在设置了价格时生效。修改已上架设备的价格对新的租用生效。

每台设备单独处理:请检查 results[].ok 和 results[].code。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。共享分组需要管理员角色。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

price_per_gpu_hr 和 price_per_cpu_hr 至少提供一个。未知字段会被拒绝。请求体最大 64 KiB。

  • machine_idsstring[]必填

    设备 ID(machine_id,不是设备编号)。1-500 项;重复项会合并。

    长度1 – 500

  • price_per_gpu_hrstring | null

    每块 GPU 每小时的 USDT 价格。null 表示清除。

    格式^(0|[1-9][0-9]{0,6})(\.[0-9]{1,3})?$

  • price_per_cpu_hrstring | null

    每颗 CPU 每小时的 USDT 价格。null 表示清除。

    格式^(0|[1-9][0-9]{0,6})(\.[0-9]{1,3})?$

  • rent_power_limit_winteger | null

    租用期间每块 GPU 的功耗上限,单位 W。null = 不限。省略则保持不变。必须在每块 GPU 的允许范围内。

  • rent_fan_modestring | null

    租用期间的风扇模式。省略或传 null 则保持不变。

    可选值automaxnull

返回

  • 200OK

    每台设备的结果。ok 为 false 时 results[].code 为:machine_not_found、group_forbidden、price_unit_mismatch(未提供该设备计价单位的价格)、price_invalid、listed(不能清除已上架设备的价格)、power_range_unknown、power_limit_out_of_range。

    返回字段(6)
  • 400Bad Request

    bad_request(请求体无效、含未知字段、machine_ids 为空或超过 500 个、rent_fan_mode 无效、未提供价格字段)、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/price' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58",
    "8043d318-b8e8-4a3a-8fde-5daaf655d443"
  ],
  "price_per_gpu_hr": "0.050"
}'
POST/api/v1/host/machines/listing

上架或下架设备

listed: true 将 1-500 台设备上架;每台设备必须已设置价格并通过上架检查(与 listing/precheck 的检查相同)。listed: false 将设备下架;不会终止进行中的租用。已处于目标状态的设备返回 ok: true。

每台设备单独处理:请检查 results[]。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。共享分组需要操作员角色。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    设备 ID(machine_id,不是设备编号)。1-500 项;重复项会合并。

    长度1 – 500

  • listedboolean必填

返回

  • 200OK

    每台设备的结果。ok 为 false 时 results[].code 为:machine_not_found、group_forbidden,上架时还可能为 price_unset、not_eligible(附 reasons,见 listing/precheck)、spec_syncing(硬件数据仍在同步,请稍后重试)、group_invalid、master_pending(已设置为母盘,重启生效前不能上架)。

    返回字段(6)
  • 400Bad Request

    bad_request(请求体无效、缺少 listed、machine_ids 无效)、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    device_index_rebuilding:设备数据正在重建,请稍后重试。也可能返回 request_timeout。

    • device_index_rebuilding
    • request_timeout

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/listing' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58"
  ],
  "listed": true
}'
POST/api/v1/host/machines/listing/precheck

检查设备能否上架

对 1-500 台设备执行上架检查,不做任何更改。可以上架(或已上架、已被租用)的设备返回 ok: true。否则由 code 说明原因;对于 not_eligible,reasons 列出具体问题,例如 offline、gpu_dropped、gpu_driver、docker_down、nvidia_runtime_missing、disk_low、agent_outdated、gpu_count_low、pcie_unstable、owner_inactive、tools_missing、rent_env_unsupported、group_invalid、data_invalid。如需查看单台设备按规则的明细,请使用 GET /api/v1/host/machines/{machine_id}/checks。

只读(host:read),但使用 API 密钥时所有设备仍必须属于同一分组(400 cross_group)。

权限
host:read
API 密钥
必填
限流类
read_pg

请求体application/json

  • machine_idsstring[]必填

    设备 ID(machine_id,不是设备编号)。1-500 项;重复项会合并。

    长度1 – 500

返回

  • 200OK

    每台设备的结果。results[].code:machine_not_found、group_forbidden、price_unset、not_eligible(附 reasons)、spec_syncing、master_pending。

    返回字段(6)
  • 400Bad Request

    bad_request、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    device_index_rebuilding:设备数据正在重建,请稍后重试。也可能返回 request_timeout。

    • device_index_rebuilding
    • request_timeout

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/listing/precheck' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58",
    "8043d318-b8e8-4a3a-8fde-5daaf655d443"
  ]
}'
POST/api/v1/host/machines/{machine_id}/tasks/{binding_id}/pause

暂停计算任务

停止设备上的一个计算任务并保持暂停。暂停已暂停的任务返回 200。binding_id 可从 GET /api/v1/host/machines/{machine_id}/tasks 获取。共享分组需要管理员角色,且设备所有者须已开通高级功能、账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

  • binding_idstring· path必填

    任务的 binding_id,来自 GET /api/v1/host/machines/{machine_id}/tasks。

    示例3f9a0c1d2e4b5a60格式^[0-9a-f]{16}$

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该共享分组中的角色权限不足)、advanced_not_enabled、account_overdue_restricted 或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    machine_not_found,或 task_not_found(该设备上不存在此任务)。

    • machine_not_found
    • task_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/tasks/3f9a0c1d2e4b5a60/pause' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/host/machines/{machine_id}/tasks/{binding_id}/resume

恢复已暂停的计算任务

重新启动已暂停的计算任务。恢复运行中的任务返回 200。设备被租用期间不允许(409 rented)。角色和账户要求与暂停相同。

权限
host:write
API 密钥
必填
限流类
write

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

  • binding_idstring· path必填

    任务的 binding_id,来自 GET /api/v1/host/machines/{machine_id}/tasks。

    示例3f9a0c1d2e4b5a60格式^[0-9a-f]{16}$

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该共享分组中的角色权限不足)、advanced_not_enabled、account_overdue_restricted 或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    machine_not_found,或 task_not_found(该设备上不存在此任务)。

    • machine_not_found
    • task_not_found
  • 409Conflict

    rented:设备已被租用。

    • rented
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/tasks/3f9a0c1d2e4b5a60/resume' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/host/machines/commands/task_restart

重启计算任务

向恰好一台设备发送重启一个计算任务的命令。命令在设备下次心跳时异步执行(600 秒后过期);返回 200 表示命令已下发,不代表已执行。可用 GET /api/v1/host/machines/{machine_id}/timeline 查看结果(issued[].cmd_id)。未下发(rejected[].reason):machine_not_found、task_not_found、group_forbidden(需要管理员角色)、agent_unsupported、rented、task_paused。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    长度1 – 1

  • argsobject必填
  • args.binding_idstring必填

    格式^[0-9a-f]{16}$

返回

  • 200OK

    已下发或已拒绝。

    返回字段(7)
  • 400Bad Request

    bad_request(设备数量不是恰好一台,或 args 不是 {binding_id})。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled(设备所有者未开通高级功能)、account_overdue_restricted(设备所有者账户欠费),或 API 密钥错误(见 KeyForbidden)。

    • advanced_not_enabled
    • account_overdue_restricted
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    command_push_failed:命令未送达,不会执行,设备时间线里显示为下发失败,可以直接重新发送。

    • command_push_failed

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/commands/task_restart' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58"
  ],
  "args": {
    "binding_id": "3f9a0c1d2e4b5a60"
  }
}'
POST/api/v1/host/machines/commands/task_logs

拉取计算任务日志

向一台设备发送命令,让它发回某个计算任务日志的最后 500 行。命令在设备下次心跳时异步执行(600 秒后过期)。记下 issued[0].cmd_id,轮询 GET /api/v1/host/machines/{machine_id}/commands/{cmd_id}/messages,直到出现 ok 消息(日志在它的 payload_gz 中)或 error 消息。日志原样返回,不隐去钱包或密码。未下发(rejected[].reason):machine_not_found、task_not_found、group_forbidden(需要操作员角色)、agent_unsupported、rented。需要设备所有者已开通高级功能(欠费账户也可以拉取日志)。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    长度1 – 1

  • argsobject必填
  • args.binding_idstring必填

    格式^[0-9a-f]{16}$

返回

  • 200OK

    已下发或已拒绝。

    返回字段(7)
  • 400Bad Request

    bad_request(设备数量不是恰好一台,或 args 不是 {binding_id})。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled(设备所有者未开通高级功能),或 API 密钥错误。

    • advanced_not_enabled
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    command_push_failed:命令未送达,不会执行,设备时间线里显示为下发失败,可以直接重新发送。

    • command_push_failed

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/commands/task_logs' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58"
  ],
  "args": {
    "binding_id": "3f9a0c1d2e4b5a60"
  }
}'
POST/api/v1/host/machines/tasks/restart

重启设备的全部计算任务

为 1-500 台设备(去重后计数)上每个未暂停的计算任务各发一条 task_restart 命令;有多个任务的设备在 issued 中有多项。命令在每台设备下次心跳时异步执行(600 秒后过期);在 GET /api/v1/host/machines/{machine_id}/timeline 查看。未下发(rejected[].reason):machine_not_found、task_none(没有任务)、group_forbidden(需要管理员角色)、agent_unsupported、rented、task_paused(全部任务已暂停)。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。需要设备所有者已开通高级功能,且该账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    设备 ID(machine_id,不是设备编号)。1-500 项;重复项会合并。

    长度1 – 500

返回

  • 200OK

    已下发和被拒绝的设备。

    返回字段(7)
  • 400Bad Request

    bad_request(machine_ids 无效)、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled(设备所有者未开通高级功能)、account_overdue_restricted(设备所有者账户欠费),或 API 密钥错误(见 KeyForbidden)。

    • advanced_not_enabled
    • account_overdue_restricted
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    command_push_failed:命令未送达,不会执行,设备时间线里显示为下发失败,可以直接重新发送。

    • command_push_failed

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/tasks/restart' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58",
    "8043d318-b8e8-4a3a-8fde-5daaf655d443"
  ]
}'
POST/api/v1/host/machines/tasks/redownload

重新安装设备的计算任务

为 1-500 台设备上属于所选模板(template_ids,1-100 个;两者都去重后计数)的每个计算任务各发一条 task_redownload 命令;有多个所选任务的设备在 issued 中有多项。每台设备在当前程序照常运行时重新下载安装包,下载好后再切换;下载失败不影响当前程序。已暂停的任务和没有 package_url 的自定义任务会跳过;只要有一个任务下发,这台设备就算已下发。命令在每台设备下次心跳时异步执行(600 秒后过期);在 GET /api/v1/host/machines/{machine_id}/timeline 查看。未下发(rejected[].reason):machine_not_found、task_not_found(这台设备上没有所选模板的任务)、group_forbidden(需要管理员角色)、agent_unsupported、rented、task_paused(所选任务全部已暂停)、task_no_package(其余任务都没有安装包)。模板 ID 只用来匹配设备上的任务,不存在的 ID 不报错。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。需要设备所有者已开通高级功能,且该账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    设备 ID(machine_id,不是设备编号)。1-500 项;重复项会合并。

    长度1 – 500

  • template_idsstring[]必填

    计算任务模板 ID(GET /api/v1/host/task-templates 的 id,或设备 tasks.items 里的 template_id)。

    长度1 – 100

返回

  • 200OK

    已下发和被拒绝的设备。

    返回字段(7)
  • 400Bad Request

    bad_request(machine_ids 或 template_ids 无效)、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled(设备所有者未开通高级功能)、account_overdue_restricted(设备所有者账户欠费),或 API 密钥错误(见 KeyForbidden)。

    • advanced_not_enabled
    • account_overdue_restricted
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    command_push_failed:命令未送达,不会执行,设备时间线里显示为下发失败,可以直接重新发送。

    • command_push_failed

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/tasks/redownload' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58",
    "8043d318-b8e8-4a3a-8fde-5daaf655d443"
  ],
  "template_ids": [
    "9c2e5b7a1d3f4e6a"
  ]
}'
POST/api/v1/host/machines/tasks/pause

暂停设备的全部计算任务

暂停 1-500 台设备上的全部计算任务,等于对每个任务调用 POST /api/v1/host/machines/{machine_id}/tasks/{binding_id}/pause。已暂停的任务不变;results[].tasks 是本次在这台设备上暂停了几个任务(0 = 本来都已暂停,仍是 ok: true)。这是修改设备的任务设置,不是命令:离线设备在下次心跳时停止任务。已暂停的任务不计出租方服务费。每台设备单独处理(results[].code:machine_not_found、task_none(没有任务)、group_forbidden(需要管理员角色));设备被租用时也可以暂停。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。需要设备所有者已开通高级功能,且该账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    设备 ID(machine_id,不是设备编号)。1-500 项;重复项会合并。

    长度1 – 500

返回

  • 200OK

    每台设备的结果。

    返回字段(6)
  • 400Bad Request

    bad_request(machine_ids 无效)、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled(设备所有者未开通高级功能)、account_overdue_restricted(设备所有者账户欠费),或 API 密钥错误(见 KeyForbidden)。

    • advanced_not_enabled
    • account_overdue_restricted
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/tasks/pause' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58",
    "8043d318-b8e8-4a3a-8fde-5daaf655d443"
  ]
}'
POST/api/v1/host/machines/tasks/resume

恢复设备的全部计算任务

恢复 1-500 台设备上全部已暂停的计算任务,等于对每个任务调用 POST /api/v1/host/machines/{machine_id}/tasks/{binding_id}/resume。正在运行的任务不变;results[].tasks 是本次在这台设备上恢复了几个任务(0 = 本来没有暂停的,仍是 ok: true)。这是修改设备的任务设置,不是命令:离线设备在下次心跳时启动任务。每台设备单独处理(results[].code:machine_not_found、task_none(没有任务)、group_forbidden(需要管理员角色)、rented(设备被租用时不可恢复))。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。需要设备所有者已开通高级功能,且该账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    设备 ID(machine_id,不是设备编号)。1-500 项;重复项会合并。

    长度1 – 500

返回

  • 200OK

    每台设备的结果。

    返回字段(6)
  • 400Bad Request

    bad_request(machine_ids 无效)、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled(设备所有者未开通高级功能)、account_overdue_restricted(设备所有者账户欠费),或 API 密钥错误(见 KeyForbidden)。

    • advanced_not_enabled
    • account_overdue_restricted
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/tasks/resume' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58",
    "8043d318-b8e8-4a3a-8fde-5daaf655d443"
  ]
}'
POST/api/v1/host/machines/commands/reboot

重启设备

向 1-100 台设备(去重后计数)发送重启命令。命令在每台设备下次心跳时异步执行(600 秒后过期);返回 200 表示命令已下发。可用 GET /api/v1/host/machines/{machine_id}/timeline 查看结果(issued[].cmd_id)。未下发(rejected[].reason):machine_not_found、group_forbidden(需要操作员角色)、host_env_unsupported(仅物理机和虚拟机可以重启)、agent_unsupported、command_pending、rented、master_disk_pending(已在控制台设置为有盘母盘,重启会变成新设备;请关机,或先取消母盘设置)。

需要 host:exec。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。

权限
host:exec
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    长度1 – 100

返回

  • 200OK

    已下发和被拒绝的设备。

    返回字段(7)
  • 400Bad Request

    bad_request(请求体无效、列表为空、ID 为空、超过 100 台设备)、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    command_push_failed:命令未送达,不会执行,设备时间线里显示为下发失败,可以直接重新发送。

    • command_push_failed

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/commands/reboot' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58"
  ]
}'
POST/api/v1/host/machines/commands/upgrade

升级设备 Agent

向 1-100 台设备(去重后计数)发送升级命令:每台设备把 Agent 升级到当前正式版。同一局域网里已经有安装包的设备会先互相传,否则设备自己下载。命令在每台设备下次心跳时异步执行(600 秒后过期);返回 200 表示命令已下发。一般不中断计算任务;新版本改了服务配置(systemd 单元或 supervisor 程序配置)时,安装脚本会重启 Agent 服务,任务会停 1 分钟左右,之后由 Agent 自动拉起。当前正式版号是 https://down.suanzu.ai/VERSION 的纯文本内容(公开,无需密钥)。不看设备当前版本:比正式版新的正式版或 beta 会被装回正式版,已是正式版的会重新安装一次,所以只发送 agent_version 低于正式版的设备(见业务规则「Agent 版本」)。可用 GET /api/v1/host/machines/{machine_id}/timeline 查看结果(issued[].cmd_id),设备的 agent_version 查看新版本。本路径不带 args,始终升级到正式版(请求体带其他字段返回 400);升级到最新 beta(https://down.suanzu.ai/VERSION-beta)只在控制台提供。未下发(rejected[].reason):machine_not_found、group_forbidden(需要操作员角色)、agent_unsupported、command_pending(另一个重启、关机、升级、修改网络或安装驱动还没完成)、rented。

需要 host:exec。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。

权限
host:exec
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    长度1 – 100

返回

  • 200OK

    已下发和被拒绝的设备。

    返回字段(7)
  • 400Bad Request

    bad_request(请求体无效、列表为空、ID 为空、超过 100 台设备)、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    command_push_failed:命令未送达,不会执行,设备时间线里显示为下发失败,可以直接重新发送。

    • command_push_failed

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/commands/upgrade' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58",
    "8043d318-b8e8-4a3a-8fde-5daaf655d443"
  ]
}'
GET/api/v1/host/machines/{machine_id}/driver-options

列出设备可安装的 NVIDIA 驱动版本

这台设备用 POST /api/v1/host/machines/commands/driver_install 可以安装的驱动版本,与控制台同一份。options 是支持的全部版本,按版本排序,不按 GPU 过滤,没有默认项。当前已安装的版本也会列出(可以重装)。GPU 不影响能不能装,没有 GPU 也能装:module 是推荐的内核模块,某个版本或模块可能不认这台设备的 GPU 时由 warn / module_warn 说明。cuda_block 不为 null(driver_cuda_hiveos)时 cuda 必须为 false。docker: true 表示会一并安装 NVIDIA 容器工具。设备现在不能安装驱动时返回 409,原因在 code:group_forbidden(需要操作员角色)、driver_env_unsupported(容器或 WSL)、driver_os_unsupported(只支持 Ubuntu 22.04 / 24.04 和 HiveOS)、driver_os_unknown、driver_arch_unsupported(只支持 x86_64)、agent_unsupported、command_pending、listed(先下架)、rented、master_disk_pending(已设置为有盘母盘;安装最后会重启,重启会变成新设备)。设备详情的 driver_block 给出同一原因(不含 command_pending)。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

返回

  • 200OK

    可安装的驱动版本。

    返回字段(17)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 409Conflict

    设备现在不能安装驱动:group_forbidden、driver_env_unsupported、driver_os_unsupported、driver_os_unknown、driver_arch_unsupported、agent_unsupported、command_pending、listed、rented。

    • group_forbidden
    • driver_env_unsupported
    • driver_os_unsupported
    • driver_os_unknown
    • driver_arch_unsupported
    • agent_unsupported
    • command_pending
    • listed
    • rented
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/driver-options' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/host/machines/commands/driver_install

安装或更换设备的 NVIDIA 驱动

向恰好一台设备发送安装驱动命令,与控制台「安装 / 更换」相同。先用 GET /api/v1/host/machines/{machine_id}/driver-options 取可选版本。args:version(options[].version 之一)、cuda(同时安装 CUDA 工具包 cuda_toolkit;cuda_block 不为 null 时必须为 false)和 accel(true:先从同一局域网的设备和 SuanZu 服务器下载,再从 NVIDIA;false:只从 NVIDIA 下载)三项必填。无论哪种,设备上已有、且和 SuanZu 记录的校验值一致的安装包(例如 HiveOS 自带的驱动包)都会先用,不再下载。module 可选:open 或 proprietary;不传时用 driver-options 推荐的 module。

设备必须已下架且未被租用。它会停掉你的计算任务,下载并校验驱动,安装后重启;重启后计算任务自动恢复。命令在设备下次心跳时异步执行(600 秒后过期)。用 GET /api/v1/host/machines/{machine_id}/commands/{cmd_id}/progress 查看阶段、百分比和日志,在 GET /api/v1/host/machines/{machine_id}/timeline 判断结果:state: ok 且 note: rebooted 表示设备已带着新的 driver_version 回来(note: rebooted_no_gpu / rebooted_gpu_unreadable:已回来,但没有 NVIDIA GPU / GPU 都读不到,未核对版本);state: error 的原因码在 latest_title 的方括号里(例如 [driver_download_failed]、[driver_secure_boot]、[driver_install_timeout])。安装须在开始后 120 分钟内完成,重启后须在 10 分钟内上线。重启前失败时旧驱动保持不变。[driver_reboot_required] 表示驱动已装好,但到重启时已超过时限、设备没有重启,请自己重启设备以加载新驱动。未下发(rejected[].reason):machine_not_found、group_forbidden(需要操作员角色)、driver_env_unsupported、driver_os_unsupported、driver_os_unknown、driver_arch_unsupported、agent_unsupported、command_pending、listed(先下架)、rented、master_disk_pending(已在控制台设置为有盘母盘;安装最后会重启,重启会变成新设备,请先取消母盘设置)。

需要 host:exec。

权限
host:exec
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    长度1 – 1

  • argsobject必填
  • args.versionstring必填

    driver-options 返回的 options[].version 之一。

  • args.cudaboolean必填

    同时安装 CUDA 工具包(nvcc)。

  • args.accelboolean必填

    先从局域网设备和 SuanZu 服务器下载,再从 NVIDIA(false:只从 NVIDIA)。无论哪种,设备上已有的一致安装包都会先用。

  • args.modulestring

    要安装的内核模块。可选;不传时用 driver-options 推荐的 module。

    可选值openproprietary

返回

  • 200OK

    已下发或已拒绝。

    返回字段(7)
  • 400Bad Request

    bad_request(请求体无效,例如带了 type 字段)、driver_param_invalid(设备数量不是恰好一台、args 缺 version、cuda 或 accel 或带了这三项与 module 以外的键、module 不是 open 或 proprietary,或在 HiveOS 上 cuda: true)、driver_version_invalid(版本不在这台设备的 driver-options 中)。

    • bad_request
    • driver_param_invalid
    • driver_version_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    command_push_failed:命令未送达,不会执行,设备时间线里显示为下发失败,可以直接重新发送。

    • command_push_failed

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/commands/driver_install' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58"
  ],
  "args": {
    "version": "610.43.03",
    "cuda": false,
    "accel": true
  }
}'
GET/api/v1/host/machines/{machine_id}/commands/{cmd_id}/progress

查看长命令的进度与日志

长命令(目前是安装驱动)执行中的阶段、百分比和日志。stage、pct、started_at、stage_at 和 at 取自最新一段日志;设备发来第一段之前都为 null(不发日志的命令也是)。安装驱动的阶段依次为:prepare、download(只有它有 pct)、verify、stop_tasks、install、toolkit、cuda、reboot;也可能出现其他阶段名。log 是从 offset 起的文本(每次最多 64 KiB);下次带 offset = next_offset 只读新增部分。log_truncated: true 表示日志已到 256 KiB,之后的不再发送。命令为 running 时每 5 秒轮询一次;成功与否看时间线的 state,不看这里。使用 API 密钥时,不返回脚本命令的日志。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

  • cmd_idstring· path必填

    命令回包或时间线中的 cmd_id。

    示例6b1f0f2e-4c1a-4f5e-9d3e-2a7b8c9d0e1f

  • offsetinteger· query

    从日志的哪个字节读起;用上一次返回的 next_offset。

    范围0 – 262144默认0

返回

  • 200OK

    进度与日志。

    返回字段(11)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/commands/6b1f0f2e-4c1a-4f5e-9d3e-2a7b8c9d0e1f/progress' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/machines/{machine_id}/messages

列出设备的消息

设备的消息(告警、任务进度、命令结果),按时间倒序,按页码分页。每一项是保存的消息原文:msg_id、type(info、ok、warn、error)、source、title、created_at、payload_gz(gzip + base64 编码的日志附件,或 null),命令结果另有 cmd_id。使用 API 密钥时,不返回属于脚本命令的消息(total 也不计入)。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

  • typestring· query

    只返回该类型的消息。

    可选值infookwarnerror

  • pageinteger· query

    范围1 – 1000000默认1

  • per_pageinteger· query

    范围1 – 1000默认50

返回

  • 200OK

    一页消息。

    返回字段(12)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/messages' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/gpus

列出你所有设备的显卡

你的设备(以及你能看到的共享分组)中每块 GPU 一行,支持筛选、排序和页码分页。counts 是按当前筛选条件(不含 problem)统计的数量;models、algos 和 hash_algos 列出可用于筛选或排序的值。problem 筛选有问题的 GPU:dropped、missing、temp_crit、temp_warn、fan、ecc、xid、idle、no_hash 或 any。可按列名排序,或按 hash:<algo>(该算法的算力)排序。

权限
host:read
API 密钥
必填
限流类
read

参数

  • groupstring· query

    分组 ID。不传则为你能看到的全部设备。

  • modelstring· query

    GPU 型号名称。

  • problemstring· query

    可选值droppedmissingtemp_crittemp_warnfaneccxididleno_hashany

  • algostring· query

    只返回运行该算法的 GPU。

  • connectivitystring· query

    可选值onlineoffline

  • sortstring· query

    device、state、index、bus、model、vendor、vram、temp、mem_temp、fan、rpm、power、power_limit、util、mem_util、pstate、clock、core_offset、mem_clock、mem_offset、throttle、problems,或 hash:<algo>。

  • orderstring· query

    可选值ascdesc

  • qstring· query

    搜索设备名称和 GPU 总线号(最多 64 个字符)。

    长度≤ 64

  • pageinteger· query

    范围1 – 1000000默认1

  • per_pageinteger· query

    范围1 – 1000默认50

返回

  • 200OK

    一页 GPU。

    返回字段(75)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    group_not_found:分组不存在,或你无法使用(不属于你、角色权限不足、不在该密钥的分组范围内,或不允许 API 访问)。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    device_index_rebuilding:设备数据正在重建,请稍后重试。也可能返回 request_timeout。

    • device_index_rebuilding
    • request_timeout

示例

curl 'https://suanzu.ai/api/v1/host/gpus' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/tags

列出你的设备标签

你能看到的标签:先是你自己的标签库,然后是共享分组给你的所有者的标签库(owner_id)。设备只能打其所有者的标签。在 POST /api/v1/host/machines/tags 中把 id 用作 tag_ids。用 POST /api/v1/host/tags 和 /api/v1/host/tags/{tag_id} 新建、重命名和删除你自己的标签。

权限
host:read
API 密钥
必填
限流类
read

返回

  • 200OK

    标签。

    返回字段(7)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/tags' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/host/tags

新建设备标签

在你自己的标签库中新建标签(每个账户最多 1000 个)。共享分组的标签属于分组所有者的标签库,你不能修改。限定了分组的密钥不能新建、重命名或删除标签(403 group_forbidden):标签库是账户级的。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • namestring必填

    去除首尾空白后 1-32 个字符。

  • colorinteger必填

    控制台使用的颜色编号。

    范围0 – 7

返回

  • 200OK

    已新建。

    返回字段(7)
  • 400Bad Request

    bad_request(缺少字段)、tag_name_invalid(去除首尾空白后 1-32 个字符)或 tag_color_invalid(0-7)。

    • bad_request
    • tag_name_invalid
    • tag_color_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden:密钥限定了分组,而这次要修改账户级模板或你的标签库。或 API 密钥错误。

    • group_forbidden
  • 409Conflict

    tag_name_taken(你已有同名标签)、tag_limit(已有 1000 个标签)。

    • tag_name_taken
    • tag_limit
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/tags' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "rack-1",
  "color": 3
}'
PATCH/api/v1/host/tags/{tag_id}

重命名或更改设备标签颜色

修改你自己的某个标签的名称、颜色或两者。设备上的标签保留。密钥规则同新建。

权限
host:write
API 密钥
必填
限流类
write

参数

  • tag_idstring· path必填

    GET /api/v1/host/tags 返回的 id。

    示例12格式^[1-9][0-9]*$

请求体application/json

  • namestring

    去除首尾空白后 1-32 个字符。

  • colorinteger

    范围0 – 7

返回

  • 200OK

    已修改。

    返回字段(7)
  • 400Bad Request

    bad_request(缺少字段)、tag_name_invalid(去除首尾空白后 1-32 个字符)或 tag_color_invalid(0-7)。

    • bad_request
    • tag_name_invalid
    • tag_color_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden:密钥限定了分组,而这次要修改账户级模板或你的标签库。或 API 密钥错误。

    • group_forbidden
  • 404Not Found

    tag_not_found:你自己的标签库中没有这个标签。

    • tag_not_found
  • 409Conflict

    tag_name_taken。

    • tag_name_taken
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PATCH 'https://suanzu.ai/api/v1/host/tags/12' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "color": 5
}'
DELETE/api/v1/host/tags/{tag_id}

删除设备标签

删除你自己的某个标签,并从所有打了该标签的设备上移除(removed_from = 移除的台数)。密钥规则同新建。

权限
host:write
API 密钥
必填
限流类
write

参数

  • tag_idstring· path必填

    GET /api/v1/host/tags 返回的 id。

    示例12格式^[1-9][0-9]*$

返回

  • 200OK

    已删除。

    返回字段(2)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden:密钥限定了分组,而这次要修改账户级模板或你的标签库。或 API 密钥错误。

    • group_forbidden
  • 404Not Found

    tag_not_found:你自己的标签库中没有这个标签。

    • tag_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X DELETE 'https://suanzu.ai/api/v1/host/tags/12' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/price-templates

列出价格模板

不带 group_id:global 为你的全局模板(group 为空)。带你拥有或共享给你的分组的 group_id:global 为该分组所有者的全局模板,group 为该分组的模板;这些就是你可以用 POST /api/v1/host/machines/price-template 套用到该分组设备上的模板。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • group_idstring· query

    你拥有或共享给你的分组。不传则为你自己的账户级条目。

返回

  • 200OK

    模板。

    返回字段(19)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    group_not_found:分组不存在,或你无法使用(不属于你、角色权限不足、不在该密钥的分组范围内,或不允许 API 访问)。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/price-templates' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/host/price-templates

新建价格模板

group_id: null 新建账户级模板;传分组 ID 则新建该分组的模板(只能是你拥有的分组)。prices.gpu 以 GPU 型号名(有 show_name 时用它,否则用 name)为键,值为 {price, power_w, fan};prices.cpu 以 CPU 型号为键,值为价格;至少一行。价格为十进制字符串,大于 0 且不超过每块 GPU(或每颗 CPU)每小时 100 USDT,最多 3 位小数;power_w 为正整数或 null(不限);fan 为 auto 或 max。新建模板不会改动任何设备;用 POST /api/v1/host/machines/price-template 套用。限定了分组的密钥只能新建其分组内的模板。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • namestring必填

    去除首尾空白后 1-64 个字符。

  • pricesobject必填

    gpu:GPU 型号名(有 show_name 时用它,否则用 name)→ {price, power_w, fan};cpu:CPU 型号 → 价格。合计至少一行。

  • prices.gpuobject必填
  • prices.gpu.*object
  • prices.gpu.*.pricestring必填

    大于 0,不超过 100,最多 3 位小数。

  • prices.gpu.*.power_winteger | null必填

    租用期间每块 GPU 的功耗上限;null = 不限。

    范围≥ 1

  • prices.gpu.*.fanstring必填

    可选值automax

  • prices.cpuobject必填
  • prices.cpu.*string

    每颗 CPU 每小时的价格。

  • group_idstring | null

    null = 账户级。

返回

  • 200OK

    已新建。

    返回字段(10)
  • 400Bad Request

    bad_request,或 template_invalid(error 文本指出哪个名称、价格、power_w 或 fan 不对)。

    • bad_request
    • template_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden:密钥限定了分组,而这次要修改账户级模板或你的标签库。或 API 密钥错误。

    • group_forbidden
  • 404Not Found

    group_not_found:分组不存在,或你无法使用(不属于你、角色权限不足、不在该密钥的分组范围内,或不允许 API 访问)。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/price-templates' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Standard",
  "prices": {
    "gpu": {
      "NVIDIA CMP 50HX": {
        "price": "0.050",
        "power_w": 200,
        "fan": "auto"
      }
    },
    "cpu": {}
  },
  "group_id": null
}'
PATCH/api/v1/host/price-templates/{price_template_id}

修改价格模板

修改名称、价格或两者(至少传一项;prices 整份替换)。不会改动设备:之前套用的价格保持不变,直到你再次套用该模板。只能修改你自己账户和分组的模板。限定了分组的密钥不能修改账户级模板。

权限
host:write
API 密钥
必填
限流类
write

参数

  • price_template_idstring· path必填

    GET /api/v1/host/price-templates 返回的 id。

    示例5d0c6a2e9b1f4c3a8e7d6b5a4c3b2a10

请求体application/json

  • namestring
  • pricesobject

    gpu:GPU 型号名(有 show_name 时用它,否则用 name)→ {price, power_w, fan};cpu:CPU 型号 → 价格。合计至少一行。

  • prices.gpuobject必填
  • prices.gpu.*object
  • prices.gpu.*.pricestring必填

    大于 0,不超过 100,最多 3 位小数。

  • prices.gpu.*.power_winteger | null必填

    租用期间每块 GPU 的功耗上限;null = 不限。

    范围≥ 1

  • prices.gpu.*.fanstring必填

    可选值automax

  • prices.cpuobject必填
  • prices.cpu.*string

    每颗 CPU 每小时的价格。

返回

  • 200OK

    已修改。

    返回字段(10)
  • 400Bad Request

    bad_request,或 template_invalid(error 文本指出哪个名称、价格、power_w 或 fan 不对)。

    • bad_request
    • template_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden:密钥限定了分组,而这次要修改账户级模板或你的标签库。或 API 密钥错误。

    • group_forbidden
  • 404Not Found

    template_not_found:模板不存在,或不属于你的账户或你的分组(或不在密钥的分组范围内)。

    • template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PATCH 'https://suanzu.ai/api/v1/host/price-templates/5d0c6a2e9b1f4c3a8e7d6b5a4c3b2a10' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Standard 2"
}'
DELETE/api/v1/host/price-templates/{price_template_id}

删除价格模板

删除模板。设备保留从它套用的价格。权限同修改。

权限
host:write
API 密钥
必填
限流类
write

参数

  • price_template_idstring· path必填

    GET /api/v1/host/price-templates 返回的 id。

    示例5d0c6a2e9b1f4c3a8e7d6b5a4c3b2a10

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden:密钥限定了分组,而这次要修改账户级模板或你的标签库。或 API 密钥错误。

    • group_forbidden
  • 404Not Found

    template_not_found:模板不存在,或不属于你的账户或你的分组(或不在密钥的分组范围内)。

    • template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X DELETE 'https://suanzu.ai/api/v1/host/price-templates/5d0c6a2e9b1f4c3a8e7d6b5a4c3b2a10' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/task-templates

列出计算任务模板

group_id 规则同 GET /api/v1/host/price-templates。带 group_id 时,defaults 为该分组的默认任务列表(template_id 和 positions)。在 POST /api/v1/host/machines/tasks/apply 和 PUT /api/v1/host/machines/{machine_id}/tasks 中使用模板的 id。模板包含保存的变量原文。不列出调试版本;模板的 machine_count 也计入运行它调试版本的设备(每台只计一次)。需要被列出模板的账户(你自己或分组所有者)已开通高级功能。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • group_idstring· query

    你拥有或共享给你的分组。不传则为你自己的账户级条目。

返回

  • 200OK

    模板。

    返回字段(50)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled,或 API 密钥错误。

    • advanced_not_enabled
  • 404Not Found

    group_not_found:分组不存在,或你无法使用(不属于你、角色权限不足、不在该密钥的分组范围内,或不允许 API 访问)。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/task-templates' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/host/task-templates

新建计算任务模板

group_id: null 新建账户级模板(只能建在你自己的账户下,且只能用未限定分组的密钥);传分组 ID 则新建该分组的模板(共享分组需要管理员角色)。请求体与租用方模板相同(见简介中的「计算任务模板」),另有出租方专用字段 oc_template_id、run_in_container、container_image 和 accel.forward。新建模板不会改动任何设备;用 POST /api/v1/host/machines/tasks/apply 使用它。需要模板所属账户已开通高级功能,且该账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

出租方计算任务模板。与 RenterTaskTemplateDraft 相同,另有下面的出租方专用字段。

  • namestring必填
  • kindstring必填

    可选值customhive

  • descriptionstring
  • varsobject[]

    仅自定义任务。程序的环境变量(最多 64 个)。设置 ref 可从你的某条钱包/变量取值;此时 value 发送空字符串,它会被替换。

  • vars[].keystring必填

    须匹配 ^[A-Za-z_][A-Za-z0-9_]*$;不能以 SUANZU_ 开头,不能是保留名。

  • vars[].valuestring必填

    最多 4 KiB。带 ref 时也必填(发送空字符串)。

  • vars[].refstring | null

    你的某条钱包/变量的 id,或 null。

  • customobject
  • custom.start_commandstring

    用 bash -c 运行。最多 16 KiB。

  • custom.package_urlstring

    可选。启动前下载的程序包。

  • custom.extractboolean

    默认true

  • hiveobject
  • hive.minerstring

    程序包目录名。留空 = 从 install_url 的文件名推出。

  • hive.coinstring

    以 DIGITAL_CASH 传入。

  • hive.walletstring

    替换 %WAL%。带 wallet_ref 时发送空字符串。

  • hive.install_urlstring

    指向 .tar.gz / .tgz 程序包的 http(s) 链接。

  • hive.algostring

    以 CUSTOM_ALGO 传入。

  • hive.templatestring

    这个字段以及 url、pass、user_config 中的宏会被替换。

  • hive.urlstring
  • hive.passstring
  • hive.user_configstring
  • accelobject
  • accel.downloadboolean

    程序包下载加速(仅限 GitHub 发布附件)。

  • accel.forwardobject | null

    域名加速。设备经 SuanZu 中转节点访问这个 host:port;它必须出现在任务内容中。null = 不加速。

  • accel.forward.hoststring
  • accel.forward.portinteger

    范围1 – 65535

  • wallet_refstring | null

    仅 HiveOS。从某条钱包/变量(GET /api/v1/host/wallet-vars)取 hive.wallet。

  • followstring

    跟随最新版:latest = 只跟正式版,latest_beta = 含预发布。只用于带版本标签的 GitHub 发布附件下载地址,否则返回 400 follow_github_only。不带 = ""(模板整份替换,不带就会关掉跟随)。

    可选值latestlatest_beta默认

  • run_in_containerboolean

    在只看得到该任务 GPU 的容器中运行任务。

  • container_imagestring

    仅在 run_in_container 时有效。留空 = 默认镜像。常用镜像:GET /api/v1/host/images。

  • oc_template_idstring | null

    任务 GPU 使用的超频模板(你的账户级模板,或同一分组的模板)。null = 不绑定。

  • group_idstring | null

    null = 账户级。

返回

  • 200OK

    已新建。

    返回字段(24)
  • 400Bad Request

    bad_request、template_invalid(error 文本指出是哪个字段)、hive_vars_unsupported、hive_wallet_required、wallet_var_unavailable、oc_template_unavailable(该超频模板不能用于这个模板)、container_image_invalid、forward_not_in_task(加速的 host:port 不在任务内容中)、forward_forbidden_address、forward_dns_error、task_config_too_large(带 machine_count)、package_url_private_host、package_url_github_query、accel_download_github_only 或 follow_github_only(跟随最新版只用于带版本标签的 GitHub 发布地址)。

    • bad_request
    • template_invalid
    • hive_vars_unsupported
    • hive_wallet_required
    • wallet_var_unavailable
    • oc_template_unavailable
    • container_image_invalid
    • forward_not_in_task
    • forward_forbidden_address
    • forward_dns_error
    • task_config_too_large
    • package_url_private_host
    • package_url_github_query
    • accel_download_github_only
    • follow_github_only
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该分组的角色权限不足,或模板是账户级而密钥限定了分组)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    group_not_found:分组不存在,或你无法使用(不属于你、角色权限不足、不在该密钥的分组范围内,或不允许 API 访问)。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    forward_unconfigured、forward_capacity_full 或 forward_unavailable:域名加速暂时无法设置,什么都没有保存。请稍后重试,或关闭 accel.forward。也可能返回 request_timeout。

    • forward_unconfigured
    • forward_capacity_full
    • forward_unavailable
    • request_timeout

示例

curl -X POST 'https://suanzu.ai/api/v1/host/task-templates' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "group_id": null,
  "name": "Pearl",
  "kind": "hive",
  "description": "",
  "hive": {
    "miner": "",
    "coin": "PRL",
    "wallet": "prl1qexampleaddress",
    "install_url": "https://github.com/example/pearlfortune/releases/download/v1.2.3/pearlfortune-1.2.3.tar.gz",
    "algo": "",
    "template": "%WAL%.%WORKER_NAME%",
    "url": "stratum+tcp://pool.example.com:3333",
    "pass": "x",
    "user_config": ""
  },
  "oc_template_id": null
}'
PUT/api/v1/host/task-templates/{task_template_id}

修改计算任务模板

整份替换模板(请求体同新建,去掉 group_id;不能修改 group_id)。设备运行的内容有变化时,使用该模板的每台设备随下一次心跳收到新任务,任务会重启;machine_count 为受影响的设备数。账户级模板只能由其所有者用未限定分组的密钥修改;分组模板在共享分组中需要管理员角色。不能在这里修改调试版本(404 template_not_found);修改模板也不会改动它的调试版本。

权限
host:write
API 密钥
必填
限流类
write

参数

  • task_template_idstring· path必填

    GET /api/v1/host/task-templates 返回的 id。

    示例9c2e5b7a1d3f4e6a8b0c2d4e6f8a0b1c

请求体application/json

出租方计算任务模板。与 RenterTaskTemplateDraft 相同,另有下面的出租方专用字段。

  • namestring必填
  • kindstring必填

    可选值customhive

  • descriptionstring
  • varsobject[]

    仅自定义任务。程序的环境变量(最多 64 个)。设置 ref 可从你的某条钱包/变量取值;此时 value 发送空字符串,它会被替换。

  • vars[].keystring必填

    须匹配 ^[A-Za-z_][A-Za-z0-9_]*$;不能以 SUANZU_ 开头,不能是保留名。

  • vars[].valuestring必填

    最多 4 KiB。带 ref 时也必填(发送空字符串)。

  • vars[].refstring | null

    你的某条钱包/变量的 id,或 null。

  • customobject
  • custom.start_commandstring

    用 bash -c 运行。最多 16 KiB。

  • custom.package_urlstring

    可选。启动前下载的程序包。

  • custom.extractboolean

    默认true

  • hiveobject
  • hive.minerstring

    程序包目录名。留空 = 从 install_url 的文件名推出。

  • hive.coinstring

    以 DIGITAL_CASH 传入。

  • hive.walletstring

    替换 %WAL%。带 wallet_ref 时发送空字符串。

  • hive.install_urlstring

    指向 .tar.gz / .tgz 程序包的 http(s) 链接。

  • hive.algostring

    以 CUSTOM_ALGO 传入。

  • hive.templatestring

    这个字段以及 url、pass、user_config 中的宏会被替换。

  • hive.urlstring
  • hive.passstring
  • hive.user_configstring
  • accelobject
  • accel.downloadboolean

    程序包下载加速(仅限 GitHub 发布附件)。

  • accel.forwardobject | null

    域名加速。设备经 SuanZu 中转节点访问这个 host:port;它必须出现在任务内容中。null = 不加速。

  • accel.forward.hoststring
  • accel.forward.portinteger

    范围1 – 65535

  • wallet_refstring | null

    仅 HiveOS。从某条钱包/变量(GET /api/v1/host/wallet-vars)取 hive.wallet。

  • followstring

    跟随最新版:latest = 只跟正式版,latest_beta = 含预发布。只用于带版本标签的 GitHub 发布附件下载地址,否则返回 400 follow_github_only。不带 = ""(模板整份替换,不带就会关掉跟随)。

    可选值latestlatest_beta默认

  • run_in_containerboolean

    在只看得到该任务 GPU 的容器中运行任务。

  • container_imagestring

    仅在 run_in_container 时有效。留空 = 默认镜像。常用镜像:GET /api/v1/host/images。

  • oc_template_idstring | null

    任务 GPU 使用的超频模板(你的账户级模板,或同一分组的模板)。null = 不绑定。

返回

  • 200OK

    已修改。

    返回字段(25)
  • 400Bad Request

    bad_request、template_invalid(error 文本指出是哪个字段)、hive_vars_unsupported、hive_wallet_required、wallet_var_unavailable、oc_template_unavailable(该超频模板不能用于这个模板)、container_image_invalid、forward_not_in_task(加速的 host:port 不在任务内容中)、forward_forbidden_address、forward_dns_error、task_config_too_large(带 machine_count)、package_url_private_host、package_url_github_query、accel_download_github_only 或 follow_github_only(跟随最新版只用于带版本标签的 GitHub 发布地址)。

    • bad_request
    • template_invalid
    • hive_vars_unsupported
    • hive_wallet_required
    • wallet_var_unavailable
    • oc_template_unavailable
    • container_image_invalid
    • forward_not_in_task
    • forward_forbidden_address
    • forward_dns_error
    • task_config_too_large
    • package_url_private_host
    • package_url_github_query
    • accel_download_github_only
    • follow_github_only
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该分组的角色权限不足,或模板是账户级而密钥限定了分组)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    template_not_found:模板不存在,或你看不到它(其他账户的账户级模板、不在密钥分组范围内的分组)。

    • template_not_found
  • 409Conflict

    forward_changed:期间该模板的域名加速被修改;请重新读取后再发送。

    • forward_changed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    forward_unconfigured、forward_capacity_full 或 forward_unavailable:域名加速暂时无法设置,什么都没有保存。请稍后重试,或关闭 accel.forward。也可能返回 request_timeout。

    • forward_unconfigured
    • forward_capacity_full
    • forward_unavailable
    • request_timeout

示例

curl -X PUT 'https://suanzu.ai/api/v1/host/task-templates/9c2e5b7a1d3f4e6a8b0c2d4e6f8a0b1c' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Pearl",
  "kind": "hive",
  "description": "",
  "hive": {
    "miner": "",
    "coin": "PRL",
    "wallet": "prl1qnewaddress",
    "install_url": "https://github.com/example/pearlfortune/releases/download/v1.2.4/pearlfortune-1.2.4.tar.gz",
    "algo": "",
    "template": "%WAL%.%WORKER_NAME%",
    "url": "stratum+tcp://pool.example.com:3333",
    "pass": "x",
    "user_config": ""
  },
  "oc_template_id": null
}'
DELETE/api/v1/host/task-templates/{task_template_id}

删除计算任务模板

删除没有设备使用的模板;否则返回 409 task_template_in_use 并带 machine_count 和 machines(先从这些设备上移除该任务)。运行它调试版本的设备也算在用(machines[].debug: true)。模板也会从分组默认任务列表中移除(removed_defaults = 移除的列表数),它的调试版本一起删除(removed_debug = 删除的份数)。不能在这里删除调试版本本身(404 template_not_found)。权限同修改。

权限
host:write
API 密钥
必填
限流类
write

参数

  • task_template_idstring· path必填

    GET /api/v1/host/task-templates 返回的 id。

    示例9c2e5b7a1d3f4e6a8b0c2d4e6f8a0b1c

返回

  • 200OK

    已删除。

    返回字段(3)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该分组的角色权限不足,或模板是账户级而密钥限定了分组)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    template_not_found:模板不存在,或你看不到它(其他账户的账户级模板、不在密钥分组范围内的分组)。

    • template_not_found
  • 409Conflict

    task_template_in_use:仍有设备在使用它或它的调试版本(machine_count、machines;machines[].debug 同 GET /api/v1/host/task-templates/{task_template_id}/usage)。

    • task_template_in_use
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    forward_unconfigured、forward_capacity_full 或 forward_unavailable:域名加速暂时无法设置,什么都没有保存。请稍后重试,或关闭 accel.forward。也可能返回 request_timeout。

    • forward_unconfigured
    • forward_capacity_full
    • forward_unavailable
    • request_timeout

示例

curl -X DELETE 'https://suanzu.ai/api/v1/host/task-templates/9c2e5b7a1d3f4e6a8b0c2d4e6f8a0b1c' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/task-templates/{task_template_id}/usage

列出使用某计算任务模板的设备

任务使用该模板或它调试版本的设备:machine_count 和前 200 台设备(每台只计一次;运行的是调试版本时 debug: true)。只计你能看到的设备;限定了分组的密钥只计其分组内的设备。debug_count 为该模板在所有分组中的调试版本份数合计。只读。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • task_template_idstring· path必填

    GET /api/v1/host/task-templates 返回的 id。

    示例9c2e5b7a1d3f4e6a8b0c2d4e6f8a0b1c

返回

  • 200OK

    设备。

    返回字段(7)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled,或 API 密钥错误。

    • advanced_not_enabled
  • 404Not Found

    template_not_found:模板不存在,或你看不到它(其他账户的账户级模板、不在密钥分组范围内的分组)。

    • template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/task-templates/9c2e5b7a1d3f4e6a8b0c2d4e6f8a0b1c/usage' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/images

列出计算任务的常用镜像

在容器里运行的计算任务可用的常用容器镜像。把 image 的值填进计算任务模板(POST /api/v1/host/task-templates)的 container_image。模板保存的是镜像地址,不是 id,也可以填其他任意镜像地址。gpu: false 的镜像是 CPU 镜像,不带 CUDA 运行库。min_cuda 是设备驱动必须支持的最低 CUDA 版本(为空表示无要求);它只是提示,保存模板时不检查。所有账户和分组看到的列表相同。

权限
host:read
API 密钥
必填
限流类
read

返回

  • 200OK

    常用镜像。

    返回字段(6)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/images' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/quote-coins

列出有行情的币种

SuanZu 有行情数据的币种。把 code 填进计算任务模板(POST /api/v1/host/task-templates)的 quote_coin,即可显示运行该模板的设备的预计产出;"" 表示不选。模板只保存代码,不检查当前是否有行情。at 是行情最后更新的时间(UNIX 秒)。prod: false 的币种仍在测试,控制台暂不提供。按 project、再按 code 排序。所有账户和分组看到的列表相同。

权限
host:read
API 密钥
必填
限流类
read

返回

  • 200OK

    有行情的币种。

    返回字段(5)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/quote-coins' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/oc-templates

列出超频模板

group_id 规则同 GET /api/v1/host/price-templates。每个模板在 models 中按 GPU 型号给出 6 项超频值;用 POST /api/v1/host/machines/oc-template 套用。需要被列出模板的账户已开通高级功能。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • group_idstring· query

    你拥有或共享给你的分组。不传则为你自己的账户级条目。

返回

  • 200OK

    模板。

    返回字段(25)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled,或 API 密钥错误。

    • advanced_not_enabled
  • 404Not Found

    group_not_found:分组不存在,或你无法使用(不属于你、角色权限不足、不在该密钥的分组范围内,或不允许 API 访问)。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/oc-templates' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/host/oc-templates

新建超频模板

group_id: null 新建账户级模板(只能建在你自己的账户下,且只能用未限定分组的密钥);传分组 ID 则新建该分组的模板(共享分组需要管理员角色)。models 以 1-64 个 GPU 型号名(有 show_name 时用它,否则用 name)为键,值为全部 6 项;每项是 PUT /api/v1/host/machines/{machine_id}/oc 允许范围内的整数,或 null(不设置)。新建模板不会改动任何设备;用 POST /api/v1/host/machines/oc-template 套用。需要已开通高级功能,且账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • namestring必填

    去除首尾空白后 1-64 个字符。

  • descriptionstring

    长度≤ 256

  • modelsobject必填

    GPU 型号名(有 show_name 时用它,否则用 name;驱动通用名不收)→ 全部 6 项(每项为整数或 null),另可带 advanced(对象 = 该型号打开高级参数;null 或不带 = 关闭)。

  • models.*object
  • models.*.power_limit_winteger | null必填
  • models.*.core_lock_mhzinteger | null必填
  • models.*.mem_lock_mhzinteger | null必填
  • models.*.core_offset_mhzinteger | null必填
  • models.*.mem_offset_mhzinteger | null必填
  • models.*.fan_percentinteger | null必填
  • models.*.advancedobject | null

    一块 GPU(或模板中一个型号)的高级参数。对象 = 打开;null 或不带 = 关闭:不下发、不核对。恰好这 4 个键;0 = 默认(出厂值)。只能为 0 或负数;xbar_ratio 是比例。超出范围返回 400 oc_param_out_of_range,带 field、min 和 max。设备需要 Agent oc.adv_agent_min 及以上;更早的 Agent 收不到这些值。

  • models.*.advanced.xbar_rationumber必填

    XBAR 比例,0.05-1.00,最多 4 位小数,或 0。

  • models.*.advanced.msvdd_vmin_mvinteger必填

    MSVDD 最低电压偏移,单位 mV。

    范围-500 – 0

  • models.*.advanced.xbar_clock_offset_mhzinteger必填

    XBAR 时钟偏移,单位 MHz。

    范围-1500 – 0

  • models.*.advanced.vcore_offset_mvinteger必填

    核心电压偏移,单位 mV。

    范围-200 – 0

  • group_idstring | null

    null = 账户级。

返回

  • 200OK

    已新建。

    返回字段(13)
  • 400Bad Request

    bad_request(例如修改时传了 group_id)、template_invalid(名称、备注或 models 无效)、oc_param_out_of_range(带 field、min、max 和 model)。

    • bad_request
    • template_invalid
    • oc_param_out_of_range
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该分组的角色权限不足,或模板是账户级而密钥限定了分组)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    group_not_found:分组不存在,或你无法使用(不属于你、角色权限不足、不在该密钥的分组范围内,或不允许 API 访问)。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/oc-templates' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Low power",
  "description": "",
  "models": {
    "NVIDIA CMP 50HX": {
      "power_limit_w": 180,
      "core_lock_mhz": null,
      "mem_lock_mhz": null,
      "core_offset_mhz": 100,
      "mem_offset_mhz": 0,
      "fan_percent": null
    }
  },
  "group_id": null
}'
PUT/api/v1/host/oc-templates/{oc_template_id}

修改超频模板

替换名称、备注和 models(三项都要传;不能修改 group_id)。计算任务通过 oc_template_id 使用该模板的设备随下一次心跳收到新值;machines 为受影响的设备数。直接套用过该模板的设备保留当时得到的值。账户级模板只能由其所有者用未限定分组的密钥修改;分组模板在共享分组中需要管理员角色。

权限
host:write
API 密钥
必填
限流类
write

参数

  • oc_template_idstring· path必填

    GET /api/v1/host/oc-templates 返回的 id。

    示例7a1b2c3d4e5f60718293a4b5c6d7e8f9

请求体application/json

  • namestring必填

    去除首尾空白后 1-64 个字符。

  • descriptionstring

    长度≤ 256

  • modelsobject必填

    GPU 型号名(有 show_name 时用它,否则用 name;驱动通用名不收)→ 全部 6 项(每项为整数或 null),另可带 advanced(对象 = 该型号打开高级参数;null 或不带 = 关闭)。

  • models.*object
  • models.*.power_limit_winteger | null必填
  • models.*.core_lock_mhzinteger | null必填
  • models.*.mem_lock_mhzinteger | null必填
  • models.*.core_offset_mhzinteger | null必填
  • models.*.mem_offset_mhzinteger | null必填
  • models.*.fan_percentinteger | null必填
  • models.*.advancedobject | null

    一块 GPU(或模板中一个型号)的高级参数。对象 = 打开;null 或不带 = 关闭:不下发、不核对。恰好这 4 个键;0 = 默认(出厂值)。只能为 0 或负数;xbar_ratio 是比例。超出范围返回 400 oc_param_out_of_range,带 field、min 和 max。设备需要 Agent oc.adv_agent_min 及以上;更早的 Agent 收不到这些值。

  • models.*.advanced.xbar_rationumber必填

    XBAR 比例,0.05-1.00,最多 4 位小数,或 0。

  • models.*.advanced.msvdd_vmin_mvinteger必填

    MSVDD 最低电压偏移,单位 mV。

    范围-500 – 0

  • models.*.advanced.xbar_clock_offset_mhzinteger必填

    XBAR 时钟偏移,单位 MHz。

    范围-1500 – 0

  • models.*.advanced.vcore_offset_mvinteger必填

    核心电压偏移,单位 mV。

    范围-200 – 0

返回

  • 200OK

    已修改。

    返回字段(14)
  • 400Bad Request

    bad_request(例如修改时传了 group_id)、template_invalid(名称、备注或 models 无效)、oc_param_out_of_range(带 field、min、max 和 model)。

    • bad_request
    • template_invalid
    • oc_param_out_of_range
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该分组的角色权限不足,或模板是账户级而密钥限定了分组)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    oc_template_not_found:模板不存在,或你看不到它。

    • oc_template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PUT 'https://suanzu.ai/api/v1/host/oc-templates/7a1b2c3d4e5f60718293a4b5c6d7e8f9' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Low power",
  "description": "",
  "models": {
    "NVIDIA CMP 50HX": {
      "power_limit_w": 170,
      "core_lock_mhz": null,
      "mem_lock_mhz": null,
      "core_offset_mhz": 100,
      "mem_offset_mhz": 0,
      "fan_percent": null
    }
  }
}'
DELETE/api/v1/host/oc-templates/{oc_template_id}

删除超频模板

删除没有计算任务模板使用的模板;否则返回 409 oc_template_in_use 并带 templates。设备保留从它套用的值。权限同修改。

权限
host:write
API 密钥
必填
限流类
write

参数

  • oc_template_idstring· path必填

    GET /api/v1/host/oc-templates 返回的 id。

    示例7a1b2c3d4e5f60718293a4b5c6d7e8f9

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该分组的角色权限不足,或模板是账户级而密钥限定了分组)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    oc_template_not_found:模板不存在,或你看不到它。

    • oc_template_not_found
  • 409Conflict

    oc_template_in_use:仍有计算任务模板使用它(templates)。

    • oc_template_in_use
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X DELETE 'https://suanzu.ai/api/v1/host/oc-templates/7a1b2c3d4e5f60718293a4b5c6d7e8f9' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/fan-templates

列出自动风扇模板

group_id 规则同 GET /api/v1/host/price-templates。用 POST /api/v1/host/machines/autofan-template 套用。需要被列出模板的账户已开通高级功能。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • group_idstring· query

    你拥有或共享给你的分组。不传则为你自己的账户级条目。

返回

  • 200OK

    模板。

    返回字段(37)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled,或 API 密钥错误。

    • advanced_not_enabled
  • 404Not Found

    group_not_found:分组不存在,或你无法使用(不属于你、角色权限不足、不在该密钥的分组范围内,或不允许 API 访问)。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/fan-templates' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/host/fan-templates

新建自动风扇模板

group_id: null 新建账户级模板(只能建在你自己的账户下,且只能用未限定分组的密钥);传分组 ID 则新建该分组的模板(共享分组需要管理员角色)。params 为自动风扇值(FanParams)。新建模板不会改动任何设备;用 POST /api/v1/host/machines/autofan-template 套用。需要已开通高级功能,且账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • namestring必填

    去除首尾空白后 1-64 个字符。

  • descriptionstring

    长度≤ 256

  • paramsobject必填

    自动风扇值(必填 7 项,另有可选的 stop_c)。Agent 在 min_fan 到 max_fan 之间调节风扇,使 GPU 核心接近 target_core_c、显存接近 target_mem_c。

  • params.enabledboolean必填
  • params.target_core_cinteger必填

    范围30 – 95

  • params.target_mem_cinteger必填

    范围40 – 110

  • params.min_faninteger必填

    风扇 %。

    范围1 – 100

  • params.max_faninteger必填

    风扇 %,不小于 min_fan。

    范围1 – 100

  • params.critical_cinteger必填

    至少为 target_core_c + 10。连续 2 轮高于它时按 overheat 处理;回落到 critical_c − 10 以下后恢复。

    范围50 – 110

  • params.overheatstring必填

    stop_task = 停止计算任务;hold_gpu = 只把这块 GPU 从任务中摘下。

    可选值stop_taskhold_gpu

  • params.stop_cinteger

    可选,不带时为 0(关)。PUT 整份替换,不带即关闭。核心温度低于它时把风扇交给显卡驱动,支持停转的显卡会停转。非 0 时为 30 到 target_core_c − 10(最多 85)。需要较新的 Agent;旧 Agent 不生效(见 autofan.stop_agent_old)。

    范围0 – 85

  • group_idstring | null

    null = 账户级。

返回

  • 200OK

    已新建。

    返回字段(19)
  • 400Bad Request

    bad_request(名称或备注无效、修改时传了 group_id,或 params 不是类型正确的 7 项)、autofan_param_invalid(某项超出范围;带 field、min、max)。

    • bad_request
    • autofan_param_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该分组的角色权限不足,或模板是账户级而密钥限定了分组)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    group_not_found:分组不存在,或你无法使用(不属于你、角色权限不足、不在该密钥的分组范围内,或不允许 API 访问)。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/fan-templates' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Quiet",
  "description": "",
  "params": {
    "enabled": true,
    "target_core_c": 65,
    "target_mem_c": 90,
    "min_fan": 30,
    "max_fan": 100,
    "critical_c": 90,
    "overheat": "stop_task"
  },
  "group_id": null
}'
PUT/api/v1/host/fan-templates/{fan_template_id}

修改自动风扇模板

替换名称、备注和 params(三项都要传;不能修改 group_id)。不会改动设备:套用过该模板的设备保留当时得到的值,直到你再次套用。账户级模板只能由其所有者用未限定分组的密钥修改;分组模板在共享分组中需要管理员角色。

权限
host:write
API 密钥
必填
限流类
write

参数

  • fan_template_idstring· path必填

    GET /api/v1/host/fan-templates 返回的 id。

    示例4b3c2d1e0f9a8b7c6d5e4f3a2b1c0d9e

请求体application/json

  • namestring必填
  • descriptionstring

    长度≤ 256

  • paramsobject必填

    自动风扇值(必填 7 项,另有可选的 stop_c)。Agent 在 min_fan 到 max_fan 之间调节风扇,使 GPU 核心接近 target_core_c、显存接近 target_mem_c。

  • params.enabledboolean必填
  • params.target_core_cinteger必填

    范围30 – 95

  • params.target_mem_cinteger必填

    范围40 – 110

  • params.min_faninteger必填

    风扇 %。

    范围1 – 100

  • params.max_faninteger必填

    风扇 %,不小于 min_fan。

    范围1 – 100

  • params.critical_cinteger必填

    至少为 target_core_c + 10。连续 2 轮高于它时按 overheat 处理;回落到 critical_c − 10 以下后恢复。

    范围50 – 110

  • params.overheatstring必填

    stop_task = 停止计算任务;hold_gpu = 只把这块 GPU 从任务中摘下。

    可选值stop_taskhold_gpu

  • params.stop_cinteger

    可选,不带时为 0(关)。PUT 整份替换,不带即关闭。核心温度低于它时把风扇交给显卡驱动,支持停转的显卡会停转。非 0 时为 30 到 target_core_c − 10(最多 85)。需要较新的 Agent;旧 Agent 不生效(见 autofan.stop_agent_old)。

    范围0 – 85

返回

  • 200OK

    已修改。

    返回字段(19)
  • 400Bad Request

    bad_request(名称或备注无效、修改时传了 group_id,或 params 不是类型正确的 7 项)、autofan_param_invalid(某项超出范围;带 field、min、max)。

    • bad_request
    • autofan_param_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该分组的角色权限不足,或模板是账户级而密钥限定了分组)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    fan_template_not_found:模板不存在,或你看不到它。

    • fan_template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PUT 'https://suanzu.ai/api/v1/host/fan-templates/4b3c2d1e0f9a8b7c6d5e4f3a2b1c0d9e' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Quiet",
  "description": "",
  "params": {
    "enabled": true,
    "target_core_c": 62,
    "target_mem_c": 90,
    "min_fan": 30,
    "max_fan": 100,
    "critical_c": 90,
    "overheat": "hold_gpu"
  }
}'
DELETE/api/v1/host/fan-templates/{fan_template_id}

删除自动风扇模板

删除模板。设备保留从它套用的自动风扇值。权限同修改。

权限
host:write
API 密钥
必填
限流类
write

参数

  • fan_template_idstring· path必填

    GET /api/v1/host/fan-templates 返回的 id。

    示例4b3c2d1e0f9a8b7c6d5e4f3a2b1c0d9e

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该分组的角色权限不足,或模板是账户级而密钥限定了分组)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    fan_template_not_found:模板不存在,或你看不到它。

    • fan_template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X DELETE 'https://suanzu.ai/api/v1/host/fan-templates/4b3c2d1e0f9a8b7c6d5e4f3a2b1c0d9e' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/host/machines/price-template

为设备套用价格模板

按价格模板为 1-500 台设备设置租金价格:GPU 设备取其 GPU 型号的价格、功耗上限和风扇模式,纯 CPU 设备取其 CPU 型号的价格。模板 ID 从 GET /api/v1/host/price-templates 获取(共享分组请带 group_id)。修改已上架设备的价格对新的租用生效。

每台设备单独处理:请检查 results[].ok 和 results[].code。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。共享分组需要管理员角色。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • template_idstring必填

    长度≥ 1

  • machine_idsstring[]必填

    设备 ID(machine_id,不是设备编号)。1-500 项;重复项会合并。

    长度1 – 500

返回

  • 200OK

    每台设备的结果。ok 为 false 时 results[].code 为:machine_not_found、group_forbidden、template_not_found(该模板不能用于这台设备)、gpu_unknown、gpu_mixed(GPU 型号不一致)、cpu_unknown、template_no_price(模板中没有该设备型号的价格)。

    返回字段(6)
  • 400Bad Request

    bad_request(请求体无效、缺少 template_id、machine_ids 为空或超过 500 个)、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 404Not Found

    template_not_found:模板不存在,或你看不到它。

    • template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    device_index_rebuilding:设备数据正在重建,请稍后重试。也可能返回 request_timeout。

    • device_index_rebuilding
    • request_timeout

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/price-template' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "template_id": "5d0c6a2e9b1f4c3a8e7d6b5a4c3b2a10",
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58"
  ]
}'
POST/api/v1/host/machines/tags

为设备添加或移除标签

为 1-1000 台设备添加(mode: add)或移除(mode: remove)标签。标签 ID 从 GET /api/v1/host/tags 获取;设备只能打其所有者的标签,最多 30 个。不能修改的设备列在 rejected 中并带 reason:machine_not_found、group_forbidden(需要操作员角色)、tag_owner_mismatch(某个标签不属于设备所有者)、tag_limit。changed 为标签有变化的设备数。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    长度1 – 1000

  • tag_idsstring[]必填

    长度1 – 1000格式^[1-9][0-9]{0,17}$

  • modestring必填

    可选值addremove

返回

  • 200OK

    不在 rejected 中的设备已完成。

    返回字段(5)
  • 400Bad Request

    bad_request(请求体无效、mode 无效、ID 为空或过多)、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    api_key_scope_denied、api_key_ip_denied 或 api_key_route_not_allowed。

    • api_key_scope_denied
    • api_key_ip_denied
    • api_key_route_not_allowed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    device_index_rebuilding:设备数据正在重建,请稍后重试。也可能返回 request_timeout。

    • device_index_rebuilding
    • request_timeout

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/tags' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58"
  ],
  "tag_ids": [
    "12"
  ],
  "mode": "add"
}'
POST/api/v1/host/machines/tasks/apply

为设备添加、替换或清空计算任务

一次请求修改 1-500 台设备的计算任务。op: add 添加 items(设备已在运行的模板会跳过,见 skipped);op: replace 让 items 成为完整的任务列表;op: clear 移除全部任务(items 必须为空)。每一项为 {template_id, positions}:positions 为 null = 全部 GPU,[] = 不用 GPU(CPU 任务),或升序的 GPU 位置 0-63,按每台设备的 GPU 换算。

每台设备单独处理:请检查 results[].ok 和 results[].code(machine_not_found、group_forbidden、template_not_found、task_limit_reached、task_config_too_large、gpu_unknown、gpu_position_out_of_range)。离线设备在重新上线后收到改动(deferred: offline)。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。共享分组需要管理员角色;设备所有者须已开通高级功能、账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • opstring必填

    可选值addreplaceclear

  • itemsobject[]必填

    长度≤ 16

  • items[].template_idstring必填

    长度≥ 1

  • items[].positionsinteger[] | null

    长度≤ 64

  • machine_idsstring[]必填

    长度1 – 500

返回

  • 200OK

    每台设备的结果。added 含新任务的 binding_id;updated、removed 和 kept 为任务 ID。

    返回字段(16)
  • 400Bad Request

    bad_request(op、items 或 positions 无效,machine_ids 为空、重复或超过 500 个)、task_template_duplicate、task_limit_reached(超过 16 项)、cross_group。

    • bad_request
    • task_template_duplicate
    • task_limit_reached
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled(设备所有者未开通高级功能)、account_overdue_restricted(设备所有者账户欠费),或 API 密钥错误(见 KeyForbidden)。

    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    template_not_found:模板不存在、你看不到它,或它是调试版本(调试版本用 PUT /api/v1/host/machines/{machine_id}/tasks 设置)。

    • template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/tasks/apply' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "op": "replace",
  "items": [
    {
      "template_id": "9c2e5b7a1d3f4e6a8b0c2d4e6f8a0b1c",
      "positions": null
    }
  ],
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58"
  ]
}'
PUT/api/v1/host/machines/{machine_id}/oc

设置单台设备的超频参数

设置一台设备上一块或多块 GPU 的超频值。cards 以 GPU 总线号(来自 GET /api/v1/host/machines/{machine_id} 的 gpus[].busid;也接受短格式 01:00.0)为键,值为全部 6 项。不在 cards 中的 GPU 不受影响,保留当前的值(包括其他工具设的值),不会恢复默认。每项都是整数;0 表示「不设置,使用默认值」。允许范围:power_limit_w 1-2000,core_lock_mhz 1-5000,mem_lock_mhz 1-20000,core_offset_mhz 和 mem_offset_mhz -10000 至 10000,fan_percent 1-100。

每块 GPU 还可以带 advanced(见 OCAdvanced)。一块 GPU 的 6 项与 advanced 整体写入:不带 advanced 表示这块 GPU 关闭高级参数(当前值保持不动)。

每次保存都会提高设备的超频 revision。设备在下一次心跳时应用;租用中的设备在租用结束后才应用(deferred: rented),离线设备在重新上线后应用(deferred: offline)。如需确认,读取 GET /api/v1/host/machines/{machine_id} 中的 oc:applied_revision 等于返回的 revision 表示已应用;rejected 和 result 显示失败原因。

如果目标 GPU 由计算任务(其超频模板)控制,返回 409 oc_task_managed 并带 tasks;带上 manual_only: true 重新发送,可将这台设备切换为仅手动调整超频。共享分组需要管理员角色;设备所有者须已开通高级功能、账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

请求体application/json

  • cardsobject必填

    GPU 总线号 → 6 项超频值,另可带 advanced。

  • cards.*object

    一块 GPU 的 6 项超频值(0 = 不设置,使用默认值),另可带 advanced。

  • cards.*.power_limit_winteger必填

    范围0 – 2000

  • cards.*.core_lock_mhzinteger必填

    范围0 – 5000

  • cards.*.mem_lock_mhzinteger必填

    范围0 – 20000

  • cards.*.core_offset_mhzinteger必填

    范围-10000 – 10000

  • cards.*.mem_offset_mhzinteger必填

    范围-10000 – 10000

  • cards.*.fan_percentinteger必填

    范围0 – 100

  • cards.*.advancedobject | null

    一块 GPU(或模板中一个型号)的高级参数。对象 = 打开;null 或不带 = 关闭:不下发、不核对。恰好这 4 个键;0 = 默认(出厂值)。只能为 0 或负数;xbar_ratio 是比例。超出范围返回 400 oc_param_out_of_range,带 field、min 和 max。设备需要 Agent oc.adv_agent_min 及以上;更早的 Agent 收不到这些值。

  • cards.*.advanced.xbar_rationumber必填

    XBAR 比例,0.05-1.00,最多 4 位小数,或 0。

  • cards.*.advanced.msvdd_vmin_mvinteger必填

    MSVDD 最低电压偏移,单位 mV。

    范围-500 – 0

  • cards.*.advanced.xbar_clock_offset_mhzinteger必填

    XBAR 时钟偏移,单位 MHz。

    范围-1500 – 0

  • cards.*.advanced.vcore_offset_mvinteger必填

    核心电压偏移,单位 mV。

    范围-200 – 0

  • manual_onlyboolean

    传 true 将设备切换为仅手动调整超频(目标 GPU 由计算任务控制时需要)。

返回

  • 200OK

    已保存。

    返回字段(3)
  • 400Bad Request

    bad_request(没有 cards 或超过 32 项、总线号无效,或该总线号不是这台设备可超频的 GPU)、template_invalid(缺少某项或不是整数)、oc_param_out_of_range(带 field、min、max 和 busid)、oc_no_gpu(设备没有支持超频的 GPU)。

    • bad_request
    • template_invalid
    • oc_param_out_of_range
    • oc_no_gpu
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该共享分组中的角色权限不足)、advanced_not_enabled、account_overdue_restricted 或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 409Conflict

    oc_task_managed:目标 GPU 由计算任务控制(tasks 列出这些任务);带 manual_only: true 重新发送。

    • oc_task_managed
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PUT 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/oc' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "cards": {
    "0000:01:00.0": {
      "power_limit_w": 180,
      "core_lock_mhz": 0,
      "mem_lock_mhz": 0,
      "core_offset_mhz": 100,
      "mem_offset_mhz": 0,
      "fan_percent": 70
    },
    "0000:02:00.0": {
      "power_limit_w": 180,
      "core_lock_mhz": 0,
      "mem_lock_mhz": 0,
      "core_offset_mhz": 100,
      "mem_offset_mhz": 0,
      "fan_percent": 70,
      "advanced": {
        "xbar_ratio": 0.306,
        "msvdd_vmin_mv": 0,
        "xbar_clock_offset_mhz": 0,
        "vcore_offset_mv": -40
      }
    }
  }
}'
POST/api/v1/host/machines/{machine_id}/oc/reapply

重新应用已保存的超频值

不修改内容,把已保存的超频值重新下发到设备(revision 加一)。适用于应用失败或 GPU 重置之后。设备必须在线且未被租用。共享分组需要操作员角色;设备所有者须已开通高级功能、账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

返回

  • 200OK

    已重新下发。

    返回字段(3)
  • 400Bad Request

    oc_no_gpu。

    • oc_no_gpu
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该共享分组中的角色权限不足)、advanced_not_enabled、account_overdue_restricted 或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 409Conflict

    offline、rented,或 oc_not_set(尚未保存任何超频值)。

    • offline
    • rented
    • oc_not_set
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/oc/reapply' \
  -H 'Authorization: Bearer sz_live_...'
PUT/api/v1/host/machines/{machine_id}/oc/manual-only

打开或关闭仅手动调整超频

打开仅手动调整后,计算任务不再修改这台设备的超频(原由任务控制的 GPU 保持当前值),批量套用模板时也会跳过它(oc_manual_only)。关闭后计算任务重新设置其 GPU。设置为当前状态不会有任何改动。角色和账户要求同 PUT /api/v1/host/machines/{machine_id}/oc。

权限
host:write
API 密钥
必填
限流类
write

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

请求体application/json

  • enabledboolean必填

返回

  • 200OK

    已保存。

    返回字段(3)
  • 400Bad Request

    bad_request(没有 enabled)、oc_no_gpu。

    • bad_request
    • oc_no_gpu
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该共享分组中的角色权限不足)、advanced_not_enabled、account_overdue_restricted 或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PUT 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/oc/manual-only' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "enabled": true
}'
POST/api/v1/host/machines/oc/reapply

在多台设备上重新应用已保存的超频值

与 POST /api/v1/host/machines/{machine_id}/oc/reapply 相同,作用于 1-500 台设备。每台设备单独处理(results[].code:machine_not_found、group_forbidden、offline、rented、oc_no_gpu、oc_not_set)。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    设备 ID(machine_id,不是设备编号)。1-500 项;重复项会合并。

    长度1 – 500

返回

  • 200OK

    每台设备的结果。

    返回字段(7)
  • 400Bad Request

    bad_request、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled(设备所有者未开通高级功能)、account_overdue_restricted(设备所有者账户欠费),或 API 密钥错误(见 KeyForbidden)。

    • advanced_not_enabled
    • account_overdue_restricted
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/oc/reapply' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58"
  ]
}'
POST/api/v1/host/machines/oc-template

为设备套用超频模板,或恢复默认

为 1-500 台设备套用超频模板:型号在模板 models 中的每块 GPU 取对应的值,其他 GPU 不受影响。template_id: null 表示把这台设备的每块 GPU 都恢复默认,包括其他工具设的值。必须带 template_id 键。模板 ID 从 GET /api/v1/host/oc-templates 获取。

套用时也会按型号复制 advanced;该型号未打开时,这些 GPU 关闭高级参数(当前值保持不动)。恢复默认时,reset_advanced(默认 true)同时恢复高级参数:打开了高级参数的 GPU 先写回出厂值再关闭;false 则高级参数保持不变。

每台设备单独处理(results[].code:machine_not_found、group_forbidden、oc_no_gpu、oc_manual_only(已打开仅手动调整)、oc_template_unavailable(该模板不能用于这台设备)、oc_template_no_model(模板中没有这台设备的任何 GPU 型号))。task_kept 为留给计算任务控制的 GPU 数。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。共享分组需要管理员角色。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    设备 ID(machine_id,不是设备编号)。1-500 项;重复项会合并。

    长度1 – 500

  • template_idstring | null必填

    null 表示恢复默认。

  • reset_advancedboolean

    仅在 template_id: null 时可用。不传 = true:高级参数也恢复默认。

返回

  • 200OK

    每台设备的结果。

    返回字段(7)
  • 400Bad Request

    bad_request(没有 template_id 键、machine_ids 无效,或 reset_advanced 与 template_id 同时出现)、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled(设备所有者未开通高级功能)、account_overdue_restricted(设备所有者账户欠费),或 API 密钥错误(见 KeyForbidden)。

    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    oc_template_not_found:模板不存在,或你看不到它。

    • oc_template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/oc-template' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58"
  ],
  "template_id": "7a1b2c3d4e5f60718293a4b5c6d7e8f9"
}'
PUT/api/v1/host/machines/{machine_id}/autofan

设置单台设备的自动风扇

设置一台设备的自动风扇值(FanParams;enabled: false 表示关闭自动风扇)。每次保存都会提高设备的超频 revision(自动风扇随超频一起下发)。设备在下一次心跳时应用;租用中的设备在租用结束后才应用(deferred: rented),离线设备在重新上线后应用(deferred: offline)。在 GET /api/v1/host/machines/{machine_id} 的 autofan 中查看设置和实时状态。共享分组需要管理员角色;设备所有者须已开通高级功能、账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

请求体application/json

  • paramsobject必填

    自动风扇值(必填 7 项,另有可选的 stop_c)。Agent 在 min_fan 到 max_fan 之间调节风扇,使 GPU 核心接近 target_core_c、显存接近 target_mem_c。

  • params.enabledboolean必填
  • params.target_core_cinteger必填

    范围30 – 95

  • params.target_mem_cinteger必填

    范围40 – 110

  • params.min_faninteger必填

    风扇 %。

    范围1 – 100

  • params.max_faninteger必填

    风扇 %,不小于 min_fan。

    范围1 – 100

  • params.critical_cinteger必填

    至少为 target_core_c + 10。连续 2 轮高于它时按 overheat 处理;回落到 critical_c − 10 以下后恢复。

    范围50 – 110

  • params.overheatstring必填

    stop_task = 停止计算任务;hold_gpu = 只把这块 GPU 从任务中摘下。

    可选值stop_taskhold_gpu

  • params.stop_cinteger

    可选,不带时为 0(关)。PUT 整份替换,不带即关闭。核心温度低于它时把风扇交给显卡驱动,支持停转的显卡会停转。非 0 时为 30 到 target_core_c − 10(最多 85)。需要较新的 Agent;旧 Agent 不生效(见 autofan.stop_agent_old)。

    范围0 – 85

返回

  • 200OK

    已保存。

    返回字段(3)
  • 400Bad Request

    bad_request(params 不是 7 项加可选的 stop_c、类型不对或 overheat 无效)、autofan_param_invalid(某项超出范围;带 field、min、max)、oc_no_gpu(设备没有支持它的 GPU)。

    • bad_request
    • autofan_param_invalid
    • oc_no_gpu
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该共享分组中的角色权限不足)、advanced_not_enabled、account_overdue_restricted 或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PUT 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/autofan' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "params": {
    "enabled": true,
    "target_core_c": 65,
    "target_mem_c": 90,
    "min_fan": 30,
    "max_fan": 100,
    "critical_c": 90,
    "overheat": "stop_task"
  }
}'
POST/api/v1/host/machines/autofan-template

为设备套用自动风扇模板,或关闭自动风扇

把自动风扇模板的值复制到 1-500 台设备。template_id: null 表示关闭自动风扇,其余值保留。必须带 template_id 键。模板 ID 从 GET /api/v1/host/fan-templates 获取。每台设备单独处理(results[].code:machine_not_found、group_forbidden、oc_no_gpu、fan_template_unavailable(该模板不能用于这台设备))。成功结果带 stop_agent_old: true 表示模板的 stop_c 已保存,但这台设备的 Agent 版本过低,暂不生效。使用 API 密钥时,所有设备必须属于同一分组(400 cross_group)。共享分组需要管理员角色。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • machine_idsstring[]必填

    设备 ID(machine_id,不是设备编号)。1-500 项;重复项会合并。

    长度1 – 500

  • template_idstring | null必填

    null 表示关闭自动风扇。

返回

  • 200OK

    每台设备的结果。

    返回字段(7)
  • 400Bad Request

    bad_request(没有 template_id 键、machine_ids 无效)、cross_group。

    • bad_request
    • cross_group
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled(设备所有者未开通高级功能)、account_overdue_restricted(设备所有者账户欠费),或 API 密钥错误(见 KeyForbidden)。

    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    fan_template_not_found:模板不存在,或你看不到它。

    • fan_template_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/autofan-template' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "machine_ids": [
    "314d1670-872d-4d8d-be94-a4ceea1c0c58"
  ],
  "template_id": "4b3c2d1e0f9a8b7c6d5e4f3a2b1c0d9e"
}'
POST/api/v1/host/machines/{machine_id}/remote/password

更换远程访问密码

更换 root 密码。 为已打开的远程会话换一个新密码和新的 session_id;旧密码失效,会话回到 connecting。使用 API 密钥时,只能更换由这同一把密钥打开的会话(这台设备的其他会话不受影响);否则返回 409 remote_not_open。新密码通过 GET /api/v1/host/machines/{machine_id}/remote 获取(等待 state: ready)。删除该密钥仍会关闭会话。需要 host:exec 和操作员角色。

权限
host:exec
API 密钥
必填
限流类
write

参数

  • machine_idstring· path必填

    你的设备的 machine_id(来自 GET /api/v1/host/machines),不是设备编号。

    示例314d1670-872d-4d8d-be94-a4ceea1c0c58

返回

  • 200OK

    密码已更换。

    返回字段(2)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(需要操作员角色),或 API 密钥错误。

    • group_forbidden
  • 404Not Found

    machine_not_found:设备不存在,或你无法查看(属于其他账户、不在该密钥的分组范围内,或该共享分组不允许 API 访问)。

    • machine_not_found
  • 409Conflict

    remote_not_open(这台设备上没有这把密钥打开的会话)、rented、agent_unsupported。

    • remote_not_open
    • rented
    • agent_unsupported
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited
  • 503Service Unavailable

    remote_unconfigured、remote_relay_unavailable。

    • remote_unconfigured
    • remote_relay_unavailable

示例

curl -X POST 'https://suanzu.ai/api/v1/host/machines/314d1670-872d-4d8d-be94-a4ceea1c0c58/remote/password' \
  -H 'Authorization: Bearer sz_live_...'
GET/api/v1/host/wallet-vars

列出钱包/变量

计算任务模板可以引用的具名值(钱包地址、服务器地址等)。group_id 规则同 GET /api/v1/host/price-templates。templates 列出你能看到的、引用该条的任务模板。值按保存的原文返回。需要被列出条目的账户已开通高级功能。

权限
host:read
API 密钥
必填
限流类
read_pg

参数

  • group_idstring· query

    你拥有或共享给你的分组。不传则为你自己的账户级条目。

返回

  • 200OK

    条目。

    返回字段(19)
  • 400Bad Request

    bad_request:参数缺失或无效,或带了未知的查询参数、请求体字段。

    • bad_request
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    advanced_not_enabled,或 API 密钥错误。

    • advanced_not_enabled
  • 404Not Found

    group_not_found:分组不存在,或你无法使用(不属于你、角色权限不足、不在该密钥的分组范围内,或不允许 API 访问)。

    • group_not_found
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl 'https://suanzu.ai/api/v1/host/wallet-vars' \
  -H 'Authorization: Bearer sz_live_...'
POST/api/v1/host/wallet-vars

新建钱包/变量

group_id: null 新建账户级条目(只能建在你自己的账户下,且只能用未限定分组的密钥);传分组 ID 则新建该分组的条目(共享分组需要管理员角色)。名称在账户级列表或同一分组内唯一。需要已开通高级功能,且账户未欠费。

权限
host:write
API 密钥
必填
限流类
write

请求体application/json

  • group_idstring | null

    null = 账户级。

  • namestring必填

    长度1 – 64

  • descriptionstring

    长度≤ 256

  • valuestring必填

    不能为空白,不能含 NUL。

    长度≤ 4096

返回

  • 200OK

    已新建。

    返回字段(10)
  • 400Bad Request

    bad_request、wallet_var_invalid(名称、备注或值无效)。

    • bad_request
    • wallet_var_invalid
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该分组的角色权限不足,或条目是账户级而密钥限定了分组)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    group_not_found:分组不存在,或你无法使用(不属于你、角色权限不足、不在该密钥的分组范围内,或不允许 API 访问)。

    • group_not_found
  • 409Conflict

    wallet_var_name_taken。

    • wallet_var_name_taken
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X POST 'https://suanzu.ai/api/v1/host/wallet-vars' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "group_id": null,
  "name": "main-wallet",
  "description": "",
  "value": "prl1qexampleaddress"
}'
PUT/api/v1/host/wallet-vars/{wallet_var_id}

修改钱包/变量

替换名称、备注和值(三项都要传;不能修改 group_id)。任务引用该条的设备随下一次心跳收到新值;template_count 和 machine_count 为受影响的模板数和设备数。账户级条目只能由其所有者用未限定分组的密钥修改;分组条目在共享分组中需要管理员角色。

权限
host:write
API 密钥
必填
限流类
write

参数

  • wallet_var_idstring· path必填

    GET /api/v1/host/wallet-vars 返回的 id。

    示例0f1e2d3c4b5a69788796a5b4c3d2e1f0格式^[0-9a-f]{32}$

请求体application/json

  • namestring必填

    长度1 – 64

  • descriptionstring

    长度≤ 256

  • valuestring必填

    长度≤ 4096

返回

  • 200OK

    已修改。

    返回字段(12)
  • 400Bad Request

    bad_request(例如传了 group_id)、wallet_var_invalid、task_config_too_large(引用它的任务会超出大小上限)。

    • bad_request
    • wallet_var_invalid
    • task_config_too_large
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该分组的角色权限不足,或条目是账户级而密钥限定了分组)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    wallet_var_not_found:条目不存在,或你看不到它(其他账户的账户级条目、不在密钥分组范围内的分组)。

    • wallet_var_not_found
  • 409Conflict

    wallet_var_name_taken。

    • wallet_var_name_taken
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X PUT 'https://suanzu.ai/api/v1/host/wallet-vars/0f1e2d3c4b5a69788796a5b4c3d2e1f0' \
  -H 'Authorization: Bearer sz_live_...' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "main-wallet",
  "description": "",
  "value": "prl1qnewaddress"
}'
DELETE/api/v1/host/wallet-vars/{wallet_var_id}

删除钱包/变量

删除没有任务模板引用的条目;否则返回 409 wallet_var_in_use 并带 templates。权限同修改。

权限
host:write
API 密钥
必填
限流类
write

参数

  • wallet_var_idstring· path必填

    GET /api/v1/host/wallet-vars 返回的 id。

    示例0f1e2d3c4b5a69788796a5b4c3d2e1f0格式^[0-9a-f]{32}$

返回

  • 200OK

    完成。

    返回字段(1)
  • 401Unauthorized

    api_key_invalid、api_key_expired 或 unauthorized(未发送密钥)。

    • api_key_invalid
    • api_key_expired
    • unauthorized
  • 403Forbidden

    group_forbidden(你在该分组的角色权限不足,或条目是账户级而密钥限定了分组)、advanced_not_enabled、account_overdue_restricted,或 API 密钥错误。

    • group_forbidden
    • advanced_not_enabled
    • account_overdue_restricted
  • 404Not Found

    wallet_var_not_found:条目不存在,或你看不到它(其他账户的账户级条目、不在密钥分组范围内的分组)。

    • wallet_var_not_found
  • 409Conflict

    wallet_var_in_use:仍有任务模板引用它(templates)。

    • wallet_var_in_use
  • 429Too Many Requests

    rate_limited。请等待 Retry-After 头中指定的秒数。

    • rate_limited

示例

curl -X DELETE 'https://suanzu.ai/api/v1/host/wallet-vars/0f1e2d3c4b5a69788796a5b4c3d2e1f0' \
  -H 'Authorization: Bearer sz_live_...'