# SuanZu public API (OpenAPI 3.1). # This file is the single source for https://suanzu.ai/docs/api and https://suanzu.ai/llms.txt. # x-zh: Chinese text for the docs page. x-codes: error codes of a response. x-flows: common call sequences. openapi: 3.1.0 info: title: SuanZu API version: "1" description: | Rent GPU and CPU machines, and manage the machines you rent out, from your own code. ## Authentication Create an API key in the console (Console → API keys) and send it on every request: `Authorization: Bearer sz_live_...`. Only this header is accepted; keys in the query string are ignored. Market endpoints also work without a key. A key has one or more scopes: | Scope | Allows | |---|---| | `renter:read` | Read your instances, balance, ledger, rent-balance deposits, compute task templates, instance tasks, tags, wallets and variables. | | `renter:write` | `renter:read` + rent, stop, change startup command, restart the container, get connection details, manage compute task templates, instance tasks, tags, wallets and variables. | | `host:read` | Read your machines, GPUs, messages, command results and progress, installable driver versions, tags, templates (and which machines use them), wallets and variables, history charts, fault history, groups, earnings, account, billing (also per day) and service-fee deposits. | | `host:write` | `host:read` + set prices (directly or from a template), list / unlist, rename, tag, set compute tasks, overclocking and auto-fan, manage templates (price, compute task, overclocking, auto-fan), tags, wallets and variables, pause / resume / restart compute tasks, fetch task logs. | | `host:exec` | `host:write` + reboot machines, upgrade the Agent, install NVIDIA drivers, open remote access (root shell on the machine) and change its password. | A key can be limited to some device groups and to an IP allowlist. A key without an allowlist works from any IP; with one, requests from other IPs get 403 `api_key_ip_denied`. Machines and groups outside the key's range behave as if they did not exist (404, or missing from lists). On groups shared with you by another account, your role in that group still applies, and the owner must allow API access for you. A key limited to device groups cannot change account-wide settings: account-wide templates (`group_id: null`), account-wide wallets and variables, and your tag library (403 `group_forbidden`); it can still read them and use them on its groups. **Keys see only your own account's money.** Balances, ledgers, billing and earnings are always your own account's. On groups shared with you by another account, a key never sees the owner's earnings, whatever your role: earnings fields are null (`summary.earnings`, `groups..earnings`), rental history has `show_income: false`, and `GET /api/v1/host/earnings` / `earnings/leases` with such a `group` return 404 `group_not_found`. Machine and status data in those groups is still returned by your role. **Multi-machine writes must stay in one group.** With an API key, a host request that names several machines (`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`) must only name machines in the same device group; otherwise the whole request is rejected with 400 `cross_group` and nothing is done. Ungrouped machines count as one group. Machines you cannot see do not count (they fail one by one with `machine_not_found`). ## Conventions - Amounts are decimal strings in USDT (for example `"0.053"`), never JSON numbers. - Times are UNIX seconds (integers). - IDs in responses are strings. Integer IDs (leases, ledger rows) are decimal strings, for example `"57"`. - Errors always look like `{"ok": false, "code": "...", "error": "..."}`. Branch on `code`; `error` is English text for humans and may change. - Every endpoint below can also return 500 `internal`; it is not listed on each endpoint. - Unknown query parameters, a query parameter sent twice, unknown body fields and out-of-range values are rejected with 400 `bad_request` on every endpoint; `error` names the parameter. (Only `gpu` and `cpu` of the market list may be repeated.) A body over the size limit gets 413 `body_too_large`. - A request that runs too long (5 seconds for GET, 30 seconds for other methods) gets 503 `request_timeout`. For a write this means the result is unknown: read the current state before you send it again. - A 200 on a write means the change is saved. Most settings then reach the machine with its next heartbeat. When you need to know that the machine actually applied something (a rental, a command, overclocking, compute tasks), poll the field named in "Async operations and polling" below. - GPU model names: market endpoints use short names (`CMP 50HX`, `RTX 4090`: the prefixes `NVIDIA `, `GeForce ` and `Tesla ` removed). Host endpoints use the full name the driver reports (`NVIDIA CMP 50HX`, `NVIDIA GeForce RTX 4090`) in `gpus[].name`, the `gpu` filter, `gpu_counts` and `/host/gpus`. Price template `prices.gpu` keys and overclocking template `models` keys use the GPU model name: `show_name` when the GPU has one (for example `CMP 170HX`, which the driver reports as `Graphics Device`), otherwise `name`. A generic driver name (`Graphics Device`, `NVIDIA Graphics Device`) is not accepted as a template key (400 `template_invalid`). ## Pagination | Style | Endpoints | Next page | |---|---|---| | `cursor` + `pageSize` (default 50, values above 200 count as 200) | `GET /api/v1/market/machines` | Pass `next` as `cursor` with the same filters and `sort`; `next` is empty on the last page | | `page` + `per_page` | Instances (default 50, history 20, max 1000), instance charges (default 20, max 50), host machines, machine messages and GPUs (default 50, max 1000) | `page` + 1 until `page` = `total_pages`. A page past the end returns the last page (machines, instances) or an empty list (charges) | | `page` + `page_size` (default 20, max 100) | Renter ledger, deposits, host ledger, earnings leases | `page` + 1 until you have `total` items | | `before` + `limit` (default 20, max 100) | `GET /api/v1/host/machines/{machine_id}/leases` | Pass `next_before` as `before`; null on the last page | | `limit` only (default 10, max 200) | `GET /api/v1/host/machines/{machine_id}/timeline` | No next page: ask for a larger `limit`. Only the newest 200 items can be read | `GET /api/v1/account/deposits/pending` is not paged (at most 50 items, newest first). ## Rate limits Each key has a per-minute budget for each rate-limit class (see `x-rate-limit-class` on every endpoint). Over the limit you get 429 `rate_limited` with a `Retry-After` header (seconds). | Class | Requests per minute per key | Used by | |---|---|---| | `read` | 120 | Market, host machine list / detail / tasks, GPUs, tags, preset images | | `read_pg` | 30 | Balances, ledgers, earnings, billing, instance list, checks, groups, precheck, command timeline and progress, driver versions, messages, templates, wallets and variables, history charts, fault history | | `write` | 30 | Writes: stop, prices, listing, names, tags, templates, task settings and control, task logs, overclocking, auto-fan, wallets and variables, reboot, Agent upgrade, driver install, remote open / close / password | | `order` | 10 | Rent a machine | | `remote` | 20 | Fetch connection details with passwords | `read_pg` and market requests also share a small server-wide concurrency pool; when it is busy you can get 429 `rate_limited` with `Retry-After: 1` even under your per-minute budget. Limits may change before release. ## Key errors Any request that carries an API key can fail before the endpoint runs: 401 `api_key_invalid`, 401 `api_key_expired` (create a new key), 403 `api_key_route_not_allowed` (this endpoint is not open to API keys), 403 `api_key_scope_denied`, 403 `api_key_ip_denied`, 429 `rate_limited`. A request without a key to an endpoint that needs one gets 401 `unauthorized`. ## Async operations and polling Machines report a heartbeat about every 15 seconds. A machine is `online` while its last heartbeat (`last_heartbeat_at`) is at most 120 seconds old; after that `connectivity` is `offline`, `status_reasons` has `offline` and the live values are null. Commands and settings normally reach a machine with its next heartbeat; while someone is viewing the machine or its group (the machine list with `group`, or the machine detail) it is woken within about a second. | Operation | Poll | Until | Interval | Typical / limit | On failure | |---|---|---|---|---|---| | Rent delivery | `GET /api/v1/renter/leases` (`tab=current`) | `phase` is `running` (`pulling` → `preparing` → `starting` → `running`) | 10 s | Image pull may take up to 1800 s after the order; preparing and starting together up to 300 s after the pull | The instance leaves the current tab and shows up in `tab=history` with `end_reason: delivery_failed` and a `fail_code`. Nothing is charged. `retry_code` (during delivery) names a step that failed once and is being retried | | Stop an instance | `GET /api/v1/renter/leases` (`tab=history`) | `phase` is `released` | 15 s | At least two machine rounds (about 30 s). No time limit: an offline machine stays `stopping` until it comes back | Billing ends when you stop, whatever the phase. `stopping` only means the machine has not confirmed the cleanup yet | | Startup command | `GET /api/v1/renter/leases` | `startup.rev` equals the returned `startup_rev` and `startup.state` is not `pending` | 10 s | Next heartbeat | `startup.state: failed` or `exited` with `exit_code`; read `GET .../container-log` | | Commands (`reboot`, `upgrade`, `task_restart`, `task_logs`) | `GET /api/v1/host/machines/{machine_id}/timeline` | The item with your `cmd_id` has `state` `ok` or `error` | 10-15 s | Picked up with the next heartbeat (about 15-20 s). An offline machine must come back and start it within 600 s (`expire_at`) | `state: error` with `note` (see the dictionary below); the reason is in `latest_title`, logs in `GET .../messages` (`payload_gz`) | | Reboot | Same as commands | `state: ok`, `note: rebooted` | 15 s | Done when the machine is back online with a newer `boot_time` | `note: timeout` when it is not back within 600 s after the reboot started | | Agent upgrade | Timeline, then `GET /api/v1/host/machines/{machine_id}` | `state: ok`, then `agent_version` shows the new version (next heartbeat after the install) | 15 s | Mostly download time; the download alone may take up to 1800 s | `state: error` with the reason in `latest_title` (for example `Upgrade failed (exit 1)`), or `note: timeout` when no result arrives by `expire_at` + 1800 s, or `interrupted` when the machine rebooted meanwhile | | Driver install | Timeline; progress in `GET /api/v1/host/machines/{machine_id}/commands/{cmd_id}/progress` | `state: ok`, `note: rebooted` (back online with the new `driver_version`) | 15 s (progress 5 s) | Download plus install, then one reboot. Limit: 120 min from the start to the reboot, 10 min to come back | `state: error`, the code in brackets in `latest_title` (`[driver_download_failed]`, `[driver_install_timeout]`, `[driver_reboot_timeout]`, `[driver_version_mismatch]`, …). Before the reboot the old driver stays; `[driver_reboot_required]` = the driver was installed but the time limit passed before the reboot, reboot the machine yourself | | Overclocking | `GET /api/v1/host/machines/{machine_id}` | `oc.applied_revision` equals `oc.revision`. The single-machine calls (`/machines/{machine_id}/oc…`, `/machines/{machine_id}/autofan`) return that `revision`; the batch calls (`/machines/oc-template`, `/machines/oc/reapply`, `/machines/autofan-template`) return only `results[]`, so read `oc.revision` after the call | 15 s | One or two heartbeats after the save. With `deferred: rented` only after the rental ends; with `deferred: offline` when the machine is back | `oc.rejected` (the whole config was refused), `oc.result[].results[].code` other than `ok` / `unchanged`, `oc.verify_error`. `applied_revision` null = the machine never reported | | Compute tasks | `GET /api/v1/host/machines/{machine_id}/tasks` (renter: `GET .../leases/{lease_id}/tasks`) | The `states[]` item with your `binding_id` has `state: running` and its `revision` equals the task's `revision` | 15 s | Next heartbeat plus the download of the program package | `state` `retrying`, `gpu_missing`, `unsupported`, `held`; `exits_1h` ≥ 3 means it keeps crashing. Read the task log (renter: `GET .../tasks/{binding_id}/log`) and `latest` | | Task stats (hash rate) | Same | `stats_at` is set and `stats[]` has your `binding_id` | 30 s | Usually 15-35 s after the task reaches `running`. HiveOS tasks (`kind: hive`) only; custom tasks report no stats | No stats while the task is not `running`; they disappear 1200 s after the machine stops reporting them | `syncing: true` on the task endpoints means the task list is still being written; read again after a few seconds. Stats and states belong to the task list the machine reported last: after a change, wait until `states[]` shows the new `revision`. ## Status and code dictionary **Machine `status`** (host endpoints; the "status" filter uses the same values): | `status` | Meaning | What you can do | What the platform does | |---|---|---|---| | `unpriced` | No price set, not listed, no problem | Set a price, then list | Nothing | | `unlisted` | Priced but not listed, no problem | List it | Nothing | | `available` | Listed and rentable | Rent-related changes apply to new rentals | Shows it on the market | | `noncompliant` | Not listed, and it has a problem (`status_reasons`) | Fix the problem; listing fails with `not_eligible` | Nothing | | `fault` | Listed, but it has a problem (`status_reasons`, offline included) | Fix it; it comes back by itself | Hides it from the market until the problem is gone (you keep the listing) | | `rented` | Has a rental that is not released yet (delivery and stopping included) | See "Rented machines" below | Stops the rental for problems marked `stop` | **`status_reasons` codes.** Columns: what happens when the problem shows up before listing / while listed / while rented. `reject` = listing or renting is refused; `hide` = hidden from the market (`fault`); `refresh` = the listed specs are updated, still rentable; `stop` = the rental is stopped and the machine unlisted; `notice` = you are only notified; `-` = not checked in that state. `GET .../checks` shows the same as `outcome`. | Code | Meaning | Not listed | Listed | Rented | |---|---|---|---|---| | `offline` | No heartbeat for 120 s | reject | hide | notice | | `offline_rented` | Rented machine offline for 600 s (billing stops at the last heartbeat) | - | - | stop | | `price_unset` | Listed without a price for its unit | reject | - | - | | `group_invalid` | Its device group was deleted | reject | hide | notice | | `gpu_dropped` | A GPU is not seen by the driver | reject | hide | stop | | `gpu_driver` | The driver cannot read a GPU | reject | hide | stop | | `gpu_ecc_uncorrected` | Uncorrected ECC errors | reject | hide | stop | | `gpu_probe_failed` | GPU data could not be read (2 rounds in a row) | reject | hide | stop | | `gpu_count_low` | Fewer GPUs than listed (or than `expected_gpu_count`) | reject | hide | stop | | `gpu_mixed` | More than one GPU model | reject | hide | notice | | `gpu_changed` | GPU model or memory changed since listing | - | hide | stop | | `driver_changed` | Driver or CUDA version changed since listing | - | hide | stop | | `cpu_changed` | CPU model or socket count changed | - | hide | stop | | `ram_low` | Less memory than listed | - | hide | stop | | `ram_more` | More memory than listed | - | refresh | - | | `disk_changed` | Disk size changed by more than 1%, or disk type changed | - | hide | stop | | `os_changed` | OS or kernel changed | - | refresh | stop | | `pcie_degraded` | A GPU runs at a lower PCIe generation or width than listed | - | refresh | stop | | `pcie_changed` | PCIe link changed, none lower | - | refresh | notice | | `pcie_unstable` | PCIe link changed 3 or more times in 24 hours | reject | hide | notice | | `docker_down` | Docker is not installed or not running | reject | hide | stop | | `nvidia_runtime_missing` | NVIDIA GPUs but no NVIDIA container runtime | reject | hide | stop | | `runc_outdated` | runc older than 1.2.8 or unknown | reject | hide | stop | | `nvidia_toolkit_outdated` | NVIDIA GPUs with an NVIDIA Container Toolkit older than 1.19.1 or unknown | reject | hide | notice | | `disk_low` | Less than 5 GiB free on the system disk | reject | hide | notice | | `collect_invalid` | CPU, memory or disk data cannot be read | reject | hide | notice | | `rent_env_unsupported` | Not a physical machine or VM (container, WSL) | reject | hide | notice | | `agent_outdated` | Agent older than 1.2.0 | reject | hide | notice | | `tools_missing` | The Agent tool package is still downloading | reject | hide | notice | | `identity_conflict` | Two machines report with the same identity | reject | hide | notice | | `owner_inactive` | The owner account has stopped renting out | reject | hide | notice | | `data_invalid` | The machine's data is broken | reject | hide | notice | | `oc_rental_tampered` | Overclocking was changed by something else during a rental | - | - | stop | | `rent_container_lost` | The renter's container is gone | - | - | stop | | `rent_isolation_failed` | Network isolation of the rental cannot be checked or restored | - | - | stop | A code not in this table is handled as `hide`. `CheckRow.result`: `pass`, `fail`, `na` (not applicable now), `pending` (changed this round, confirmed on the next one). `CheckRow.outcome` is set on every row and says what happens if the rule fails in the machine's current state (null = nothing). The `action` of `GET .../checks` is `ok`, `hide` or `stop`. **Instance `phase`:** `pulling` (downloading the image; `progress` 0-99), `preparing` (GPU and overclocking checks), `starting` (container starting), `running` (billed), `stopping` (ended, waiting for the machine to clean up), `released` (cleaned up). Only `running` can be used; stopping is allowed in every phase before `stopping`. **`end_reason`:** `renter` (you stopped it; cancelled during delivery has `fail_code: renter_cancel`, not charged), `balance_exhausted` (your balance could not pay the next minute), `offline_rented` (the machine was offline for 600 s), `verdict` (a hardware or driver problem marked `stop` above), `admin` (stopped by the platform), `delivery_failed` (see `fail_code`). **`fail_code`:** set by the platform: `pull_timeout`, `prepare_timeout`, `start_timeout`, `oc_failed`, `gpu_busy` (the host was using the machine; it is unlisted), `agent_outdated`, `renter_cancel`; reported by the machine: `pull_failed`, `disk_insufficient`, `image_too_large`, `image_no_shell`, `start_failed`, `gpu_mismatch`, `network_isolation_failed`, `rent_job_failed`. Other lowercase codes may appear. **Command `state` / `note`** (timeline): `pending` (not started yet), `running` (started, no result yet), `ok`, `error`. `note` on finished commands: `rebooted` (reboot done), `powered_off`, `expired` (never started within 600 s), `timeout` (started, no result in time), `interrupted` (the machine rebooted while it ran), `not_delivered` (never sent, safe to send again), `rebooted_no_gpu` / `rebooted_gpu_unreadable` (driver install done but the machine has no NVIDIA GPU / no GPU can be read, so the version was not checked); null otherwise, also for an `error` reported by the machine (the reason is in `latest_title`). **Compute task `state`** (`states[].state`): `running` (the program runs), `preparing` (downloading or starting), `retrying` (the program exited or preparing failed; it is restarted with back-off up to 60 s), `gpu_missing` (its GPUs are gone), `paused`, `held` (held on the machine itself, for example while GPUs initialize after boot or a driver is installed; see `reason`), `overheat` (stopped by fan control), `yielded` (the machine is rented, host tasks give way), `unsupported` (the machine lacks a tool, `missing`), `stopped` (removed). **A task runs when `state` is `running` and its `revision` equals the task's `revision`.** `started_at` is when the current run started; `exits_1h` counts exits in the last hour. ## Retries and batch operations | Kind | Endpoints | On timeout or 5xx | |---|---|---| | Safe to repeat (same body, same result) | Prices, applying price templates, changing templates and tags (`PUT` / `PATCH`), listing, precheck, tags, `PUT .../tasks`, `tasks/apply` (`replace`, `clear`; `add` skips tasks already there), task pause / resume, `oc/manual-only`, rename, wallets / variables `PUT`, `PUT .../startup`, stop an instance, rent with the same `Idempotency-Key` | Send it again | | Repeat with care | `PUT .../oc`, `oc-template`, `oc/reapply`, `PUT .../autofan`, `autofan-template` | Each call raises `revision` and makes the machine apply the values again (same values, no harm). Read `oc.revision` first | | Do not repeat blindly | `commands/reboot`, `commands/upgrade`, `commands/driver_install`, `commands/task_restart`, `commands/task_logs`, `tasks/restart`, `tasks/redownload`, `startup/restart`, `rebuild`, renter task `restart` / `reinstall`, password changes, creating templates, wallets / variables or tags | Read the result first: commands in the timeline (your `cmd_id`, or the newest item of that `type` with `issued_by_mine`), the rest in the matching list. 503 `command_push_failed` is the exception: nothing was sent, send again | - 429 `rate_limited`: wait `Retry-After` seconds (the start of the next minute for the per-minute budget, 1 s when the shared pool is busy), plus a random 0-1000 ms so parallel workers do not retry together. - 503 `device_index_rebuilding` or `request_timeout` on a read: back off 2, 4, 8, 16 s and give up after 5 tries. 503 `request_timeout` on a write: read the state first (see above). - Rent with a new `Idempotency-Key` for each order and reuse it when you retry that order: the key is kept for good, the same key with the same body returns the same order, a different body 422 `idempotency_mismatch`. - Multi-machine writes with an API key: split `machine_ids` by `group_id` (from `GET /api/v1/host/machines`) and send one request per group; otherwise the request fails with 400 `cross_group`. Per request at most: 500 machines for `price`, `price-template`, `listing`, `listing/precheck`, `tasks/apply`, `tasks/restart`, `tasks/redownload`, `tasks/pause`, `tasks/resume`, `oc-template`, `oc/reapply`, `autofan-template`; 1000 for `tags`; 100 (after removing duplicates) for `commands/reboot` and `commands/upgrade`; exactly 1 for `commands/task_restart`, `commands/task_logs` and `commands/driver_install`. Results are per machine: always check `results[]` (or `rejected[]`), a 200 does not mean every machine was done. - Only one big command (reboot, shutdown, Agent upgrade, network change, driver install) can be open per machine; another is rejected with `command_pending` until the first one ends. Compute-task commands are not blocked by it and do not block it. ## Business rules - **Prices and commission.** The price a host sets (`price_per_gpu_hr` / `price_per_cpu_hr`) is what the host earns. The market and renters see that price plus the platform commission: unit price × (1 + commission), rounded up to 3 decimal places, times the GPU (or CPU socket) count. The commission rate is set by the platform. Both prices are fixed when an order is placed; later price changes apply to new rentals only. - **Billing.** Rent is charged every minute from when the image is ready (`billing_from`) until you stop, only for time the machine is online, rounded up to the cent on the running total. Ordering needs at least one hour of rent in your balance. There is no grace period: when your balance cannot pay the next minute, all your instances are stopped with `end_reason: balance_exhausted` (you are notified when less than 120 and 30 minutes are left). - **No rental duration.** An order has no duration; an instance runs until you stop it (`POST .../stop`), your balance runs out, or the platform stops it. Stop it from your code when you are done. - **Deposits.** The API cannot create deposit addresses or move money; deposit in the console. Use `GET /api/v1/account/deposits/pending` to see an incoming deposit and `GET /api/v1/account/deposits` / `GET /api/v1/renter/account` to see it credited. Withdrawals and balance transfers are not available to API keys. - **Agent version.** The current stable Agent version is the plain text at `https://down.suanzu.ai/VERSION` (public, no key), always `MAJOR.MINOR.PATCH`. `commands/upgrade` installs exactly that version, whatever the machine runs now: a newer release or beta is replaced by it (`1.5.8-beta.2` becomes `1.5.7`), and a machine already on it gets it installed again. So send it only to the machines you want on the stable version. Compare as semantic versions: `MAJOR`, `MINOR` and `PATCH` one by one as numbers; a `-beta.N` version is below the same version without it and above the release before it (`1.5.7` < `1.5.8-beta.2` < `1.5.8`). `agent_version` null = not reported yet. - **Host service fees.** Your host account is overdue when `earn_balance` is below 0. Service-fee credit and gift credit pay service fees first, and new deposits, transfers received and gifts are applied to the debt automatically. While overdue, `GET /api/v1/host/account` has `overdue_since` and `freeze_at` (= `overdue_since` + 3 days). If it is still overdue then, the account is restricted (`restricted: true`): compute task, overclocking and wallet / variable changes fail with `account_overdue_restricted` until you top up. - **Rented machines.** While a machine has a rental (`status: rented`, delivery and stopping included): `commands/reboot`, `commands/upgrade`, `commands/driver_install`, `commands/task_restart`, `commands/task_logs`, `tasks/restart`, `tasks/redownload`, opening remote access, `oc/reapply` and resuming host tasks (one task or `tasks/resume`) are rejected with `rented`; overclocking, overclocking templates, auto-fan and `oc/manual-only` are saved and applied after the rental ends (`deferred: rented`); host compute tasks can be changed but give way to the renter (`state: yielded`); prices can be changed (the running rental keeps its price); unlisting is allowed and does not stop the rental. ## Compute task templates A template is `custom` (your own start command) or `hive` (a HiveOS custom miner package). Host tasks run on the machine; renter tasks run inside the instance. - **Custom tasks.** `custom.start_command` (required, at most 16 KiB) runs with `bash -c`. With `custom.package_url` the file is downloaded first: `.tar.gz`, `.tgz`, `.tar.xz` and `.tar` are unpacked into the working directory when `extract` is true (the default); other files (`.zip` included) are saved there unchanged and made executable. When the program exits it is started again after 3 to 60 s; the wait resets once it has run for 300 s. - **Variables** (`vars`, custom tasks only). Each item becomes an environment variable of the program; the value is passed as it is (no shell expansion). At most 64. `key` matches `^[A-Za-z_][A-Za-z0-9_]*$`, does not start with `SUANZU_` and is none of `CUDA_DEVICE_ORDER`, `CUDA_VISIBLE_DEVICES`, `NVIDIA_VISIBLE_DEVICES`, `BASH_ENV`, `ENV`, `PATH`. `value` is required (it may be empty), at most 4 KiB. A HiveOS template with `vars` fails with 400 `hive_vars_unsupported`. - **Values from your wallets / variables.** Set `ref` to the `id` of one of your wallets / variables and send `value: ""`: the value is always replaced with the current value of that wallet / variable, and changing that value restarts the tasks that use it. An `id` that is not yours fails with 400 `wallet_var_unavailable`. For HiveOS, `wallet_ref` does the same for `hive.wallet` (send `wallet: ""`). - **Set for the program.** `SUANZU_TASK_ID`, `SUANZU_TASK_DIR`, `SUANZU_WORKER_NAME`, `SUANZU_GPU_BUSIDS` (the task's GPU bus IDs, comma-separated) and `CUDA_DEVICE_ORDER=PCI_BUS_ID`. When the task uses only some GPUs, `CUDA_VISIBLE_DEVICES` and `NVIDIA_VISIBLE_DEVICES` hold their UUIDs. CPU tasks (`gpus: []`) get `SUANZU_TASK_CPU=1` and no GPU. - **HiveOS fields.** `install_url` must be an http(s) link to a `.tar.gz` / `.tgz` package with `/h-manifest.conf` and `/h-run.sh`. Leave `miner` empty to take it from the file name: drop the extension, then keep what comes before the last `-` (`pearlfortune-1.2.3.tar.gz` gives `pearlfortune`). `coin` and `algo` reach the package as `DIGITAL_CASH` and `CUSTOM_ALGO`. In `template`, `url`, `pass` and `user_config` the macros `%WAL%` (the wallet), `%WORKER_NAME%`, `%URL%`, `%URL_HOST%` and `%URL_PORT%` (from the first address in `url`) are replaced; any other `%...%` is left as it is. `%WAL%` with an empty wallet and no `wallet_ref` fails with 400 `hive_wallet_required`. - **Follow the latest version.** When the download link (`hive.install_url` / `custom.package_url`) is a GitHub release file with a version tag, set `follow` to `latest` (stable releases) or `latest_beta` (pre-releases too). When a newer release comes out, SuanZu switches the template's download link to it (with download acceleration on, once the cache is ready, at the latest 1 hour after the release) and sends the `tpl.auto_updated` notification. Templates return the version in use as `current_tag`. - **Is it running?** A task runs when its `states[]` item has `state: running` and the same `revision` as the task. Only HiveOS tasks report stats (`TaskStats`, from the package's `h-stats.sh`). x-zh: description: |- 从你自己的代码中租用 GPU 和 CPU 设备,并管理你出租的设备。 ## 认证 在控制台(控制台 → API 密钥)中创建 API 密钥,并在每个请求中携带:`Authorization: Bearer sz_live_...`。只接受此请求头;查询字符串中的密钥会被忽略。市场接口不带密钥也可使用。 每个密钥有一个或多个权限范围: | 权限范围 | 允许的操作 | |---|---| | `renter:read` | 读取你的实例、余额、流水、租金余额充值记录、计算任务模板、实例计算任务、标签和钱包/变量。 | | `renter:write` | `renter:read` + 租用、停止、修改启动命令、重启容器、获取连接信息,管理计算任务模板、实例计算任务、标签和钱包/变量。 | | `host:read` | 读取你的设备、GPU、消息、命令结果与进度、可安装的驱动版本、标签、模板(及使用它们的设备)、钱包/变量、历史曲线、故障历史、分组、收益、账户、账单(含按天明细)和服务费充值记录。 | | `host:write` | `host:read` + 设置价格(直接设置或套用模板)、上架 / 下架、重命名、打标签、设置计算任务、超频和自动风扇、管理模板(价格、计算任务、超频、自动风扇)、标签和钱包/变量、暂停 / 恢复 / 重启计算任务、拉取任务日志。 | | `host:exec` | `host: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..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` 响应头(秒)。 | 限流类 | 每个密钥每分钟请求数 | 适用接口 | |---|---|---| | `read` | 120 | 市场、出租方设备列表 / 详情 / 任务、GPU、标签、预置镜像 | | `read_pg` | 30 | 余额、流水、收益、账单、实例列表、上架检查、分组、预检查、命令时间线与进度、驱动版本、消息、模板、钱包/变量、历史曲线、故障历史 | | `write` | 30 | 写操作:停止、价格、上架、名称、标签、模板、任务设置与控制、任务日志、超频、自动风扇、钱包/变量、重启、升级 Agent、安装驱动、远程访问开启 / 关闭 / 换密码 | | `order` | 10 | 租用设备 | | `remote` | 20 | 获取带密码的连接信息 | `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` 为 `released` | 15 秒 | 至少两轮设备循环(约 30 秒)。没有时限:设备离线时一直保持 `stopping`,直到它重新上线 | 不论处于哪个阶段,停止时即停止计费。`stopping` 只表示设备尚未确认清理完成 | | 启动命令 | `GET /api/v1/renter/leases` | `startup.rev` 等于返回的 `startup_rev`,且 `startup.state` 不再是 `pending` | 10 秒 | 下一次心跳 | `startup.state: failed` 或带 `exit_code` 的 `exited`;读取 `GET .../container-log` | | 命令(`reboot`、`upgrade`、`task_restart`、`task_logs`) | `GET /api/v1/host/machines/{machine_id}/timeline` | `cmd_id` 对应的那一项 `state` 为 `ok` 或 `error` | 10-15 秒 | 随下一次心跳领取(约 15-20 秒)。离线设备须在 600 秒内(`expire_at`)上线并开始执行 | `state: error` 并带 `note`(见下方词典);原因在 `latest_title`,日志在 `GET .../messages`(`payload_gz`) | | 重启 | 同命令 | `state: ok`、`note: rebooted` | 15 秒 | 设备重新上线且 `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}/progress` | `state: 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.revision` | 15 秒 | 保存后一到两次心跳。`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` 等于任务的 `revision` | 15 秒 | 下一次心跳,加上程序包下载时间 | `state` 为 `retrying`、`gpu_missing`、`unsupported`、`held`;`exits_1h` ≥ 3 表示反复崩溃。查看任务日志(租用方:`GET .../tasks/{binding_id}/log`)和 `latest` | | 任务统计(算力) | 同上 | `stats_at` 有值且 `stats[]` 中有你的 `binding_id` | 30 秒 | 通常在任务进入 `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` 与此相同。 | 代码 | 含义 | 未上架 | 上架中 | 租用中 | |---|---|---|---|---| | `offline` | 120 秒无心跳 | reject | hide | notice | | `offline_rented` | 租用中设备离线满 600 秒(计费截止到最后一次心跳) | - | - | stop | | `price_unset` | 已上架但没有对应单位的价格 | reject | - | - | | `group_invalid` | 所属分组已删除 | reject | hide | notice | | `gpu_dropped` | 有 GPU 未被驱动识别 | reject | hide | stop | | `gpu_driver` | 驱动读不到某块 GPU | reject | hide | stop | | `gpu_ecc_uncorrected` | 存在未纠正的 ECC 错误 | reject | hide | stop | | `gpu_probe_failed` | GPU 数据读取失败(连续 2 轮) | reject | hide | stop | | `gpu_count_low` | GPU 少于上架时(或少于 `expected_gpu_count`) | reject | hide | stop | | `gpu_mixed` | GPU 型号不止一种 | reject | hide | notice | | `gpu_changed` | 上架后 GPU 型号或显存变了 | - | hide | stop | | `driver_changed` | 上架后驱动或 CUDA 版本变了 | - | hide | stop | | `cpu_changed` | CPU 型号或颗数变了 | - | hide | stop | | `ram_low` | 内存少于上架时 | - | hide | stop | | `ram_more` | 内存多于上架时 | - | refresh | - | | `disk_changed` | 磁盘容量变化超过 1%,或磁盘类型变了 | - | hide | stop | | `os_changed` | 操作系统或内核变了 | - | refresh | stop | | `pcie_degraded` | 某块 GPU 的 PCIe 代数或宽度低于上架时 | - | refresh | stop | | `pcie_changed` | PCIe 链路变了,但没有变低 | - | refresh | notice | | `pcie_unstable` | 24 小时内 PCIe 链路变化 3 次及以上 | reject | hide | notice | | `docker_down` | Docker 未安装或未运行 | reject | hide | stop | | `nvidia_runtime_missing` | 有 NVIDIA GPU 但没有 NVIDIA 容器运行时 | reject | hide | stop | | `runc_outdated` | runc 低于 1.2.8 或读不到版本 | reject | hide | stop | | `nvidia_toolkit_outdated` | 有 NVIDIA GPU,但 NVIDIA 容器工具包低于 1.19.1 或读不到版本 | reject | hide | notice | | `disk_low` | 系统盘可用空间不足 5 GiB | reject | hide | notice | | `collect_invalid` | 读不到 CPU、内存或磁盘信息 | reject | hide | notice | | `rent_env_unsupported` | 不是物理机或虚拟机(容器、WSL) | reject | hide | notice | | `agent_outdated` | Agent 低于 1.2.0 | reject | hide | notice | | `tools_missing` | Agent 工具包仍在下载 | reject | hide | notice | | `identity_conflict` | 两台设备用同一身份上报 | reject | hide | notice | | `owner_inactive` | 所有者账户已停止出租 | reject | hide | notice | | `data_invalid` | 设备数据损坏 | reject | hide | notice | | `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) 链接,指向包含 `/h-manifest.conf` 和 `/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`)。 servers: - url: https://suanzu.ai security: - apiKey: [] tags: - name: Market description: Machines that are listed for rent. Public; no key needed. x-zh: name: "市场" description: "已上架可供租用的设备。公开接口,无需密钥。" - name: Renter description: Rent machines and manage your instances, balance and deposits. Needs `renter:read` or `renter:write`. x-zh: name: "租用方" description: "租用设备,并管理你的实例、余额和充值。需要 `renter:read` 或 `renter:write`。" - name: Host description: Manage the machines you rent out. Needs `host:read`, `host:write` or `host:exec`. x-zh: name: "出租方" description: "管理你出租的设备。需要 `host:read`、`host:write` 或 `host:exec`。" x-flows: - summary: Rent a machine, connect to it, stop it x-zh: summary: "租用设备、连接、停止" steps: - operationId: getMarketFacets description: Optional. Get the GPU and CPU model names you can filter by. x-zh: description: "可选。获取可用于筛选的 GPU 和 CPU 型号名称。" - operationId: listMarketMachines description: Find a machine. Keep its `machine_id` and `device_no`. x-zh: description: "查找设备。记下其 `machine_id` 和 `device_no`。" - operationId: listRenterImages description: Pick a preset `image_id`, or use your own public image. x-zh: description: "选择一个预置 `image_id`,或使用你自己的公开镜像。" - operationId: createLease description: Rent it with a new `Idempotency-Key`. Your balance must cover at least one hour of rent. Keep the returned `id`. x-zh: description: "使用新的 `Idempotency-Key` 租用。你的余额必须至少足够支付一小时租金。记下返回的 `id`。" - operationId: listLeases description: Poll until the instance's `phase` is `running`. x-zh: description: "轮询,直到实例的 `phase` 变为 `running`。" - operationId: getLeaseAccess description: Get the SSH command and password. Treat them as a secret. x-zh: description: "获取 SSH 命令和密码。请将其作为机密妥善保管。" - operationId: stopLease description: Stop the instance when you are done. Rent is settled up to now. x-zh: description: "使用完毕后停止实例。租金结算至当前时间。" - summary: Price your machines and list them on the market x-zh: summary: "为设备定价并上架到市场" steps: - operationId: listHostMachines description: Find the `machine_id` of your machines (use `group` to stay in one device group). x-zh: description: "查找你的设备的 `machine_id`(使用 `group` 限定在同一分组内)。" - operationId: setMachinePrices description: Set `price_per_gpu_hr` (GPU machines) or `price_per_cpu_hr` (CPU-only machines). x-zh: description: "设置 `price_per_gpu_hr`(GPU 设备)或 `price_per_cpu_hr`(纯 CPU 设备)。" - operationId: precheckMachineListing description: See which machines can be listed; `reasons` lists the problems. x-zh: description: "查看哪些设备可以上架;`reasons` 列出存在的问题。" - operationId: getHostMachineChecks description: Optional. Per-rule details for a machine that failed the check. x-zh: description: "可选。查看未通过检查的设备的逐条规则详情。" - operationId: setMachineListing description: 'Send `listed: true` to put the machines on the market.' x-zh: description: "发送 `listed: true` 将设备上架到市场。" - summary: Change the startup command, or run it again x-zh: summary: "修改启动命令,或重新执行" steps: - operationId: setStartupCommand description: Save the new command. Saving the same command again does nothing, so you can safely retry this call. x-zh: description: "保存新命令。再次保存相同的命令不会有任何操作,因此可以放心重试。" - operationId: restartStartupCommand description: To run the same command again, restart the container instead. Each call restarts it once, so do not retry automatically. x-zh: description: "要重新执行同一条命令,请改为重启容器。每次调用都会重启一次,因此不要自动重试。" - operationId: listLeases description: Poll until `startup.rev` equals the returned `startup_rev` and `startup.state` is no longer `pending`. x-zh: description: "轮询,直到 `startup.rev` 等于返回的 `startup_rev`,且 `startup.state` 不再是 `pending`。" - summary: Set overclocking on one machine x-zh: summary: "设置单台设备的超频" steps: - operationId: getHostMachine description: Read `gpus[].busid` and the current `oc` (`revision`, `cards`). x-zh: description: "读取 `gpus[].busid` 和当前的 `oc`(`revision`、`cards`)。" - operationId: setMachineOC description: 'Send all 6 values for each GPU to change. On 409 `oc_task_managed`, send again with `manual_only: true`.' x-zh: description: "为每块要修改的 GPU 发送全部 6 项值。返回 409 `oc_task_managed` 时,带上 `manual_only: true` 重新发送。" - operationId: getHostMachine description: Poll until `oc.applied_revision` equals the returned `revision`; check `oc.rejected` and `oc.result` for failures. x-zh: description: "轮询,直到 `oc.applied_revision` 等于返回的 `revision`;失败原因见 `oc.rejected` 和 `oc.result`。" - summary: Upgrade the Agent and track it x-zh: summary: "升级 Agent 并跟踪进度" steps: - operationId: listHostMachines description: Find the machines whose `agent_version` is lower than the stable version at `https://down.suanzu.ai/VERSION` (see Agent version under Business rules; the command installs the stable version whatever the machine runs, so a newer release or beta would be moved back to it). Split the `machine_id` values by `group_id`, at most 100 per request. x-zh: description: "查找 `agent_version` 低于 `https://down.suanzu.ai/VERSION` 正式版的设备(见业务规则「Agent 版本」;命令不看当前版本,比正式版新的正式版或 beta 也会被装回正式版)。按 `group_id` 拆分 `machine_id`,每个请求最多 100 台。" - operationId: upgradeMachinesAgent description: Send one request per group. Keep `issued[].cmd_id`; `rejected[].reason` lists the machines that got no command (for example `rented`, `command_pending`). x-zh: description: "每个分组发一个请求。记下 `issued[].cmd_id`;`rejected[].reason` 列出没有下发命令的设备(例如 `rented`、`command_pending`)。" - operationId: getHostMachineTimeline description: Poll every 15 s until the item with your `cmd_id` has `state` `ok` or `error`. With `error`, the reason is in `latest_title` and `note` (`expired`, `timeout`, `interrupted`). x-zh: description: "每 15 秒轮询一次,直到带你的 `cmd_id` 的项 `state` 为 `ok` 或 `error`。为 `error` 时,原因见 `latest_title` 和 `note`(`expired`、`timeout`、`interrupted`)。" - operationId: listHostMachineMessages description: Optional. For a failed upgrade, read the install log in `payload_gz`. x-zh: description: "可选。升级失败时,从 `payload_gz` 读取安装日志。" - operationId: listHostMachines description: After `ok`, `agent_version` shows the new version from the next heartbeat on. x-zh: description: "得到 `ok` 后,从下一次心跳起 `agent_version` 显示新版本。" - summary: Reboot machines and confirm they are back x-zh: summary: "重启设备并确认恢复" steps: - operationId: listHostMachines description: Find the machines, for example `reason=gpu_dropped`. Split them by `group_id`, at most 100 per request. x-zh: description: "查找设备,例如 `reason=gpu_dropped`。按 `group_id` 拆分,每个请求最多 100 台。" - operationId: rebootMachines description: Keep `issued[].cmd_id`. Rented machines are rejected with `rented` (unlisting with `POST /api/v1/host/machines/listing` does not end a rental). x-zh: description: "记下 `issued[].cmd_id`。被租用的设备会以 `rented` 被拒(用 `POST /api/v1/host/machines/listing` 下架不会结束租用)。" - operationId: getHostMachineTimeline description: 'Poll every 15 s until the item with your `cmd_id` has `state: ok` and `note: rebooted` (the machine is back online and has booted again). `note: timeout` = not back within 600 s.' x-zh: description: "每 15 秒轮询一次,直到带你的 `cmd_id` 的项为 `state: ok` 且 `note: rebooted`(设备已重新开机并上线)。`note: timeout` = 600 秒内没有恢复。" - operationId: getHostMachine description: Check that the problem is gone, for example `gpus[].dropped` and `status_reasons`. x-zh: description: "确认问题已消失,例如查看 `gpus[].dropped` 和 `status_reasons`。" - summary: Watch for offline machines x-zh: summary: "监控离线设备" steps: - operationId: getHostMachineSummary description: Every 5 minutes, read `offline` in `all` and in each of `groups`. Stop here when it is 0. x-zh: description: "每 5 分钟读取一次 `all` 和 `groups` 中各分组的 `offline`。为 0 时到此为止。" - operationId: listHostMachines description: 'List them with `connectivity=offline` and `per_page=1000`, following `page` up to `total_pages`. `last_heartbeat_at` says since when; a machine counts as offline 120 s after its last heartbeat. Rented machines that stay offline for 600 s lose their rental.' x-zh: description: "用 `connectivity=offline` 和 `per_page=1000` 列出,按 `page` 翻到 `total_pages`。`last_heartbeat_at` 表示从何时起离线;最后一次心跳后 120 秒判为离线。被租用的设备离线满 600 秒会停租。" - operationId: getHostMachineTimeline description: Optional. Read the newest messages of a machine before it went offline. x-zh: description: "可选。读取设备离线前的最新消息。" - summary: List machines across several groups x-zh: summary: "跨多个分组列出设备" steps: - operationId: listDeviceGroups description: 'Get the `id` of every group the key can use (yours and those shared with you, `shared: true`).' x-zh: description: "获取密钥可用的每个分组的 `id`(你自己的和共享给你的,`shared: true`)。" - operationId: listHostMachines description: Without `group` you get every machine the key can see in one list. With `group`, one request per group; follow `page` up to `total_pages` (`per_page` at most 1000). x-zh: description: "不传 `group` 时,一个列表返回密钥可见的全部设备。传 `group` 时每个分组一个请求;按 `page` 翻到 `total_pages`(`per_page` 最大 1000)。" - operationId: getHostMachineSummary description: Optional. Totals per group in one call. x-zh: description: "可选。一次调用拿到各分组的汇总。" - summary: Run a renter task that uses a saved wallet x-zh: summary: "运行使用已保存钱包的租用方任务" steps: - operationId: createRenterWalletVar description: Save the wallet address. Keep `wallet_var.id`. x-zh: description: "保存钱包地址。记下 `wallet_var.id`。" - operationId: createRenterTaskTemplate description: 'Custom task: add a `vars` item with `ref` set to that `id` and `value: ""`. HiveOS task: set `wallet_ref` to that `id` and `hive.wallet` to `""`. Keep `template.id`.' x-zh: description: "自定义任务:添加一个 `vars` 项,`ref` 设为该 `id`,`value: \"\"`。HiveOS 任务:`wallet_ref` 设为该 `id`,`hive.wallet` 设为 `\"\"`。记下 `template.id`。" - operationId: setLeaseTasks description: Put the template on a `running` instance. x-zh: description: "把模板设到一个 `running` 状态的实例上。" - operationId: getLeaseTasks description: 'Poll every 15 s until `states[]` has your `binding_id` with `state: running` and the same `revision`. HiveOS tasks then report `stats` (hash rate in `params.khs`).' x-zh: description: "每 15 秒轮询一次,直到 `states[]` 中你的 `binding_id` 为 `state: running` 且 `revision` 相同。之后 HiveOS 任务会上报 `stats`(算力见 `params.khs`)。" - operationId: updateRenterWalletVar description: Optional. Changing the value restarts every task that uses it. x-zh: description: "可选。修改值会重启所有用到它的任务。" - summary: Fetch the log of a compute task x-zh: summary: "拉取计算任务日志" steps: - operationId: listHostMachineTasks description: Find the task's `binding_id`. x-zh: description: "找到任务的 `binding_id`。" - operationId: fetchMachineTaskLogs description: Send the command for that one machine and task. Keep `issued[0].cmd_id`; a `rejected[].reason` (for example `rented`, `task_not_found`) means no command was sent. x-zh: description: "对这一台设备和这个任务发送命令。记下 `issued[0].cmd_id`;出现 `rejected[].reason`(例如 `rented`、`task_not_found`)表示没有下发命令。" - operationId: listHostCommandMessages description: Poll every 10 s until there is an `ok` or `error` message. The log is the `payload_gz` of the `ok` message (gzip + base64, last 500 lines). x-zh: description: "每 10 秒轮询一次,直到出现 `ok` 或 `error` 消息。日志是 `ok` 消息的 `payload_gz`(gzip + base64,最后 500 行)。" - summary: Install or change the NVIDIA driver on one machine x-zh: summary: "为一台设备安装或更换 NVIDIA 驱动" steps: - operationId: setMachineListing description: 'If the machine is listed, send `listed: false` first (a rented machine cannot install a driver).' x-zh: description: "设备已上架时,先发送 `listed: false` 下架(被租用的设备不能安装驱动)。" - operationId: getMachineDriverOptions description: 'Pick a `version` from `options`; a 409 `code` says why the machine cannot install now. Use `cuda: false` when `cuda_block` is not null.' x-zh: description: "从 `options` 里选一个 `version`;返回 409 时 `code` 说明设备现在为什么不能安装。`cuda_block` 不为 null 时用 `cuda: false`。" - operationId: installMachineDriver description: Send it for that one machine. Keep `issued[0].cmd_id`; a `rejected[].reason` means no command was sent. Do not retry blindly. x-zh: description: "对这一台设备发送。记下 `issued[0].cmd_id`;出现 `rejected[].reason` 表示没有下发命令。不要盲目重试。" - operationId: getHostCommandProgress description: Optional. Every 5 s while it runs, read the stage, download percent and the new log with `offset` = `next_offset`. x-zh: description: "可选。执行中每 5 秒读一次阶段、下载百分比和新增日志(`offset` = `next_offset`)。" - operationId: getHostMachineTimeline description: 'Poll every 15 s until your `cmd_id` has `state` `ok` (`note: rebooted`, the machine is back with the new driver) or `error` (the code is in brackets in `latest_title`).' x-zh: description: "每 15 秒轮询一次,直到你的 `cmd_id` 的 `state` 为 `ok`(`note: rebooted`,设备已带着新驱动回来)或 `error`(原因码在 `latest_title` 的方括号里)。" paths: /api/v1/market/machines: get: tags: [Market] operationId: listMarketMachines summary: List machines available for rent description: | Returns one page of machines that can be rented right now. To get the next page, pass the `next` value of this page as `cursor`, with the same filters and `sort`. All filters are optional and combine with AND; a repeated parameter (`gpu`, `cpu`) matches any of its values. Unknown query parameters are rejected with 400. Example: 8-GPU CMP 50HX machines at most 0.100 USDT per GPU-hour, cheapest first: `GET /api/v1/market/machines?gpu=CMP%2050HX&count=8&priceMax=0.100&sort=price_asc` x-zh: summary: "列出可租用的设备" description: |- 返回一页当前可租用的设备。要获取下一页,将本页的 `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` security: [{}, { apiKey: [] }] x-rate-limit-class: read parameters: - name: sort in: query description: Sort order. Ties are broken by machine ID. x-zh: description: "排序方式。排序值相同时按设备 ID 排序。" schema: type: string enum: [price_asc, price_desc, total_asc, total_desc, cores_desc] default: price_asc example: price_asc - name: pageSize in: query description: Machines per page. Values above 200 are treated as 200. x-zh: description: "每页设备数。大于 200 的值按 200 处理。" schema: { type: integer, minimum: 0, maximum: 200, default: 50 } - name: cursor in: query description: The `next` value from the previous page. Omit for the first page. Only valid with the same `sort`. x-zh: description: "上一页的 `next` 值。获取第一页时省略。仅在 `sort` 相同时有效。" schema: { type: string } - name: gpu in: query description: GPU model, exactly as returned in `gpu_models[].name` of `GET /api/v1/market/facets` (for example `CMP 50HX`, URL-encoded). Repeat to match any of several models. x-zh: description: "GPU 型号,须与 `GET /api/v1/market/facets` 返回的 `gpu_models[].name` 完全一致(例如 `CMP 50HX`,需 URL 编码)。重复传入可匹配多个型号中的任一个。" style: form explode: true schema: { type: array, items: { type: string } } example: [CMP 50HX] - name: cpu in: query description: CPU model, exactly as returned in `cpu_models[].name` of `GET /api/v1/market/facets`. Repeat to match any of several models. x-zh: description: "CPU 型号,须与 `GET /api/v1/market/facets` 返回的 `cpu_models[].name` 完全一致。重复传入可匹配多个型号中的任一个。" style: form explode: true schema: { type: array, items: { type: string } } - name: cpuOnly in: query description: Only machines without GPUs. x-zh: description: "仅限无 GPU 的设备。" schema: { type: string, enum: ["1", "true", "0", "false"] } - name: count in: query description: Exact number of GPUs. 0 = any. x-zh: description: "GPU 数量,精确匹配。0 = 不限。" schema: { type: integer, minimum: 0, example: 8 } - name: vramMin in: query description: Minimum memory per GPU, in GB. x-zh: description: "每块 GPU 的最小显存,单位 GB。" schema: { type: integer, minimum: 0 } - name: cudaMin in: query description: Minimum CUDA version the driver supports, for example `12.8`. x-zh: description: "驱动支持的最低 CUDA 版本,例如 `12.8`。" schema: { type: number, minimum: 0 } - name: priceMax in: query description: Maximum unit price in USDT per hour (per GPU on GPU machines, per CPU socket on CPU-only machines). Decimal string, up to 3 decimal places. 0 = any. x-zh: description: "单价上限,单位为 USDT/小时(GPU 设备按每块 GPU 计,纯 CPU 设备按每颗 CPU 计)。十进制字符串,最多 3 位小数。0 = 不限。" schema: { type: string, pattern: '^\d{1,7}(\.\d{1,3})?$', example: "0.100" } - name: minSockets in: query description: Minimum number of CPU sockets. x-zh: description: "最少 CPU 颗数。" schema: { type: integer, minimum: 0 } - name: minCores in: query description: Minimum total CPU cores. x-zh: description: "最少 CPU 总核数。" schema: { type: integer, minimum: 0 } - name: ramMin in: query description: Minimum memory, in GB. x-zh: description: "最小内存,单位 GB。" schema: { type: integer, minimum: 0 } - name: storageMin in: query description: Minimum total disk size, in GB. x-zh: description: "最小磁盘总容量,单位 GB。" schema: { type: integer, minimum: 0 } - name: storageType in: query description: Disk type. (`USB` can appear in results but cannot be used as a filter.) x-zh: description: "磁盘类型。(`USB` 可能出现在结果中,但不能用作筛选条件。)" schema: { type: string, enum: [NVMe, SSD, HDD] } responses: "200": description: One page of machines. x-zh: description: "一页设备。" content: application/json: schema: { $ref: "#/components/schemas/MarketPage" } example: items: - machine_id: 314d1670-872d-4d8d-be94-a4ceea1c0c58 device_no: SZ-000014 connectivity: online gpu_model: CMP 50HX gpu_count: 8 cpu_model: Intel Xeon E5-2686 v4 cpu_sockets: 1 cpu_cores_total: 18 cpu_threads: 36 ram_gb: 12 ram_type: DDR4 storage_total_gb: 110 storage_avail_gb: 67 storage_type: SSD price_per_gpu_hr: "0.053" price_per_cpu_hr: null total_price_hr: "0.424" rent_count: 0 cuda_version: "13.3" driver_version: 610.43.03 os: Ubuntu 22.04.5 LTS kernel: "6.1" nvidia_runtime: true gpus: - model: CMP 50HX count: 8 vram_gb: 10 vram_type: "" power_default_w: 225 power_max_w: 225 compute_cap: "7.5" pcie_gen: 1 pcie_width: 1 rent_power_limit_w: null total: 7 page_size: 1 next: djF8cHJpY2VfYXNjfDAuMDUzfDMx... "400": { $ref: "#/components/responses/BadRequest" } "429": { $ref: "#/components/responses/RateLimited" } "503": { $ref: "#/components/responses/Unavailable" } /api/v1/market/machines/{machine_id}: get: tags: [Market] operationId: getMarketMachine summary: Get one machine available for rent description: | Returns the same fields as one item of the market list. Machines that are not listed, not rentable right now, or do not exist all return 404 `machine_not_found`. x-zh: summary: "获取单台可租用设备" description: "返回的字段与市场列表中的单项相同。未上架、当前不可租用或不存在的设备,均返回 404 `machine_not_found`。" security: [{}, { apiKey: [] }] x-rate-limit-class: read parameters: - name: machine_id in: path required: true description: '`machine_id` from the market list (a UUID). The device number (`SZ-000014`) is not accepted.' x-zh: description: "市场列表中的 `machine_id`(UUID)。不接受设备编号(`SZ-000014`)。" schema: { type: string, example: 314d1670-872d-4d8d-be94-a4ceea1c0c58 } responses: "200": description: The machine. x-zh: description: "该设备。" content: application/json: schema: { $ref: "#/components/schemas/MarketMachine" } example: machine_id: 3eed9a92-c838-4790-bc9f-6111b642984f device_no: SZ-000016 connectivity: online gpu_model: "" gpu_count: 0 cpu_model: AMD EPYC 7702 64-Core cpu_sockets: 2 cpu_cores_total: 128 cpu_threads: 256 ram_gb: 128 ram_type: DDR4 storage_total_gb: 1876 storage_avail_gb: 1746 storage_type: NVMe price_per_gpu_hr: null price_per_cpu_hr: "1.050" total_price_hr: "2.100" rent_count: 0 cuda_version: "" driver_version: "" os: Ubuntu 24.04.2 LTS kernel: "7.0" nvidia_runtime: false gpus: [] "404": description: '`machine_not_found`.' x-zh: description: "`machine_not_found`。" x-codes: [machine_not_found] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } "503": { $ref: "#/components/responses/Unavailable" } /api/v1/market/facets: get: tags: [Market] operationId: getMarketFacets summary: Get filter values for the market list description: | Returns the GPU and CPU models currently on the market, the range of each numeric filter, and the price range. Cached for up to 10 seconds. `count` is the number of machines you can rent right now; it equals `total` of `GET /api/v1/market/machines?gpu=` (or `?cpu=`). Pass `name` to the list's `gpu` / `cpu` parameter exactly as returned (same case and spaces; URL-encode spaces). A range that has no data is left out of `ranges`. `price_range` is null when no machine is on the market. x-zh: summary: "获取市场列表的筛选值" description: |- 返回市场上当前的 GPU 和 CPU 型号、各数值筛选条件的范围以及价格范围。最多缓存 10 秒。 `count` 是当前可租用的设备数量;等于 `GET /api/v1/market/machines?gpu=`(或 `?cpu=`)的 `total`。将 `name` 按返回原样传给列表的 `gpu` / `cpu` 参数(大小写和空格保持一致;空格需 URL 编码)。没有数据的范围不会出现在 `ranges` 中。市场上没有设备时,`price_range` 为 null。 security: [{}, { apiKey: [] }] x-rate-limit-class: read responses: "200": description: Filter values. x-zh: description: "筛选值。" content: application/json: schema: { $ref: "#/components/schemas/MarketFacets" } example: gpu_models: - { name: CMP 50HX, count: 2 } - { name: RTX 5060 Ti, count: 1 } cpu_models: - { name: AMD EPYC 7702 64-Core, count: 1 } - { name: Intel Xeon E5-2686 v4, count: 1 } ranges: vram: [8, 10] cuda: [13.2, 13.3] ram: [8, 128] storage: [110, 1876] sockets: [1, 2] cores: [2, 128] price_range: { min: "0.053", max: "1.050" } "429": { $ref: "#/components/responses/RateLimited" } "503": { $ref: "#/components/responses/Unavailable" } /api/v1/renter/images: get: tags: [Renter] operationId: listRenterImages summary: List preset images description: | Preset container images you can rent with (`image_id` in `POST /api/v1/renter/leases`). `gpu: true` images are for GPU machines, `gpu: false` for CPU-only machines. `min_cuda` is the lowest CUDA version the machine's driver must support (empty = no requirement). x-zh: summary: "列出预置镜像" description: "可用于租用的预置容器镜像(即 `POST /api/v1/renter/leases` 中的 `image_id`)。`gpu: true` 的镜像用于 GPU 设备,`gpu: false` 的镜像用于纯 CPU 设备。`min_cuda` 是设备驱动必须支持的最低 CUDA 版本(为空表示无要求)。" security: [{ apiKey: [renter:read] }] x-rate-limit-class: read responses: "200": description: Preset images. x-zh: description: "预置镜像。" content: application/json: schema: type: object properties: items: { type: array, items: { $ref: "#/components/schemas/Image" } } example: items: - { id: cuda-12-runtime, name: CUDA 12.8 Runtime, image: "nvidia/cuda:12.8.1-runtime-ubuntu22.04", gpu: true, min_cuda: "12.8" } - { id: pytorch-cuda-12, name: PyTorch 2.8.0 · CUDA 12.8, image: "pytorch/pytorch:2.8.0-cuda12.8-cudnn9-runtime", gpu: true, min_cuda: "12.8" } - { id: ubuntu-cpu, name: Ubuntu 22.04 · CPU, image: "ubuntu:22.04", gpu: false, min_cuda: "" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases: get: tags: [Renter] operationId: listLeases summary: List your instances description: | Lists your rented instances, one page at a time (`page` / `per_page`). `tab=current` (default) lists instances that have not ended, including ones still being delivered; `tab=history` lists ended ones. A page number past the last page returns the last page. On the current tab, `counts` and `gpu_models` cover all your current instances and ignore the filters; `hourly_total` is the summed hourly price of instances that are being billed. Use `phase` to tell delivery (`pulling` → `preparing` → `starting`) from `running`. x-zh: summary: "列出你的实例" description: |- 分页列出你租用的实例(`page` / `per_page`)。`tab=current`(默认)列出尚未结束的实例,包括仍在交付中的实例;`tab=history` 列出已结束的实例。页码超过最后一页时返回最后一页。 在 current 标签下,`counts` 和 `gpu_models` 涵盖你所有当前实例,不受筛选条件影响;`hourly_total` 是正在计费的实例的每小时价格总和。通过 `phase` 区分交付中(`pulling` → `preparing` → `starting`)与 `running`。 security: [{ apiKey: [renter:read] }] x-rate-limit-class: read_pg parameters: - name: tab in: query schema: { type: string, enum: [current, history], default: current } - name: phase in: query description: Current tab only. `delivery` = any of `pulling`, `preparing`, `starting`. x-zh: description: "仅限 current 标签。`delivery` = `pulling`、`preparing`、`starting` 中的任一个。" schema: { type: string, enum: [running, delivery, pulling, preparing, starting] } - name: gpu in: query description: Current tab only. Exact GPU model, as in `gpu_models`. x-zh: description: "仅限 current 标签。确切的 GPU 型号,与 `gpu_models` 中一致。" schema: { type: string } - name: sort in: query description: Current tab only. x-zh: description: "仅限 current 标签。" schema: { type: string, enum: [machine, gpuModels, image, gpuUtil, cpu, memory, rate, started, status], default: machine } - name: order in: query description: Current tab only. x-zh: description: "仅限 current 标签。" schema: { type: string, enum: [asc, desc] } - name: reason in: query description: History tab only. Only instances that ended for this `end_reason`. x-zh: description: "仅限 history 标签。仅返回因该 `end_reason` 结束的实例。" schema: { type: string, enum: [renter, balance_exhausted, offline_rented, verdict, admin, delivery_failed] } - name: days in: query description: History tab only. Only instances that ended in the last N days. 0 = any. x-zh: description: "仅限 history 标签。仅返回最近 N 天内结束的实例。0 = 不限。" schema: { type: integer, enum: [0, 7, 30, 90] } - name: tags in: query description: Comma-separated tag IDs (from `GET /api/v1/renter/tags`); matches instances with any of them. x-zh: description: "以逗号分隔的标签 ID(来自 `GET /api/v1/renter/tags`);匹配带有其中任一标签的实例。" schema: { type: string, example: "12,15" } - name: q in: query description: Case-insensitive search in device number, GPU model, image and tag names. At most 64 characters. x-zh: description: "在设备编号、GPU 型号、镜像和标签名称中搜索,不区分大小写。最多 64 个字符。" schema: { type: string, maxLength: 64 } - name: page in: query schema: { type: integer, minimum: 1, maximum: 1000000, default: 1 } - name: per_page in: query description: Default 50 on the current tab, 20 on the history tab. x-zh: description: "current 标签默认 50,history 标签默认 20。" schema: { type: integer, minimum: 1, maximum: 1000 } responses: "200": description: One page of instances. The history tab has only `items` and the paging fields. x-zh: description: "一页实例。history 标签仅包含 `items` 和分页字段。" content: application/json: schema: { $ref: "#/components/schemas/LeasePage" } example: items: - id: "57" device_no: SZ-000014 spec: { gpu_model: CMP 50HX, gpu_count: 8, gpu_vram: 10, cuda: "13.3", cpu_model: Intel Xeon E5-2686 v4, cpu_sockets: 1, cpu_cores: 18, cpu_threads: 36, ram_gb: 12, disk_gb: 110, storage_type: SSD } image: "nvidia/cuda:12.8.1-runtime-ubuntu22.04" image_custom: false phase: running online: true last_seen_at: 1762416000 started_at: 1762412300 billing_from: 1762412400 ended_at: null rent_total_hr: "0.424" rent_unit_hr: "0.053" rent_charged: "0.43" end_reason: null fail_code: null progress: null pull_stage: null retry_code: null tag_ids: [] metrics: { gpu_util_avg: 97, gpu_temp_max: 61, cpu_util: 12.5, mem_used_gb: 3.1, mem_total_gb: 12, gpus: [] } startup_cmd: null startup: null tasks: null remote: { state: ready, error: "" } total: 1 page: 1 per_page: 50 total_pages: 1 hourly_total: "0.424" counts: { current: 1, running: 1, delivery: 0, pulling: 0, preparing: 0, starting: 0 } gpu_models: [CMP 50HX] "400": { $ref: "#/components/responses/BadRequest" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "429": { $ref: "#/components/responses/RateLimited" } post: tags: [Renter] operationId: createLease summary: Rent a machine description: | Rents one whole machine. Billing starts when the instance is delivered and is charged every minute. Your balance must cover at least one hour of rent. The new instance starts in phase `pulling`; poll `GET /api/v1/renter/leases` for its state. **`Idempotency-Key` is required with an API key.** If a request times out, send it again with the same key and body: you get the same order back (200, same `id`) instead of renting twice, even if that order has ended since. A failed order does not use up the key. x-zh: summary: "租用设备" description: |- 租用一整台设备。实例交付后开始计费,按分钟扣费。你的余额必须至少足够支付一小时租金。新实例的初始阶段为 `pulling`;轮询 `GET /api/v1/renter/leases` 获取其状态。 **使用 API 密钥时必须提供 `Idempotency-Key`。** 如果请求超时,使用相同的幂等键和请求体重新发送:你会得到同一个订单(200,相同的 `id`),而不会重复租用,即使该订单此后已结束。失败的订单不会占用该幂等键。 security: [{ apiKey: [renter:write] }] x-rate-limit-class: order parameters: - name: Idempotency-Key in: header required: true description: Any unique string you choose, 1-64 visible ASCII characters (no spaces). Use a new one for every new order. x-zh: description: "由你自定的任意唯一字符串,1-64 个可见 ASCII 字符(不含空格)。每个新订单使用一个新值。" schema: { type: string, minLength: 1, maxLength: 64, pattern: '^[\x21-\x7e]{1,64}$', example: order-20261106-0001 } requestBody: required: true content: application/json: schema: type: object required: [machine_id, device_no, price_hr] description: Give exactly one of `image_id` and `image`. `startup_cmd` and `tasks` cannot both be set. Body at most 64 KiB. x-zh: description: "`image_id` 和 `image` 必须且只能提供一个。`startup_cmd` 和 `tasks` 不能同时设置。请求体最大 64 KiB。" properties: machine_id: { type: string, description: 'From the market list.', x-zh: {description: "来自市场列表。"} } device_no: { type: string, description: 'From the market list; must match `machine_id`.', x-zh: {description: "来自市场列表;必须与 `machine_id` 对应。"} } price_hr: { type: string, pattern: '^(0|[1-9][0-9]{0,15})(\.[0-9]{1,3})?$', description: 'The whole-machine price per hour you saw: `total_price_hr` from the market list, as is (decimal string). If the current price is different, the order is not placed and you get 409 `price_changed` with the current price.', x-zh: {description: "你看到的整机每小时价格:市场列表的 `total_price_hr` 原样传入(十进制字符串)。与现价不同时不下单,返回 409 `price_changed` 并带上现价。"} } image_id: { type: string, description: 'A preset image ID from `GET /api/v1/renter/images`.', x-zh: {description: "`GET /api/v1/renter/images` 返回的预置镜像 ID。"} } image: { type: string, description: 'Your own image from a public registry, for example `docker.io/library/ubuntu:22.04`.', x-zh: {description: "来自公共镜像仓库的你自己的镜像,例如 `docker.io/library/ubuntu:22.04`。"} } startup_cmd: { type: string, maxLength: 4096, description: 'Shell command run inside the instance after it starts. At most 4096 bytes of UTF-8, no NUL.', x-zh: {description: "实例启动后在其内部执行的 shell 命令。最多 4096 字节 UTF-8,不能包含 NUL。"} } tasks: type: array maxItems: 16 description: Compute tasks to run after delivery, from your own task templates (`id` from `GET /api/v1/renter/task-templates`). Each template at most once; `gpus` must be null (all GPUs) when ordering. x-zh: description: "交付后要运行的计算任务,来自你自己的任务模板(`id` 取自 `GET /api/v1/renter/task-templates`)。每个模板最多使用一次;下单时 `gpus` 必须为 null(全部 GPU)。" items: type: object required: [template_id] properties: template_id: { type: string, description: 'Template `id` from `GET /api/v1/renter/task-templates`.', x-zh: {description: "`GET /api/v1/renter/task-templates` 返回的模板 `id`。"} } gpus: { type: "null" } example: machine_id: 314d1670-872d-4d8d-be94-a4ceea1c0c58 device_no: SZ-000014 price_hr: "0.848" image_id: cuda-12-runtime responses: "200": description: Order placed (or the same order again, for a repeated `Idempotency-Key`). x-zh: description: "已下单(对于重复的 `Idempotency-Key`,返回同一订单)。" content: application/json: schema: type: object properties: ok: { type: boolean } id: { type: string, description: 'Lease ID (decimal string).', x-zh: {description: "租约 ID(十进制字符串)。"} } example: { ok: true, id: "57" } "400": description: | `bad_request` (missing or invalid fields, or a malformed `Idempotency-Key`), `idempotency_key_required`, `image_invalid` (also an unknown `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`. x-zh: description: "`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`。" x-codes: [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] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "401": { $ref: "#/components/responses/Unauthorized" } "403": description: '`own_machine` (you cannot rent your own machine), or an API key error (`api_key_scope_denied`, `api_key_ip_denied`, `api_key_route_not_allowed`).' x-zh: description: "`own_machine`(不能租用自己的设备),或 API 密钥错误(`api_key_scope_denied`、`api_key_ip_denied`、`api_key_route_not_allowed`)。" x-codes: [own_machine] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "404": description: '`template_not_found`: a task template in `tasks` does not exist or is not yours.' x-zh: description: "`template_not_found`:`tasks` 中的某个任务模板不存在或不属于你。" x-codes: [template_not_found] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "409": description: | `machine_not_rentable`, `machine_rented`, `machine_configuration_changed` (refresh the market and retry), `price_changed` (the host or the platform changed the price after you loaded the market; the response has the current `price_hr` (whole machine) and `price_per_hr` (per GPU or CPU socket, may be absent); place a new order with the new `price_hr` and a new `Idempotency-Key`), `balance_too_low` (balance is below one hour of rent). x-zh: description: "`machine_not_rentable`、`machine_rented`、`machine_configuration_changed`(刷新市场后重试)、`price_changed`(你加载市场之后出租方或平台改了价格;回包带现价 `price_hr`(整机)和 `price_per_hr`(每张卡或每颗 CPU,可能没有);用新的 `price_hr` 和新的 `Idempotency-Key` 重新下单)、`balance_too_low`(余额不足一小时租金)。" x-codes: [machine_not_rentable, machine_rented, machine_configuration_changed, price_changed, balance_too_low] content: application/json: schema: allOf: - $ref: "#/components/schemas/Error" - type: object properties: price_hr: { type: string, description: 'Only with `price_changed`: current whole-machine price per hour.', x-zh: {description: "仅 `price_changed`:当前整机每小时价格。"} } price_per_hr: { type: string, description: 'Only with `price_changed`: current price per GPU (or CPU socket) per hour; may be absent.', x-zh: {description: "仅 `price_changed`:当前每张卡(或每颗 CPU)每小时价格;可能没有。"} } example: { ok: false, code: price_changed, error: "the price has changed; price_hr in this response is the current price", price_hr: "0.912", price_per_hr: "0.456" } "422": description: '`idempotency_mismatch`: this key was already used for a different order.' x-zh: description: "`idempotency_mismatch`:该幂等键已用于另一个订单。" x-codes: [idempotency_mismatch] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/{lease_id}/settles: get: tags: [Renter] operationId: listLeaseSettles summary: List the charges of one instance description: | Returns the instance's billing summary (`lease`) and its charges, newest first, 20 per page by default. Pass `at` (a `period_end` value) instead of `page` to get the page that contains that charge. A page past the end returns empty `items`. x-zh: summary: "列出单个实例的扣费记录" description: "返回实例的计费摘要(`lease`)及其扣费记录,按时间倒序,默认每页 20 条。传入 `at`(某个 `period_end` 值)代替 `page`,可获取包含该扣费记录的页。超出末页时返回空的 `items`。" security: [{ apiKey: [renter:read] }] x-rate-limit-class: read_pg parameters: - $ref: "#/components/parameters/LeaseId" - name: page in: query schema: { type: integer, minimum: 1, maximum: 1000000, default: 1 } - name: per_page in: query schema: { type: integer, minimum: 1, maximum: 50, default: 20 } - name: at in: query description: '`period_end` of a charge. Cannot be combined with `page`.' x-zh: description: "某条扣费记录的 `period_end`。不能与 `page` 同时使用。" schema: { type: integer, minimum: 1 } responses: "200": description: Billing summary and one page of charges. x-zh: description: "计费摘要和一页扣费记录。" content: application/json: schema: type: object properties: lease: type: object properties: lease_id: { type: string } device_no: { type: string } status: { type: string, enum: [active, ended] } started_at: { type: integer } ended_at: { type: [integer, "null"] } price_hr: { type: string, description: 'USDT per hour for the whole machine.', x-zh: {description: "整台设备的价格,单位 USDT/小时。"} } minutes: { type: integer, description: 'Billed minutes so far.', x-zh: {description: "截至目前已计费的分钟数。"} } rent_charged: { type: string } bad_debt: { type: string, description: 'Rent that could not be charged because the balance ran out.', x-zh: {description: "因余额耗尽而未能扣除的租金。"} } items: type: array items: type: object properties: period_end: { type: integer } minutes: { type: integer } rent_paid: { type: string } bad_debt: { type: string } total: { type: integer } page: { type: integer } example: lease: { lease_id: "57", device_no: SZ-000014, status: active, started_at: 1762412300, ended_at: null, price_hr: "0.424", minutes: 61, rent_charged: "0.43", bad_debt: "0.00" } items: - { period_end: 1762416000, minutes: 1, rent_paid: "0.01", bad_debt: "0.00" } total: 61 page: 1 "400": { $ref: "#/components/responses/BadRequest" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseNotFound" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/{lease_id}/container-log: get: tags: [Renter] operationId: getContainerLog summary: Read the container log description: | Returns the latest complete tail of your container log (`docker logs`: the startup command's output and anything written to `/proc/1/fd/1`; the last 200 lines, up to 64 KiB). Logs are fetched on request: call `POST .../container-log`, then poll this endpoint until `log.req` equals the `req` you got back. `log` is null until a log has arrived. Only while the instance is `running`. The log is deleted when the rental ends. x-zh: summary: "读取容器日志" description: "返回容器日志(`docker logs`:启动命令的输出,以及写到 `/proc/1/fd/1` 的内容;最后 200 行、最多 64 KiB)的最新完整一份。日志按请求获取:先调用 `POST .../container-log`,然后轮询本接口,直到 `log.req` 等于返回的 `req`。日志到达前 `log` 为 null。仅在实例处于 `running` 时可用。租用结束后日志即删除。" security: [{ apiKey: [renter:read] }] x-rate-limit-class: read_pg parameters: - $ref: "#/components/parameters/LeaseId" responses: "200": description: The latest log. x-zh: description: "最新日志。" content: application/json: schema: type: object properties: ok: { type: boolean } req: { type: integer, description: 'Number of your latest log request (0 = never requested).', x-zh: {description: "你最近一次日志请求的编号(0 = 从未请求)。"} } log: type: [object, "null"] properties: req: { type: integer, description: 'The request this log answers.', x-zh: {description: "该日志对应的请求。"} } at: { type: integer } truncated: { type: boolean } error: { type: string, enum: ["", no_log, exec_failed], description: 'Empty when the log was read (the content may be empty). `exec_failed` = the machine could not read the container log.', x-zh: {description: "成功读取日志时为空(内容可以为空)。`exec_failed` = 设备读取不到容器日志。"} } content: { type: string } example: ok: true req: 3 log: { req: 3, at: 1762416010, truncated: false, error: "", content: "Starting worker...\n" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseNotFound" } "409": { $ref: "#/components/responses/LeaseNotRunning" } "429": { $ref: "#/components/responses/RateLimited" } post: tags: [Renter] operationId: requestContainerLog summary: Ask the instance for a fresh container log description: | Asks the machine to send the current tail of the container log. Returns the request number `req`; read the log with `GET .../container-log`. At most once every 5 seconds per instance. Only while the instance is `running`. x-zh: summary: "请求实例发送最新容器日志" description: "请求设备发送当前的容器日志尾部。返回请求编号 `req`;通过 `GET .../container-log` 读取日志。每个实例最多每 5 秒请求一次。仅在实例处于 `running` 时可用。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/LeaseId" responses: "200": description: Request sent. x-zh: description: "请求已发送。" content: application/json: schema: type: object properties: ok: { type: boolean } req: { type: integer } example: { ok: true, req: 3 } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseNotFound" } "409": { $ref: "#/components/responses/LeaseNotRunning" } "429": description: | `container_log_rate_limited` (requested less than 5 seconds ago; the body also has `retry_after` in seconds), or `rate_limited`. Both send a `Retry-After` header. x-zh: description: "`container_log_rate_limited`(距上次请求不足 5 秒;响应体中还包含以秒为单位的 `retry_after`),或 `rate_limited`。两者都会返回 `Retry-After` 响应头。" x-codes: [container_log_rate_limited, rate_limited] headers: Retry-After: { schema: { type: integer } } content: application/json: schema: allOf: - $ref: "#/components/schemas/Error" - type: object properties: retry_after: { type: integer } example: { ok: false, code: container_log_rate_limited, error: container log was requested less than 5 seconds ago, retry_after: 4 } /api/v1/renter/leases/{lease_id}/access: get: tags: [Renter] operationId: getLeaseAccess summary: Get SSH connection details for an instance description: | **Returns a password.** Gives the SSH command and password for your instance's container. Treat the response as a secret: do not log it. `ssh_command` is filled only when `status` is `ready`; `password` is returned whenever the instance is running. The user is always `root` (inside your container). Needs `renter:write` (a read-only key cannot get passwords). x-zh: summary: "获取实例的 SSH 连接信息" description: |- **返回密码。** 提供实例容器的 SSH 命令和密码。请将响应作为机密处理:不要记录到日志中。 仅当 `status` 为 `ready` 时才会填写 `ssh_command`;只要实例在运行,就会返回 `password`。用户始终为 `root`(在你的容器内)。需要 `renter:write`(只读密钥无法获取密码)。 security: [{ apiKey: [renter:write] }] x-rate-limit-class: remote parameters: - $ref: "#/components/parameters/LeaseId" responses: "200": description: Connection details. x-zh: description: "连接信息。" content: application/json: schema: type: object properties: ok: { type: boolean } access: type: object properties: status: { type: string, enum: [connecting, ready, reconnecting, failed] } error: { type: string, description: 'Reason text from the relay or the machine, when not ready.', x-zh: {description: "未就绪时,来自中转或设备的原因说明。"} } ssh_command: { type: string, description: 'Empty unless `status` is `ready`.', x-zh: {description: "仅当 `status` 为 `ready` 时有值,否则为空。"} } password: { type: string, description: '20 characters, `0-9A-Za-z`. Secret.', x-zh: {description: "20 个字符,`0-9A-Za-z`。需保密。"} } fingerprint: { type: string, description: 'SSH host key fingerprint.', x-zh: {description: "SSH 主机密钥指纹。"} } live: { type: boolean, description: 'Whether the relay answered for this request.', x-zh: {description: "本次请求是否得到中转的响应。"} } example: ok: true access: status: ready error: "" ssh_command: ssh -p 20022 -o HostKeyAlias=suanzu-lease-57 root@relay.example.com password: EXAMPLEPASSWORD00000 fingerprint: SHA256:EXAMPLEFINGERPRINT live: true "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseNotFound" } "409": description: '`lease_not_running`, or `remote_not_ready` (the connection is not set up yet; retry shortly).' x-zh: description: "`lease_not_running`,或 `remote_not_ready`(连接尚未建立,请稍后重试)。" x-codes: [lease_not_running, remote_not_ready] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } "503": description: '`remote_unconfigured`, `remote_relay_failed`, or `request_timeout`.' x-zh: description: "`remote_unconfigured`、`remote_relay_failed` 或 `request_timeout`。" x-codes: [remote_unconfigured, remote_relay_failed, request_timeout] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } /api/v1/renter/leases/{lease_id}/stop: post: tags: [Renter] operationId: stopLease summary: Stop an instance description: | Stops the instance and settles the rent up to now. During delivery (before billing starts) this cancels the order at no charge. Stopping an instance that has already ended returns 200 again. x-zh: summary: "停止实例" description: "停止实例,并结算截至当前的租金。交付期间(开始计费前)停止会取消订单,不收费。对已结束的实例再次停止,同样返回 200。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/LeaseId" responses: "200": { $ref: "#/components/responses/Ok" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseNotFound" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/{lease_id}/access/password: post: tags: [Renter] operationId: rotateLeasePassword summary: Change the SSH password of an instance description: | Sets a new SSH password and disconnects all current SSH sessions. The response does not contain the new password; get it with `GET .../access`. Only while the instance is `running`. x-zh: summary: "修改实例的 SSH 密码" description: "设置新的 SSH 密码,并断开当前所有 SSH 会话。响应中不包含新密码,请通过 `GET .../access` 获取。仅在实例处于 `running` 状态时可用。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/LeaseId" responses: "200": { $ref: "#/components/responses/Ok" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseNotFound" } "409": description: '`lease_not_running`, or `remote_not_ready`.' x-zh: description: "`lease_not_running` 或 `remote_not_ready`。" x-codes: [lease_not_running, remote_not_ready] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } "503": description: '`remote_unconfigured`, or `request_timeout`.' x-zh: description: "`remote_unconfigured` 或 `request_timeout`。" x-codes: [remote_unconfigured, request_timeout] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } /api/v1/renter/leases/{lease_id}/startup: put: tags: [Renter] operationId: setStartupCommand summary: Change the startup command description: | Saves a new startup command and restarts the container with it. If the command is the same as the current one, nothing happens: the container is not restarted and `startup_rev` stays the same. So this call is safe to retry. To run the same command again, use `POST .../startup/restart`. An empty string clears the command. Setting a command removes all compute tasks of this instance. Only while the instance is `running`. Returns the current `startup_rev`. x-zh: summary: "修改启动命令" description: "保存新的启动命令,并用该命令重启容器。命令与当前相同时不做任何操作:不重启容器,`startup_rev` 不变,因此可以放心重试。要重新执行同一条命令,请使用 `POST .../startup/restart`。传入空字符串会清除命令。设置命令会删除该实例的所有计算任务。仅在实例处于 `running` 状态时可用。返回当前的 `startup_rev`。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/LeaseId" requestBody: required: true content: application/json: schema: type: object required: [startup_cmd] properties: startup_cmd: { type: string, maxLength: 4096, description: 'At most 4096 bytes of UTF-8, no NUL. Empty = no command.', x-zh: {description: "UTF-8 编码,最多 4096 字节,不能包含 NUL。为空表示无命令。"} } example: { startup_cmd: "python3 /workspace/train.py" } responses: "200": description: Saved; the container is restarting. If the command did not change, nothing was done and `startup_rev` is unchanged. x-zh: description: "已保存,容器正在重启。如果命令没有变化,则不做任何操作,`startup_rev` 不变。" content: application/json: schema: type: object properties: ok: { type: boolean } startup_rev: { type: integer } example: { ok: true, startup_rev: 2 } "400": description: '`bad_request` (`startup_cmd` missing or not a string), `startup_cmd_invalid`.' x-zh: description: "`bad_request`(缺少 `startup_cmd` 或其不是字符串)、`startup_cmd_invalid`。" x-codes: [bad_request, startup_cmd_invalid] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseNotFound" } "409": description: '`lease_not_running`, or `rebuild_in_progress` (a rebuild is in progress; try again after it finishes).' x-zh: description: "`lease_not_running`,或 `rebuild_in_progress`(正在重建,结束后再试)。" x-codes: [lease_not_running, rebuild_in_progress] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/{lease_id}/startup/restart: post: tags: [Renter] operationId: restartStartupCommand summary: Restart the container description: | Restarts the container. Processes in the container are stopped; files are kept. If a startup command is set, it is not changed and runs again after the container starts (`startup.runs` starts again from 1). Works with or without a startup command, only while the instance is `running`. Returns the new `startup_rev`. **Each successful call restarts the container once. Do not retry automatically.** If a request times out, call `GET /api/v1/renter/leases` first: if `startup.rev` already equals the previous `startup_rev` + 1, the restart went through. x-zh: summary: "重启容器" description: "重启容器。容器内的进程会被结束,文件会保留。如果设置了启动命令,命令不变,容器启动后会重新执行,`startup.runs` 从 1 重新计数。有没有启动命令都可以用,仅在实例处于 `running` 状态时可用。返回新的 `startup_rev`。**每次成功调用都会重启一次容器,请不要自动重试。** 如果请求超时,请先调用 `GET /api/v1/renter/leases`:如果 `startup.rev` 已经等于之前的 `startup_rev` + 1,说明重启已经生效。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/LeaseId" responses: "200": description: The container is restarting. x-zh: description: "容器正在重启。" content: application/json: schema: type: object properties: ok: { type: boolean } startup_rev: { type: integer } example: { ok: true, startup_rev: 3 } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseNotFound" } "409": description: '`lease_not_running`: the instance is not running. `rebuild_in_progress`: a rebuild is in progress; try again after it finishes.' x-zh: description: "`lease_not_running`:实例不在运行中。`rebuild_in_progress`:正在重建,结束后再试。" x-codes: [lease_not_running, rebuild_in_progress] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/{lease_id}/rebuild: post: tags: [Renter] operationId: rebuildLease summary: Rebuild the instance description: | Rebuilds the container of a `running` instance on the same machine: either with a different image (`image_id` or `image`, as when renting) or with the current image (send `{}`; the image is pulled again, so a tag that now points to a newer version is updated). **All files in the container are deleted.** The GPUs, the SSH connection details and the rent stay the same, and billing does not stop. The old container keeps running while the new image is pulled. If the pull fails, the old container is not changed. If the new container cannot start, it is kept for troubleshooting and the old one is already gone; rebuild again or stop the rental. Track the result in `rebuild` of `GET /api/v1/renter/leases` (`pending` → `pulling` → `switching` → `done` / `failed`). Optional `startup_cmd` sets the startup command of the new container in the same step (same rules as `PUT .../startup`; omit it to keep the current command, an empty string clears it). Setting a non-empty command removes all compute tasks of this instance. While a rebuild is in progress, `startup/restart`, `PUT .../startup` and another rebuild return 409 `rebuild_in_progress`. **Each successful call rebuilds the instance once. Do not retry automatically.** If a request times out, call `GET /api/v1/renter/leases` first: if `rebuild.rev` already equals the previous value + 1, the rebuild was accepted. x-zh: summary: "重建实例" description: |- 在同一台设备上重建 `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,说明重建已被受理。 security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/LeaseId" requestBody: required: true content: application/json: schema: type: object description: Give at most one of `image_id` and `image`; give neither (`{}`) to rebuild with the current image. Body at most 64 KiB. x-zh: description: "`image_id` 和 `image` 最多提供一个;都不提供(`{}`)表示用现有镜像重建。请求体最大 64 KiB。" properties: image_id: { type: string, description: 'A preset image ID from `GET /api/v1/renter/images`.', x-zh: {description: "`GET /api/v1/renter/images` 返回的预置镜像 ID。"} } image: { type: string, description: 'Your own image from a public registry, for example `docker.io/library/ubuntu:22.04`.', x-zh: {description: "来自公共镜像仓库的你自己的镜像,例如 `docker.io/library/ubuntu:22.04`。"} } startup_cmd: { type: string, maxLength: 4096, description: 'Startup command of the new container. Omit to keep the current one; empty = no command. At most 4096 bytes of UTF-8, no NUL.', x-zh: {description: "新容器的启动命令。不传表示保留当前命令;为空表示无命令。最多 4096 字节 UTF-8,不能包含 NUL。"} } example: { image: "ghcr.io/foo/bar:1.2" } responses: "200": description: Accepted. The machine starts the rebuild within seconds. x-zh: description: "已受理,设备会在几秒内开始重建。" content: application/json: schema: type: object properties: ok: { type: boolean } rebuild_rev: { type: integer, description: 'Number of this rebuild; matches `rebuild.rev` in the lease list.', x-zh: {description: "本次重建的序号,与租约列表里的 `rebuild.rev` 对应。"} } example: { ok: true, rebuild_rev: 1 } "400": description: | `bad_request` (not a JSON object, an unknown field, both `image_id` and `image`, or an empty one), `image_unchanged` (this is the current image; send `{}` to pull it again), `image_invalid`, `image_registry_unsupported`, `image_gpu_mismatch`, `image_cuda_too_old`, `startup_cmd_invalid`. x-zh: description: "`bad_request`(不是 JSON 对象、有未知字段、同时提供 `image_id` 和 `image`,或其中一个为空)、`image_unchanged`(就是当前镜像;要重新拉取请发送 `{}`)、`image_invalid`、`image_registry_unsupported`、`image_gpu_mismatch`、`image_cuda_too_old`、`startup_cmd_invalid`。" x-codes: [bad_request, image_unchanged, image_invalid, image_registry_unsupported, image_gpu_mismatch, image_cuda_too_old, startup_cmd_invalid] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseNotFound" } "409": description: '`lease_not_running`, `rebuild_in_progress` (wait for the current rebuild to finish), or `agent_outdated` (the machine''s agent is too old; the host needs to upgrade it).' x-zh: description: "`lease_not_running`、`rebuild_in_progress`(请等待当前重建结束)或 `agent_outdated`(设备的 agent 版本过低,需要出租方升级)。" x-codes: [lease_not_running, rebuild_in_progress, agent_outdated] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/account: get: tags: [Renter] operationId: getRenterAccount summary: Get your rent balance description: Your renter balance in USDT. `updated_at` is null if the account has never had a transaction. x-zh: summary: "获取你的租用方余额" description: "你的租用方余额(USDT)。账户从未产生流水时,`updated_at` 为 null。" security: [{ apiKey: [renter:read] }] x-rate-limit-class: read_pg responses: "200": description: Balance. x-zh: description: "余额。" content: application/json: schema: type: object properties: balance: { type: string } updated_at: { type: [integer, "null"] } example: { balance: "12.34", updated_at: 1762416000 } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/ledger: get: tags: [Renter] operationId: listRenterLedger summary: List your renter balance transactions description: | Deposits, rent charges and referral shares, newest first. Rent rows have negative `amount` and are updated in place as the instance keeps being billed (`updated_at`). `referral` rows are your referral share from users you invited renting devices, credited to your renter balance (`source` is `referral`). Note: this endpoint pages with `page_size`, not `per_page`. x-zh: summary: "列出租用方余额流水" description: "充值、租金扣费和推荐分润,按时间倒序。租金记录的 `amount` 为负数,实例持续计费时会原地更新(`updated_at`)。`referral` 是你邀请的用户租用设备时给你的推荐分润,进入租用方余额(`source` 为 `referral`)。注意:此接口使用 `page_size` 分页,而不是 `per_page`。" security: [{ apiKey: [renter:read] }] x-rate-limit-class: read_pg parameters: - $ref: "#/components/parameters/Page" - $ref: "#/components/parameters/PageSize" - name: type in: query description: 'Filter by type. `referral` = referral share credited to your renter balance.' x-zh: {description: "按类型筛选。`referral` = 进入租用方余额的推荐分润。"} schema: { type: string, enum: [deposit, rent, referral] } responses: "200": description: One page of transactions. x-zh: description: "一页流水。" content: application/json: schema: type: object properties: items: type: array items: type: object properties: id: { type: string } created_at: { type: integer } type: { type: string, enum: [deposit, rent, referral] } source: { type: string, description: '`usdt` for on-chain deposits, `rent` for rent, `referral` for referral shares.', x-zh: {description: "`usdt` 表示链上充值,`rent` 表示租金,`referral` 表示推荐分润。"} } amount: { type: string, description: 'Negative for rent.', x-zh: {description: "租金为负数。"} } balance_after: { type: string } chain: { type: [string, "null"], enum: [tron, eth, bsc, null], description: 'On-chain deposits only.', x-zh: {description: "仅链上充值。"} } updated_at: { type: [integer, "null"], description: 'Rent rows only.', x-zh: {description: "仅租金记录。"} } total: { type: integer } example: items: - { id: "1031", created_at: 1762412400, type: rent, source: rent, amount: "-0.43", balance_after: "12.34", chain: null, updated_at: 1762416000 } - { id: "1002", created_at: 1762400000, type: deposit, source: usdt, amount: "12.77", balance_after: "12.77", chain: tron, updated_at: null } total: 2 "400": { $ref: "#/components/responses/BadRequest" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/task-templates: get: tags: [Renter] operationId: listRenterTaskTemplates summary: List your compute task templates description: | Your own compute task templates, oldest first. Use `id` as `tasks[].template_id` when renting (`POST /api/v1/renter/leases`) or when setting tasks (`PUT /api/v1/renter/leases/{lease_id}/tasks`). x-zh: summary: "列出你的计算任务模板" description: "你自己的计算任务模板,按创建时间正序。租用时(`POST /api/v1/renter/leases`)或设置任务时(`PUT /api/v1/renter/leases/{lease_id}/tasks`)把 `id` 填进 `tasks[].template_id`。" security: [{ apiKey: [renter:read] }] x-rate-limit-class: read_pg responses: "200": description: Templates. x-zh: description: "模板列表。" content: application/json: schema: type: object properties: items: type: array items: type: object properties: id: { type: string, description: '16 hex characters.', x-zh: {description: "16 位十六进制字符。"} } name: { type: string } description: { type: string } kind: { type: string, enum: [hive, custom], description: '`hive` = HiveOS-style settings; `custom` = your own program.', x-zh: {description: "`hive` = HiveOS 格式的设置;`custom` = 自定义程序。"} } vars: type: array description: Variables passed to the task. `ref` is set when the value comes from your wallets / variables. x-zh: description: "传给计算任务的变量。值来自你的钱包/变量时带 `ref`。" items: type: object properties: key: { type: string } value: { type: string } ref: { type: string } hive: type: object description: Only when `kind` is `hive`. x-zh: description: "仅当 `kind` 为 `hive` 时出现。" properties: coin: { type: string } wallet: { type: string } miner: { type: string } install_url: { type: string } algo: { type: string } template: { type: string } url: { type: string } pass: { type: string } user_config: { type: string } custom: type: object description: Only when `kind` is `custom`. x-zh: description: "仅当 `kind` 为 `custom` 时出现。" properties: start_command: { type: string } package_url: { type: string } extract: { type: boolean } accel: type: object properties: download: { type: boolean, description: 'Download acceleration for the program package.', x-zh: {description: "程序包下载加速。"} } wallet_ref: { type: [string, "null"], description: 'Which of your wallets / variables the HiveOS `wallet` comes from. Null = typed in.', x-zh: {description: "HiveOS `wallet` 取自你的哪一条钱包/变量。null = 手动填写。"} } follow: { type: string, enum: ["", latest, latest_beta], description: 'Follow the latest version. "" = fixed version.', x-zh: {description: "跟随最新版。\"\" = 固定版本。"} } current_tag: { type: string, description: 'GitHub version tag in the download link. "" when it is not a GitHub release link with a version tag.', x-zh: {description: "下载地址里的 GitHub 版本标签。不是带版本标签的 GitHub 发布地址时为 \"\"。"} } version: { type: integer, description: 'Goes up by 1 when what is sent to machines changes.', x-zh: {description: "下发到设备的内容变化时加 1。"} } created_at: { type: integer } updated_at: { type: integer } machine_count: { type: integer, description: 'Instances currently using it.', x-zh: {description: "当前正在使用它的实例数。"} } has_update: { type: boolean, description: 'Present and `true` only when a newer version exists. Templates that follow the latest version compare against the version they would switch to; fixed-version templates compare against the latest stable release on GitHub. Only in this list. A hint only: no notification is sent.', x-zh: {description: "只在有新版本时出现,值为 `true`。跟随最新版的模板与它将要切换到的版本比;固定版本的模板与 GitHub 上最新的正式版比。只有本列表带。仅作提示,不发通知。"} } latest_version: { type: string, description: 'Tag of the newer version. Only with `has_update`.', x-zh: {description: "新版本的标签。只在 `has_update` 时出现。"} } latest_url: { type: string, description: 'Download link of the matching package in the newer version. Absent when that version has no matching package.', x-zh: {description: "新版本里对应安装包的下载地址。新版本里没有对应的安装包时不出现。"} } release_url: { type: string, description: 'GitHub release page of the newer version. Only with `has_update`.', x-zh: {description: "新版本的 GitHub 发布页。只在 `has_update` 时出现。"} } example: items: - id: 3f9a0c1d2e4b5a60 name: Pearl description: "" kind: custom 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 } wallet_ref: null follow: "" current_tag: v1.0 version: 2 created_at: 1762000000 updated_at: 1762000000 machine_count: 0 "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "429": { $ref: "#/components/responses/RateLimited" } post: tags: [Renter] operationId: createRenterTaskTemplate summary: Create a compute task template description: | Creates a compute task template under your account. `kind: custom` runs your own program (`custom.start_command`, optional `custom.package_url`); `kind: hive` uses HiveOS-style settings (`hive`). Body at most 256 KiB; the template itself at most 64 KiB. `ref` / `wallet_ref` can only name your own wallets / variables (`GET /api/v1/renter/wallet-vars`). x-zh: summary: "新建计算任务模板" description: "在你的账户下新建计算任务模板。`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`)。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write requestBody: required: true content: application/json: schema: { $ref: "#/components/schemas/RenterTaskTemplateDraft" } example: { 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 } } responses: "200": description: Created. `template` has the same fields as an item of `GET /api/v1/renter/task-templates`. x-zh: description: "已新建。`template` 的字段与 `GET /api/v1/renter/task-templates` 的列表项相同。" content: application/json: schema: type: object properties: ok: { type: boolean } template: { type: object } example: ok: true template: { id: 3f9a0c1d2e4b5a60, name: Pearl, description: "", kind: custom, 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 }, wallet_ref: null, follow: "", current_tag: v1.0, version: 1, created_at: 1762000000, updated_at: 1762000000, machine_count: 0 } "400": { $ref: "#/components/responses/RenterTemplateInvalid" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/task-templates/{template_id}: put: tags: [Renter] operationId: updateRenterTaskTemplate summary: Replace a compute task template description: | Replaces the whole template (send every field, as in create). If what is sent to machines changes, `version` goes up and running instances that use the template pick up the new settings with the next heartbeat. x-zh: summary: "替换计算任务模板" description: "整份替换模板(与新建一样发送全部字段)。下发到设备的内容有变化时,`version` 加 1,使用该模板的运行中实例随下一次心跳应用新设置。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/RenterTemplateId" requestBody: required: true content: application/json: schema: { $ref: "#/components/schemas/RenterTaskTemplateDraft" } example: { 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 } } responses: "200": description: Saved. `template` is the updated template. x-zh: description: "已保存。`template` 为更新后的模板。" content: application/json: schema: type: object properties: ok: { type: boolean } template: { type: object } example: ok: true template: { id: 3f9a0c1d2e4b5a60, name: Pearl, description: "", kind: custom, 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 }, wallet_ref: null, follow: "", current_tag: v1.0, version: 3, created_at: 1762000000, updated_at: 1762003600, machine_count: 1 } "400": { $ref: "#/components/responses/RenterTemplateInvalid" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/RenterTemplateNotFound" } "429": { $ref: "#/components/responses/RateLimited" } delete: tags: [Renter] operationId: deleteRenterTaskTemplate summary: Delete a compute task template description: | Deletes a template that no instance uses. If instances still use it you get 409 `task_template_in_use` with `machine_count`; remove the task from those instances first. x-zh: summary: "删除计算任务模板" description: "删除没有实例在用的模板。仍有实例在用时返回 409 `task_template_in_use` 并带 `machine_count`;请先从这些实例中移除该任务。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/RenterTemplateId" responses: "200": { $ref: "#/components/responses/Ok" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/RenterTemplateNotFound" } "409": description: '`task_template_in_use`: instances still use this template; `machine_count` says how many.' x-zh: description: "`task_template_in_use`:仍有实例在用该模板;`machine_count` 为实例数。" x-codes: [task_template_in_use] content: application/json: schema: allOf: - $ref: "#/components/schemas/Error" - type: object properties: machine_count: { type: integer } example: { ok: false, code: task_template_in_use, error: template is used by instances, machine_count: 2 } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/{lease_id}/tasks: get: tags: [Renter] operationId: getLeaseTasks summary: Get the compute tasks of an instance description: | The instance's compute tasks with their latest message, stats and states, plus the GPUs of the machine (`gpus`, for choosing GPUs in `PUT .../tasks`). Works during delivery too. `stats_at` is null and `stats` / `states` are empty while the instance has not reported stats for the current task list yet. x-zh: summary: "获取实例的计算任务" description: "实例的计算任务及其最新消息、统计和状态,并附上设备的 GPU(`gpus`,用于在 `PUT .../tasks` 中选卡)。交付期间也可调用。实例尚未上报当前任务列表的统计时,`stats_at` 为 null,`stats` / `states` 为空。" security: [{ apiKey: [renter:read] }] x-rate-limit-class: read_pg parameters: - $ref: "#/components/parameters/LeaseId" responses: "200": description: Tasks. x-zh: description: "任务。" content: application/json: schema: type: object properties: ok: { type: boolean } tasks: type: array items: allOf: - $ref: "#/components/schemas/TaskItem" - type: object properties: latest: { type: [object, "null"], description: 'Latest task message: `{type, title, created_at}`.', x-zh: {description: "最新任务消息:`{type, title, created_at}`。"} } progress: { type: [object, "null"], description: 'Latest progress line: `{title, created_at}`.', x-zh: {description: "最新进度行:`{title, created_at}`。"} } stats_at: { type: [integer, "null"], description: 'When `stats` was reported.', x-zh: {description: "`stats` 的上报时间。"} } stats: { type: array, items: { $ref: "#/components/schemas/TaskStats" }, description: 'Stats of the HiveOS tasks as reported by the instance. [] when they belong to an older task list.', x-zh: {description: "实例上报的 HiveOS 任务统计。属于旧的任务列表时为 []。"} } states: { type: array, items: { $ref: "#/components/schemas/TaskState" }, description: 'Run state of each task as reported by the instance. [] when they belong to an older task list.', x-zh: {description: "实例上报的各任务运行状态。属于旧的任务列表时为 []。"} } error: { type: [string, "null"], description: 'Why the instance could not read its tasks this round (English), or null.', x-zh: {description: "实例本轮未能读取任务的原因(英文),否则为 null。"} } gpus: type: array description: GPUs of the machine, bus IDs in ascending order. x-zh: description: "设备的 GPU,按总线号升序。" items: type: object properties: busid: { type: string } model: { type: string } hashes: { type: [array, "null"], items: { $ref: "#/components/schemas/GPUHash" }, description: 'Per-GPU hashrate from the tasks. [] = none; null = could not be matched to this GPU.', x-zh: {description: "该卡来自各任务的算力。[] = 没有;null = 无法对应到这张卡。"} } example: ok: true tasks: - { binding_id: 3f9a0c1d2e4b5a60, revision: 2, template_id: 9c2e5b7a1d3f4e6a, name: Pearl, kind: custom, gpus: null, paused: false, miner: "", version: 3, latest: null, progress: null } stats_at: 1762416000 stats: [] states: [] error: null gpus: - { busid: "0000:01:00.0", model: RTX 4090, hashes: [] } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseNotFound" } "429": { $ref: "#/components/responses/RateLimited" } put: tags: [Renter] operationId: setLeaseTasks summary: Set the compute tasks of an instance description: | Sets the whole task list of one instance; `tasks: []` removes all tasks. Up to 16 tasks, each template at most once. To keep a task running unchanged, send its `binding_id` with the same template and GPUs: it keeps its ID and is not restarted. `gpus` null = all GPUs; otherwise bus IDs from `GET .../tasks` `gpus`. Setting tasks clears the startup command. Only while the instance is `running`. Saving the same list again changes nothing, so this call is safe to retry. x-zh: summary: "设置实例的计算任务" description: "整份设置一个实例的任务列表;`tasks: []` 移除全部任务。最多 16 个任务,每个模板最多使用一次。要让某个任务保持原样运行,请带上它的 `binding_id`,并使用相同的模板和 GPU:它会保留 ID 且不会重启。`gpus` 为 null = 全部 GPU;否则填 `GET .../tasks` 中 `gpus` 的总线号。设置任务会清除启动命令。仅在实例处于 `running` 时可用。再次保存相同的列表不会有任何变化,因此可以放心重试。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/LeaseId" requestBody: required: true content: application/json: schema: type: object required: [tasks] properties: tasks: { $ref: "#/components/schemas/RenterTaskPicks" } example: { tasks: [{ binding_id: 3f9a0c1d2e4b5a60, template_id: 9c2e5b7a1d3f4e6a, gpus: null }] } responses: "200": description: Saved. Lists which tasks were added, updated, removed and kept. x-zh: description: "已保存。列出新增、更新、移除和保留的任务。" content: application/json: schema: { $ref: "#/components/schemas/RenterTaskOutcome" } example: { lease_id: "57", ok: true, skipped: [], added: [{ template_id: 9c2e5b7a1d3f4e6a, binding_id: 7d1e2f3a4b5c6d7e }], updated: [], removed: [], kept: [] } "400": { $ref: "#/components/responses/RenterTaskPickInvalid" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": description: '`lease_not_found`, or `template_not_found` (a template is not yours or does not exist).' x-zh: description: "`lease_not_found`,或 `template_not_found`(某个模板不属于你或不存在)。" x-codes: [lease_not_found, template_not_found] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "409": { $ref: "#/components/responses/LeaseNotRunning" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/tasks: post: tags: [Renter] operationId: batchLeaseTasks summary: Change compute tasks on several instances description: | Applies one action to 1-500 of your instances. `add` keeps each instance's tasks and adds the given templates (a template the instance already has is skipped); `replace` makes the given templates the whole list; `pause`, `resume`, `restart` act on all tasks; `clear` removes all tasks. `tasks` only with `add` / `replace`. Each instance succeeds or fails on its own: see `results[].ok` and `results[].code` (for example `lease_not_found`, `lease_not_running`, `task_gpus_invalid`). `restart` restarts every time; do not retry automatically. x-zh: summary: "批量修改多个实例的计算任务" description: "对你的 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` 每次都会重启,请不要自动重试。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write requestBody: required: true content: application/json: schema: type: object required: [lease_ids, action] properties: lease_ids: { $ref: "#/components/schemas/LeaseIds500" } action: { type: string, enum: [add, replace, pause, resume, restart, clear] } tasks: { $ref: "#/components/schemas/RenterTaskPicks" } example: { lease_ids: ["57", "58"], action: add, tasks: [{ template_id: 9c2e5b7a1d3f4e6a, gpus: null }] } responses: "200": description: One result per instance, in request order. x-zh: description: "每个实例一条结果,按请求顺序。" content: application/json: schema: type: object properties: ok: { type: boolean } results: { type: array, items: { $ref: "#/components/schemas/RenterTaskOutcome" } } example: ok: true results: - { lease_id: "57", ok: true, skipped: [], added: [{ template_id: 9c2e5b7a1d3f4e6a, binding_id: 7d1e2f3a4b5c6d7e }], updated: [], removed: [], kept: [] } - { lease_id: "58", ok: false, code: lease_not_running, skipped: [], added: [], updated: [], removed: [], kept: [] } "400": { $ref: "#/components/responses/RenterTaskPickInvalid" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/RenterTemplateNotFound" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/{lease_id}/tasks/{binding_id}/pause: post: tags: [Renter] operationId: pauseLeaseTask summary: Pause a compute task description: Stops the task and keeps it paused until you resume it. Only while the instance is `running`. x-zh: summary: "暂停计算任务" description: "停止该任务并保持暂停,直到你恢复它。仅在实例处于 `running` 时可用。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/LeaseId" - $ref: "#/components/parameters/RenterBindingId" responses: "200": { $ref: "#/components/responses/Ok" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseTaskNotFound" } "409": { $ref: "#/components/responses/LeaseNotRunning" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/{lease_id}/tasks/{binding_id}/resume: post: tags: [Renter] operationId: resumeLeaseTask summary: Resume a compute task description: Starts a paused task again. Only while the instance is `running`. x-zh: summary: "恢复计算任务" description: "重新启动已暂停的任务。仅在实例处于 `running` 时可用。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/LeaseId" - $ref: "#/components/parameters/RenterBindingId" responses: "200": { $ref: "#/components/responses/Ok" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseTaskNotFound" } "409": { $ref: "#/components/responses/LeaseNotRunning" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/{lease_id}/tasks/{binding_id}/restart: post: tags: [Renter] operationId: restartLeaseTask summary: Restart a compute task description: | Restarts the task program. **Each successful call restarts it once. Do not retry automatically.** Only while the instance is `running` and the task is not paused. x-zh: summary: "重启计算任务" description: "重启任务程序。**每次成功调用都会重启一次,请不要自动重试。**仅在实例处于 `running` 且任务未暂停时可用。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/LeaseId" - $ref: "#/components/parameters/RenterBindingId" responses: "200": { $ref: "#/components/responses/Ok" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseTaskNotFound" } "409": { $ref: "#/components/responses/LeaseTaskBusy" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/{lease_id}/tasks/{binding_id}/reinstall: post: tags: [Renter] operationId: reinstallLeaseTask summary: Download and install a compute task's package again description: | Downloads the task's program package again, installs it and restarts the task. Only for tasks that have a package; only while the instance is `running` and the task is not paused. x-zh: summary: "重新下载并安装计算任务的程序包" description: "重新下载任务的程序包、安装并重启任务。仅适用于有程序包的任务;仅在实例处于 `running` 且任务未暂停时可用。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/LeaseId" - $ref: "#/components/parameters/RenterBindingId" responses: "200": { $ref: "#/components/responses/Ok" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseTaskNotFound" } "409": description: '`lease_not_running`, `task_paused` (resume it first), or `task_no_package` (the task has no package to reinstall).' x-zh: description: "`lease_not_running`、`task_paused`(请先恢复任务),或 `task_no_package`(该任务没有可重新安装的程序包)。" x-codes: [lease_not_running, task_paused, task_no_package] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/{lease_id}/tasks/{binding_id}/log: get: tags: [Renter] operationId: getLeaseTaskLog summary: Read a compute task's log description: | Returns the latest complete log of the task. Logs are fetched on request: call `POST .../log`, then poll this endpoint until `log.req` equals the `req` you got back. `log` is null until a log has arrived. Only while the instance is `running`. x-zh: summary: "读取计算任务日志" description: "返回该任务的最新完整日志。日志按请求获取:先调用 `POST .../log`,然后轮询本接口,直到 `log.req` 等于返回的 `req`。日志到达前 `log` 为 null。仅在实例处于 `running` 时可用。" security: [{ apiKey: [renter:read] }] x-rate-limit-class: read_pg parameters: - $ref: "#/components/parameters/LeaseId" - $ref: "#/components/parameters/RenterBindingId" responses: "200": description: The latest log. Same shape as the startup command log. x-zh: description: "最新日志。形状与启动命令日志相同。" content: application/json: schema: type: object properties: ok: { type: boolean } req: { type: integer, description: 'Number of your latest log request (0 = never requested).', x-zh: {description: "你最近一次日志请求的编号(0 = 从未请求)。"} } log: type: [object, "null"] properties: req: { type: integer, description: 'The request this log answers.', x-zh: {description: "该日志对应的请求。"} } at: { type: integer } truncated: { type: boolean } error: { type: string, description: 'Empty when the log was read.', x-zh: {description: "成功读取日志时为空。"} } content: { type: string } example: ok: true req: 2 log: { req: 2, at: 1762416010, truncated: false, error: "", content: "share accepted\n" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseTaskNotFound" } "409": { $ref: "#/components/responses/LeaseNotRunning" } "429": { $ref: "#/components/responses/RateLimited" } post: tags: [Renter] operationId: requestLeaseTaskLog summary: Ask the instance for a fresh task log description: | Asks the instance to send the current log of this task. Returns the request number `req`; read the log with `GET .../log`. Only while the instance is `running` and the task is not paused. x-zh: summary: "请求实例发送最新任务日志" description: "请求实例发送该任务的当前日志。返回请求编号 `req`;通过 `GET .../log` 读取日志。仅在实例处于 `running` 且任务未暂停时可用。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/LeaseId" - $ref: "#/components/parameters/RenterBindingId" responses: "200": description: Request sent. x-zh: description: "请求已发送。" content: application/json: schema: type: object properties: ok: { type: boolean } req: { type: integer } example: { ok: true, req: 2 } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/LeaseTaskNotFound" } "409": { $ref: "#/components/responses/LeaseTaskBusy" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/tags: get: tags: [Renter] operationId: listRenterTags summary: List your instance tags description: | Your tags. Filter instances by tag with `GET /api/v1/renter/leases?tags=`. `lease_count` counts all your instances with the tag, ended ones included. x-zh: summary: "列出你的实例标签" description: "你的标签。按标签筛选实例请用 `GET /api/v1/renter/leases?tags=`。`lease_count` 统计带有该标签的你的全部实例,包括已结束的。" security: [{ apiKey: [renter:read] }] x-rate-limit-class: read_pg responses: "200": description: Tags. x-zh: description: "标签列表。" content: application/json: schema: type: object properties: items: type: array items: type: object properties: id: { type: string, description: 'Decimal string.', x-zh: {description: "十进制字符串。"} } name: { type: string } color: { type: integer, minimum: 0, maximum: 7 } lease_count: { type: integer } created_at: { type: integer } example: items: - { id: "12", name: training, color: 2, lease_count: 3, created_at: 1762000000 } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "429": { $ref: "#/components/responses/RateLimited" } post: tags: [Renter] operationId: createRenterTag summary: Create an instance tag description: | Creates a tag. `name` is 1-32 characters after trimming, unique in your account (case-insensitive); `color` is 0-7. At most 1000 tags per account. x-zh: summary: "新建实例标签" description: "新建标签。`name` 去除首尾空白后为 1-32 个字符,在你的账户内不区分大小写唯一;`color` 为 0-7。每个账户最多 1000 个标签。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write requestBody: required: true content: application/json: schema: type: object required: [name, color] properties: name: { type: string, minLength: 1, maxLength: 32 } color: { type: integer, minimum: 0, maximum: 7 } example: { name: training, color: 2 } responses: "200": description: Created. x-zh: description: "已新建。" content: application/json: schema: type: object properties: ok: { type: boolean } id: { type: string } example: { ok: true, id: "12" } "400": { $ref: "#/components/responses/RenterTagInvalid" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "409": description: '`tag_name_taken`, or `tag_limit` (1000 tags already).' x-zh: description: "`tag_name_taken`,或 `tag_limit`(已有 1000 个标签)。" x-codes: [tag_name_taken, tag_limit] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/tags/{tag_id}: patch: tags: [Renter] operationId: updateRenterTag summary: Rename or recolor an instance tag description: Send `name`, `color` or both; same rules as create. x-zh: summary: "重命名或修改实例标签颜色" description: "发送 `name`、`color` 或两者;规则与新建相同。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/RenterTagId" requestBody: required: true content: application/json: schema: type: object properties: name: { type: string, minLength: 1, maxLength: 32 } color: { type: integer, minimum: 0, maximum: 7 } example: { name: inference } responses: "200": { $ref: "#/components/responses/Ok" } "400": { $ref: "#/components/responses/RenterTagInvalid" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/RenterTagNotFound" } "409": description: '`tag_name_taken`.' x-zh: description: "`tag_name_taken`。" x-codes: [tag_name_taken] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } delete: tags: [Renter] operationId: deleteRenterTag summary: Delete an instance tag description: Deletes the tag and removes it from all your instances. x-zh: summary: "删除实例标签" description: "删除该标签,并从你的所有实例上移除。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/RenterTagId" responses: "200": { $ref: "#/components/responses/Ok" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/RenterTagNotFound" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/leases/tags: post: tags: [Renter] operationId: tagLeases summary: Add or remove tags on several instances description: | Adds (`mode: add`) or removes (`mode: remove`) 1-30 tags on 1-500 of your instances, all or nothing. An instance can have at most 30 tags; going over rejects the whole request with 409 `tag_lease_limit` and the instance's `lease_id`. Adding a tag an instance already has, or removing one it does not have, is not an error. x-zh: summary: "为多个实例添加或移除标签" description: "为你的 1-500 个实例添加(`mode: add`)或移除(`mode: remove`)1-30 个标签,要么全部成功,要么全部不做。每个实例最多 30 个标签;超出时整个请求被拒绝,返回 409 `tag_lease_limit` 并带该实例的 `lease_id`。添加实例已有的标签或移除实例没有的标签不算错误。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write requestBody: required: true content: application/json: schema: type: object required: [lease_ids, tag_ids, mode] properties: lease_ids: { $ref: "#/components/schemas/LeaseIds500" } tag_ids: type: array description: Tag IDs as decimal strings. 1-30 items; duplicates are merged. x-zh: description: "标签 ID,十进制字符串。1-30 项;重复项会合并。" minItems: 1 maxItems: 30 items: { type: string, pattern: '^[1-9][0-9]{0,17}$' } mode: { type: string, enum: [add, remove] } example: { lease_ids: ["57", "58"], tag_ids: ["12"], mode: add } responses: "200": description: Done. `n` is the number of instances (after merging duplicates). x-zh: description: "完成。`n` 为实例数(合并重复项之后)。" content: application/json: schema: type: object properties: ok: { type: boolean } n: { type: integer } example: { ok: true, n: 2 } "400": { $ref: "#/components/responses/BadRequest" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": description: '`lease_not_found` (an instance is not yours), or `tag_not_found` (a tag is not yours).' x-zh: description: "`lease_not_found`(某个实例不属于你),或 `tag_not_found`(某个标签不属于你)。" x-codes: [lease_not_found, tag_not_found] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "409": description: '`tag_lease_limit`: an instance would have more than 30 tags; `lease_id` says which.' x-zh: description: "`tag_lease_limit`:某个实例的标签将超过 30 个;`lease_id` 指出是哪一个。" x-codes: [tag_lease_limit] content: application/json: schema: allOf: - $ref: "#/components/schemas/Error" - type: object properties: lease_id: { type: string } example: { ok: false, code: tag_lease_limit, error: a lease can have at most 30 tags, lease_id: "57" } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/wallet-vars: get: tags: [Renter] operationId: listRenterWalletVars summary: List your wallets and variables description: | Your saved wallets / variables. Use `id` as `vars[].ref` or `wallet_ref` in a compute task template; the template then always uses the current `value`. `templates` lists the templates that use each one. x-zh: summary: "列出你的钱包/变量" description: "你保存的钱包/变量。在计算任务模板中把 `id` 填进 `vars[].ref` 或 `wallet_ref`,模板就始终使用当前的 `value`。`templates` 列出使用每一条的模板。" security: [{ apiKey: [renter:read] }] x-rate-limit-class: read_pg responses: "200": description: Wallets and variables. x-zh: description: "钱包/变量列表。" content: application/json: schema: type: object properties: items: { type: array, items: { $ref: "#/components/schemas/RenterWalletVar" } } example: items: - { id: 5b1c9e2d7a3f4e60, name: Pearl wallet, description: "", value: prl1qexamplewallet0000, templates: [{ id: 3f9a0c1d2e4b5a60, name: Pearl }], updated_at: 1762000000 } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "429": { $ref: "#/components/responses/RateLimited" } post: tags: [Renter] operationId: createRenterWalletVar summary: Save a wallet or variable description: | Saves a wallet address or any other value. `name` is 1-64 characters after trimming and unique in your account; `description` at most 256 characters; `value` must not be blank, at most 4 KiB, no NUL. x-zh: summary: "保存钱包/变量" description: "保存一个钱包地址或其他值。`name` 去除首尾空白后为 1-64 个字符,在你的账户内唯一;`description` 最多 256 个字符;`value` 不能为空白,最大 4 KiB,不能包含 NUL。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write requestBody: required: true content: application/json: schema: { $ref: "#/components/schemas/RenterWalletVarInput" } example: { name: Pearl wallet, description: "", value: prl1qexamplewallet0000 } responses: "200": description: Saved. x-zh: description: "已保存。" content: application/json: schema: type: object properties: ok: { type: boolean } wallet_var: { $ref: "#/components/schemas/RenterWalletVar" } example: { ok: true, wallet_var: { id: 5b1c9e2d7a3f4e60, name: Pearl wallet, description: "", value: prl1qexamplewallet0000, templates: [], updated_at: 1762000000 } } "400": { $ref: "#/components/responses/RenterWalletVarInvalid" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "409": description: '`wallet_var_name_taken`.' x-zh: description: "`wallet_var_name_taken`。" x-codes: [wallet_var_name_taken] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/renter/wallet-vars/{wallet_var_id}: put: tags: [Renter] operationId: updateRenterWalletVar summary: Change a wallet or variable description: | Replaces `name`, `description` and `value` (send all three). If `value` changed, every template that uses it is updated and running instances with those templates pick up the new value with the next heartbeat; `template_count` and `lease_count` say how many. If the new value would make an instance's tasks larger than 64 KiB, nothing is changed (400 `task_config_too_large`). x-zh: summary: "修改钱包/变量" description: "替换 `name`、`description` 和 `value`(三项都要发送)。`value` 有变化时,使用它的每个模板都会更新,使用这些模板的运行中实例随下一次心跳应用新值;`template_count` 和 `lease_count` 为相应数量。新值会使某个实例的任务超过 64 KiB 时,不做任何修改(400 `task_config_too_large`)。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/RenterWalletVarId" requestBody: required: true content: application/json: schema: { $ref: "#/components/schemas/RenterWalletVarInput" } example: { name: Pearl wallet, description: main, value: prl1qnewwallet00000000 } responses: "200": description: Saved. x-zh: description: "已保存。" content: application/json: schema: type: object properties: ok: { type: boolean } wallet_var: { $ref: "#/components/schemas/RenterWalletVar" } template_count: { type: integer, description: 'Templates whose settings changed.', x-zh: {description: "设置发生变化的模板数。"} } lease_count: { type: integer, description: 'Instances that were updated.', x-zh: {description: "已更新的实例数。"} } example: { ok: true, wallet_var: { id: 5b1c9e2d7a3f4e60, name: Pearl wallet, description: main, value: prl1qnewwallet00000000, templates: [{ id: 3f9a0c1d2e4b5a60, name: Pearl }], updated_at: 1762003600 }, template_count: 1, lease_count: 2 } "400": description: '`bad_request`, `wallet_var_invalid` (the `error` text says which field), or `task_config_too_large`.' x-zh: description: "`bad_request`、`wallet_var_invalid`(`error` 文本指出是哪个字段)或 `task_config_too_large`。" x-codes: [bad_request, wallet_var_invalid, task_config_too_large] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/RenterWalletVarNotFound" } "409": description: '`wallet_var_name_taken`.' x-zh: description: "`wallet_var_name_taken`。" x-codes: [wallet_var_name_taken] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } delete: tags: [Renter] operationId: deleteRenterWalletVar summary: Delete a wallet or variable description: | Deletes a wallet / variable that no template uses. If templates still use it you get 409 `wallet_var_in_use` with `templates`; change those templates first. x-zh: summary: "删除钱包/变量" description: "删除没有模板在用的钱包/变量。仍有模板在用时返回 409 `wallet_var_in_use` 并带 `templates`;请先修改这些模板。" security: [{ apiKey: [renter:write] }] x-rate-limit-class: write parameters: - $ref: "#/components/parameters/RenterWalletVarId" responses: "200": { $ref: "#/components/responses/Ok" } "401": { $ref: "#/components/responses/Unauthorized" } "403": { $ref: "#/components/responses/KeyForbidden" } "404": { $ref: "#/components/responses/RenterWalletVarNotFound" } "409": description: '`wallet_var_in_use`: templates still use it; `templates` lists them.' x-zh: description: "`wallet_var_in_use`:仍有模板在用;`templates` 列出这些模板。" x-codes: [wallet_var_in_use] content: application/json: schema: allOf: - $ref: "#/components/schemas/Error" - type: object properties: templates: { type: array, items: { type: object, properties: { id: { type: string }, name: { type: string } } } } example: { ok: false, code: wallet_var_in_use, error: wallet or variable is used by task templates, templates: [{ id: 3f9a0c1d2e4b5a60, name: Pearl }] } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/account/deposits: get: tags: [Renter] operationId: listDeposits summary: List your credited deposits description: | On-chain USDT deposits that have been credited, newest first. `target=rent_balance` lists deposits to your rent balance and needs `renter:read`; `target=fee_credit` lists deposits to your host service-fee balance and needs `host:read` (otherwise 403 `api_key_scope_denied`). x-zh: summary: "列出已入账的充值" description: "已入账的链上 USDT 充值,按时间倒序。`target=rent_balance` 列出充值到租金余额的记录,需要 `renter:read`;`target=fee_credit` 列出充值到出租方服务费余额的记录,需要 `host:read`(否则返回 403 `api_key_scope_denied`)。" security: [{ apiKey: [renter:read] }, { apiKey: [host:read] }] x-rate-limit-class: read_pg parameters: - $ref: "#/components/parameters/DepositTarget" - $ref: "#/components/parameters/Page" - $ref: "#/components/parameters/PageSize" responses: "200": description: One page of deposits. x-zh: description: "一页充值记录。" content: application/json: schema: type: object properties: items: type: array items: type: object properties: chain: { type: string, enum: [tron, eth, bsc] } tx_hash: { type: string } amount: { type: string } credited_at: { type: integer } total: { type: integer } example: items: - { chain: tron, tx_hash: 5f0c8a…e21b, amount: "12.77", credited_at: 1762400000 } total: 1 "400": description: '`bad_target` (`target` missing or invalid), `bad_request`.' x-zh: description: "`bad_target`(缺少 `target` 或其无效)、`bad_request`。" x-codes: [bad_target, bad_request] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "401": { $ref: "#/components/responses/Unauthorized" } "403": description: '`api_key_scope_denied` (`target=rent_balance` needs `renter:read`, `target=fee_credit` needs `host:read`), `api_key_ip_denied`, `api_key_route_not_allowed`.' x-zh: description: "`api_key_scope_denied`(`target=rent_balance` 需要 `renter:read`,`target=fee_credit` 需要 `host:read`)、`api_key_ip_denied`、`api_key_route_not_allowed`。" x-codes: [api_key_scope_denied, api_key_ip_denied, api_key_route_not_allowed] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/account/deposits/pending: get: tags: [Renter] operationId: listPendingDeposits summary: List deposits seen on chain but not credited yet description: | Up to 50 deposits that are on chain but still waiting for confirmations. `amount` is null when the on-chain amount cannot be shown exactly. Scope by `target` as in `GET /api/v1/account/deposits`. x-zh: summary: "列出链上已出现但尚未入账的充值" description: "最多 50 笔已上链但仍在等待确认的充值。无法精确显示链上金额时,`amount` 为 null。所需权限范围按 `target` 而定,同 `GET /api/v1/account/deposits`。" security: [{ apiKey: [renter:read] }, { apiKey: [host:read] }] x-rate-limit-class: read_pg parameters: - $ref: "#/components/parameters/DepositTarget" responses: "200": description: Pending deposits. x-zh: description: "待入账的充值。" content: application/json: schema: type: object properties: items: type: array items: type: object properties: chain: { type: string, enum: [tron, eth, bsc] } tx_hash: { type: string } amount: { type: [string, "null"] } seen_at: { type: integer } example: items: - { chain: bsc, tx_hash: 0x9a4e…77c1, amount: "50.00", seen_at: 1762416100 } "400": description: '`bad_target`.' x-zh: description: "`bad_target`。" x-codes: [bad_target] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "401": { $ref: "#/components/responses/Unauthorized" } "403": description: '`api_key_scope_denied` (`target=rent_balance` needs `renter:read`, `target=fee_credit` needs `host:read`), `api_key_ip_denied`, `api_key_route_not_allowed`.' x-zh: description: "`api_key_scope_denied`(`target=rent_balance` 需要 `renter:read`,`target=fee_credit` 需要 `host:read`)、`api_key_ip_denied`、`api_key_route_not_allowed`。" x-codes: [api_key_scope_denied, api_key_ip_denied, api_key_route_not_allowed] content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } "429": { $ref: "#/components/responses/RateLimited" } /api/v1/host/machines: get: tags: [Host] operationId: listHostMachines summary: List your machines description: | Lists the machines you can see: your own plus those in groups shared with you (where the owner allows API access), limited to the key's groups. Without `group` this is the "all groups" view. Pages with `page` / `per_page`; a page past the end returns the last page. Starred machines come first, then the `sort` column (empty values always last), then display name. `summary` covers all machines in scope and ignores `connectivity`, `status` and `q`. The `*_counts` fields count machines by filter value, for building filter menus. With a group-limited key, your ungrouped machines are not visible. Unknown query parameters are rejected with 400. x-zh: summary: "列出你的设备" description: |- 列出你可见的设备:你自己的设备,以及共享给你的分组中的设备(需所有者允许 API 访问),并受密钥的分组限制。不传 `group` 时为「全部分组」视图。使用 `page` / `per_page` 分页;页码超出末页时返回最后一页。星标设备排在最前,然后按 `sort` 列排序(空值始终排在最后),最后按显示名称排序。 `summary` 统计权限范围内的所有设备,不受 `connectivity`、`status` 和 `q` 影响。`*_counts` 字段按筛选值统计设备数量,用于构建筛选菜单。使用限定分组的密钥时,看不到你未分组的设备。未知的查询参数会返回 400。 security: [{ apiKey: [host:read] }] x-rate-limit-class: read parameters: - name: group in: query description: Device group ID (`id` from `GET /api/v1/host/device-groups`). Empty = all groups. x-zh: description: "分组 ID(`GET /api/v1/host/device-groups` 返回的 `id`)。为空表示全部分组。" schema: { type: string } - name: connectivity in: query schema: { type: string, enum: [online, offline] } - name: status in: query description: 'Comma-separated, any of: `available`, `rented`, `unlisted`, `unpriced`, `fault`, `noncompliant`.' x-zh: description: "逗号分隔,可选值:`available`、`rented`、`unlisted`、`unpriced`、`fault`、`noncompliant`。" schema: { type: string, example: "available,rented" } - name: reason in: query description: Only machines with this code in `status_reasons`. x-zh: description: "仅返回 `status_reasons` 中包含该代码的设备。" schema: { type: string, pattern: '^[a-z0-9_]{1,64}$' } - name: gpu in: query description: Comma-separated GPU model names (full names as in `gpus[].name`), up to 32. x-zh: description: "逗号分隔的 GPU 型号名称(与 `gpus[].name` 中的完整名称一致),最多 32 个。" schema: { type: string } - name: tag in: query description: '`none` (untagged), or comma-separated tag IDs (up to 1000).' x-zh: description: "`none`(无标签),或逗号分隔的标签 ID(最多 1000 个)。" schema: { type: string } - name: task in: query description: 'Comma-separated: `none`, or compute task template IDs (32 hex). Up to 32. A template ID also matches machines that run its debug version (pass the source template ID, not the debug version''s).' x-zh: description: "逗号分隔:`none` 或计算任务模板 ID(32 位十六进制)。最多 32 个。模板 ID 也匹配运行它调试版本的设备(传来源模板 ID,不传调试版本的 ID)。" schema: { type: string } - name: oc in: query description: 'Overclock template filter. Comma-separated: `none`, `manual`, or template IDs (32 hex). Up to 32.' x-zh: description: "超频模板筛选。逗号分隔:`none`、`manual` 或模板 ID(32 位十六进制)。最多 32 个。" schema: { type: string } - name: fan in: query description: Fan template filter. Same format as `oc`. x-zh: description: "风扇模板筛选。格式同 `oc`。" schema: { type: string } - name: price in: query description: Price template filter. Same format as `oc`. x-zh: description: "价格模板筛选。格式同 `oc`。" schema: { type: string } - name: oc_v in: query description: '`not_latest` or a version number. Needs exactly one template ID in `oc`.' x-zh: description: "`not_latest` 或版本号。要求 `oc` 中恰好有一个模板 ID。" schema: { type: string } - name: fan_v in: query description: Same as `oc_v`, for `fan`. x-zh: description: "与 `oc_v` 相同,用于 `fan`。" schema: { type: string } - name: price_v in: query description: Same as `oc_v`, for `price`. x-zh: description: "与 `oc_v` 相同,用于 `price`。" schema: { type: string } - name: algo in: query description: Only machines whose compute tasks report this algorithm. Needs advanced features. x-zh: description: "仅返回计算任务上报该算法的设备。需要高级功能。" schema: { type: string, maxLength: 64 } - name: attention in: query description: Only machines with this task problem. Needs advanced features. x-zh: description: "仅返回存在该任务问题的设备。需要高级功能。" schema: { type: string, enum: [zero_hashrate, gpu_missing, start_failed] } - name: q in: query description: Case-insensitive search in machine ID prefix, display name, hostname, worker name, alias, LAN IP, GPU model and tag names. At most 64 characters. x-zh: description: "不区分大小写,搜索设备 ID 前缀、显示名称、主机名、worker 名称、别名、局域网 IP、GPU 型号和标签名称。最多 64 个字符。" schema: { type: string, maxLength: 64 } - name: sort in: query description: Sort column, one of the listed keys or `taskHash: