> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/clore.ai/clore.ai-eng-zh/mian-xiang-zhu-ji-fang/api.md).

# API

> 💡 **Python 开发者：** 请使用官方 [clore-ai Python SDK](/clore.ai/clore.ai-eng-zh/kai-fa-zhe/python-sdk.md) ，而不是直接调用 API。它会自动处理身份验证、速率限制、重试和错误处理。
>
> **快速开始：** `pip install clore-ai` — 请查看 [Python SDK 文档](/clore.ai/clore.ai-eng-zh/kai-fa-zhe/python-sdk.md) 和 [CLI 参考](/clore.ai/clore.ai-eng-zh/kai-fa-zhe/cli-guide.md).

> 🧭 更喜欢可浏览的参考文档？请在以下地址打开交互式 API 文档： [clore.ai/api-docs](https://clore.ai/api-docs)。本页所有端点的基础 URL： `https://api.clore.ai/v1/`.

<div data-full-width="true"><figure><img src="https://1308073318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbyNlC5NV8aIpXnc76G7w%2Fuploads%2FoEhopGeayaKnbuDjgTEs%2FCLORE%20Docs%20API%20Page.png?alt=media&amp;token=a0adf6bb-1fde-4f1b-8236-dff2563ffbfd" alt=""><figcaption></figcaption></figure></div>

### 简介 <a href="#introduction" id="introduction"></a>

[CLORE.AI](http://clore.ai/) API 可用于自动化将你的工作负载部署到 [CLORE.AI](http://clore.ai/)

首先你需要获取一个 API 密钥\
![alt text](https://clore.ai/assets/html/api-export1.png)\
![alt text](https://clore.ai/assets/html/api-export2.png)

***

### API 响应 <a href="#api-responses" id="api-responses"></a>

响应以 JSON 格式返回，可能具有不同字段

始终返回的字段是 code，用于表示状态

**code 字段**

| code | 描述              |
| ---- | --------------- |
| `0`  | 正常              |
| `1`  | 数据库错误           |
| `2`  | 无效输入数据          |
| `3`  | 无效 API 令牌       |
| `4`  | 无效端点            |
| `5`  | 超过每秒 1 次请求限制    |
| `6`  | 错误位于 `error` 字段 |

***

### 端点 <a href="#endpoints" id="endpoints"></a>

#### 1. `wallets` <a href="#id-1-wallets" id="id-1-wallets"></a>

**关于**

返回钱包和余额

**请求头**

| 字段     | 类型       | 必填 | 描述     |
| ------ | -------- | -- | ------ |
| `auth` | `string` | 是  | API 令牌 |

**输出**

| 字段        | 类型         | 描述   |
| --------- | ---------- | ---- |
| `code`    | `int`      | 状态码  |
| `wallets` | `[]string` | 钱包数组 |

**示例**

**输入：**

```
curl -XGET -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' 'https://api.clore.ai/v1/wallets'
```

**输出：**

```
{
  "wallets": [
    {
      "name": "bitcoin",
      "deposit": "tb1q6erw7v02t7hakgmlcl4wfnlykzqj05alndruwr",
      "balance": 0.00153176,
      "withdrawal_fee": 0.0001
    }
  ],
  "code": 0
}
```

#### 2. `my_servers` <a href="#id-2-my_servers" id="id-2-my_servers"></a>

**关于**

返回你正在提供的服务器 [clore.ai](http://clore.ai/) 市场

**请求头**

| 字段     | 类型       | 必填 | 描述     |
| ------ | -------- | -- | ------ |
| `auth` | `string` | 是  | API 令牌 |

**输出**

| 字段                                    | 类型         | 描述                                            |
| ------------------------------------- | ---------- | --------------------------------------------- |
| `code`                                | `int`      | 状态码                                           |
| `限制`                                  | `int`      | 你可以拥有的服务器最大数量                                 |
| `servers`                             | `[]string` | 服务器数组                                         |
| `servers[x].name`                     | `string`   | 用户选择的服务器名称                                    |
| `servers[x].connected`                | `string`   | 服务器是否曾连接过 [clore.ai](http://clore.ai/)        |
| `servers[x].visibility`               | `string`   | 在市场上的可见性                                      |
| `servers[x].pricing`                  | `[]string` | 按需每日报价                                        |
| `servers[x].online`                   | `bool`     | 服务器是否在线                                       |
| `servers[x].min_spot_pricing`         | `[]string` | 在现货市场租用的最低日价格                                 |
| `servers[x].init_token`               | `string`   | 机器注册令牌，仅在机器初始化之前返回—— **请将其视为凭据**，它会将机器注册到你的账户 |
| `servers[x].specs`                    | `[]string` | 服务器规格                                         |
| `servers[x].remaining_time`           | `int`      | 最新活跃订单的租赁结束时间（毫秒时间戳）                          |
| `servers[x].rental_state`             | `string`   | GPU 租赁状态汇总： `无`, `部分`，或 `完全`                  |
| `servers[x].rented_gpus`              | `int`      | 当前在活跃订单中已租用的 GPU                              |
| `servers[x].total_gpus`               | `int`      | 服务器上的 GPU 总数                                  |
| `servers[x].rented_price_by_currency` | `object`   | 按货币键汇总的活跃订单价格总和                               |
| `servers[x].update_channel`           | `string`   | 托管代理更新通道： `稳定版` 或 `测试版`                       |
| `servers[x].requested_channel`        | `string`   | 从网页界面请求的通道切换（仅在请求时出现）                         |
| `servers[x].target_backend_version`   | `int`      | 当前通道所对应的后端版本                                  |

> 租赁状态字段（`remaining_time`, `rental_state`, `rented_gpus`, `total_gpus`, `rented_price_by_currency`）仅在服务器有活跃订单时存在。

**示例**

**输入：**

```
curl -XGET -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' 'https://api.clore.ai/v1/my_servers'
```

**输出：**

```
{
  "servers": [
    {
      "name": "Michael",
      "connected": false,
      "visibility": "hidden",
      "pricing": { "bitcoin": 0, "usd": 0 },
      "online": false,
      "min_spot_pricing": { "bitcoin": 0, "usd": 0 },
      "init_token": "qnwVIMsZPjUWS7jw6gAbTOeoGQNgTH9XVxJaiCEbG0OlmfjF"
    },
    {
      "name": "Jan Vykydal",
      "connected": true,
      "visibility": "public",
      "pricing": { "bitcoin": 0.00010337, "usd": 0 },
      "online": false,
      "min_spot_pricing": { "bitcoin": 0.00005168, "usd": 0 },
      "specs": {
        "mb": "Z590 GAMING X",
        "cpu": "Intel Core i9-11900",
        "cpus": "8/16",
        "ram": 64,
        "disk": "NVMe 512GB",
        "disk_speed": 2000,
        "gpu": "1x GeForce GTX 1080 Ti",
        "gpuram": 11,
        "net": {
          "down":119.61,
          "up":25.24
        }
      }
    }
  ],
  "limit": 16,
  "code": 0
}
```

USD 值在 `pricing` 对象中反映了主机启用的基于 USD 的定价模式。

#### 3. `server_config` <a href="#id-3-server_config" id="id-3-server_config"></a>

**关于**

获取指定服务器的配置

**请求头**

| 字段     | 类型       | 必填 | 描述                     |
| ------ | -------- | -- | ---------------------- |
| `auth` | `string` | 是  | API 令牌                 |
| `内容类型` | `string` | 是  | 必须为 `application/json` |

**请求体**

| 字段            | 类型       | 必填 | 描述    |
| ------------- | -------- | -- | ----- |
| `server_name` | `string` | 是  | 服务器名称 |

**输出**

| 字段                      | 类型                   | 描述                                                                           |
| ----------------------- | -------------------- | ---------------------------------------------------------------------------- |
| `code`                  | `int`                | 状态码                                                                          |
| `creation_completed`    | `bool`               | 服务器创建是否完成                                                                    |
| `config`                | `[]string`           | 服务器配置                                                                        |
| `config.name`           | `string`             | 用户选择的服务器名称                                                                   |
| `config.connected`      | `bool`               | 服务器是否曾连接过 [clore.ai](http://clore.ai/)                                       |
| `config.visibility`     | `string`             | 在市场上的可见性                                                                     |
| `config.pricing`        | `[]string`           | 按需每日报价                                                                       |
| `config.spot_pricing`   | `[]string`           | 在现货市场租用的最低日价格                                                                |
| `config.mrl`            | `int`                | 最大租赁时长（小时）                                                                   |
| `config.online`         | `bool`               | 服务器是否在线                                                                      |
| `config.initialized`    | `bool`               | 服务器是否曾连接过 [clore.ai](http://clore.ai/)                                       |
| `config.id`             | `int`                | 唯一服务器 ID                                                                     |
| `config.rental_status`  | `int`                | 0 - 未租用 \| 1 - 在现货市场出租 \| 2 - 按需出租 \| 3 - 固定 USD 租赁                          |
| `config.specs`          | `[]string`           | 服务器规格                                                                        |
| `config.background_job` | `object`             | 未租用时的后台任务： `image`, `command`, `env`, `times_updated`                        |
| `config.autoprice`      | `object` \| `string` | 每种货币的自动定价配置（也会出现旧版字符串值 `"pow"` / `"usd"` ）                                   |
| `config.usd_pricing`    | `object`             | USD 价格目标——仅在启用 USD 自动定价时出现                                                   |
| `config.tenants`        | `[]object`           | 服务器上的活跃订单： `rental_type`, `currency`, `price`, `remaining_time`, `gpu_count` |

> `server_config` 也会返回与 `my_servers`: `remaining_time`, `rental_state`, `rented_gpus`, `total_gpus`, `rented_price_by_currency`, `update_channel`, `requested_channel`, `target_backend_version`。在这两个端点中，租赁状态字段仅在服务器有活跃订单时存在。

**示例**

**输入：**

```
curl -XGET -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' -H "Content-type: application/json" -d '{
    "server_name":"Jan Vykydal"
}' 'https://api.clore.ai/v1/server_config'
```

**输出：**

```
{
  "config": {
    "name": "Jan Vykydal",
    "connected": true,
    "visibility": "public",
    "pricing": { "bitcoin": 0.00010337, "usd": 0 },
    "spot_pricing": { "bitcoin": 0.00005168, "usd": 0 },
    "mrl": 72,
    "online": false,
    "initialized": true,
    "id": 4,
    "rental_status": 0,
    "specs": {
      "mb": "Z590 GAMING X",
      "cpu": "Intel Core i9-11900",
      "cpus": "8/16",
      "ram": 64,
      "disk": "NVMe 512GB",
      "disk_speed": 2000,
      "gpu": "1x GeForce GTX 1080 Ti",
      "gpuram": 11,
      "net": {
        "down":119.61,
        "up":25.24
      }
    },
    "background_job": {
      "times_updated": 1,
      "image": "cloreai/ubuntu20.04-jupyter",
      "command": "",
      "env": []
    }
  },
  "creation_completed": true,
  "code": 0
}
```

USD 值在 `pricing` 对象中反映了主机启用的基于 USD 的定价模式。

#### 4. `市场` <a href="#id-4-marketplace" id="id-4-marketplace"></a>

**关于**

获取市场

**请求头**

| 字段     | 类型       | 必填 | 描述     |
| ------ | -------- | -- | ------ |
| `auth` | `string` | 是  | API 令牌 |

**输出**

| 字段                              | 类型                 | 描述                                                                |
| ------------------------------- | ------------------ | ----------------------------------------------------------------- |
| `code`                          | `int`              | 状态码                                                               |
| `my_servers`                    | `[]string`         | 你正在提供的服务器 ID 数组 [clore.ai](http://clore.ai/) （无法出租）               |
| `servers`                       | `[]string`         | 市场上的公开服务器数组                                                       |
| `servers[x].id`                 | `int`              | 唯一服务器 ID                                                          |
| `servers[x].owner`              | `int`              | 唯一所有者 ID                                                          |
| `servers[x].mrl`                | `int`              | 最大租赁时长（小时）                                                        |
| `servers[x].price.on_demand`    | `[]string`         | 按需每日价格                                                            |
| `servers[x].price.spot`         | `[]string`         | 现货市场最低日价格                                                         |
| `servers[x].rented`             | `bool`             | 服务器是否按需出租                                                         |
| `servers[x].specs`              | `[]string`         | 服务器规格                                                             |
| `servers[x].partial_gpu_rental` | `object` \| `bool` | `false` 在不支持部分租赁时为 `{ total_gpus, available_gpus, free_indices }` |

> `price.on_demand` 和 `price.spot` 只包含每台服务器实际接受的货币——如果某台服务器在某种货币下没有价格，则不能以该货币租用。

**示例**

获取市场

**输入：**

```
curl -XGET -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' 'https://api.clore.ai/v1/marketplace'
```

**输出：**

```
{
  "servers": [
    {
      "id": 6,
      "owner": 4,
      "mrl": 73,
      "price": { "on_demand": { "bitcoin": 0.00001 },
      "spot": { "bitcoin": 0.000001 }},
      "rented": false,
      "specs": {
        "mb": "Z590 GAMING X",
        "cpu": "11th Gen Intel(R) Core(TM) i9-11900 @ 2.50GHz",
        "cpus": "8/16",
        "ram": 62.67348861694336,
        "disk": "NVMe disk 247.3623046875GB",
        "disk_speed": 0,
        "gpu": "1x NVIDIA GeForce GTX 1080 Ti",
        "gpuram": 11,
        "net": {
          "up": 26.38,
          "down": 118.42,
          "cc": "CZ"
        }
      }
    }
  ],
  "my_servers": [1, 2, 4],
  "code": 0
}
```

#### 5. `my_orders` <a href="#id-5-my_orders" id="id-5-my_orders"></a>

**关于**

获取你的订单

**请求头**

| 字段     | 类型       | 必填 | 描述     |
| ------ | -------- | -- | ------ |
| `auth` | `string` | 是  | API 令牌 |

**查询字符串**

| 字段                 | 类型     | 必填 | 描述           |
| ------------------ | ------ | -- | ------------ |
| `return_completed` | `bool` | 否  | 返回已完成（已过期）订单 |

**输出**

| 字段                       | 类型         | 描述                                                     |
| ------------------------ | ---------- | ------------------------------------------------------ |
| `code`                   | `int`      | 状态码                                                    |
| `限制`                     | `int`      | 活跃订单最大数量                                               |
| `orders`                 | `[]string` | 订单数组                                                   |
| `orders[x].id`           | `int`      | 唯一订单 ID                                                |
| `orders[x].fee`          | `float`    | 支付给 [clore.ai](http://clore.ai/)                       |
| `orders[x].creation_fee` | `float`    | 支付给 [clore.ai](http://clore.ai/)                       |
| `orders[x].price`        | `float`    | 订单每日价格（成本）                                             |
| `orders[x].mrl`          | `int`      | 订单最长租赁时长（秒）                                            |
| `orders[x].image`        | `string`   | 使用的 Docker 镜像                                          |
| `orders[x].currency`     | `string`   | 用于计费的货币                                                |
| `orders[x].spend`        | `float`    | 截至目前实际扣款金额：累计租赁价值加上租用方基础费用（扣除 PoH 后）以及任何额外费用；不包括一次性创建费 |
| `orders[x].gpu_count`    | `int`      | 订单占用的 GPU 数量（按需订单；除非是部分租赁，否则等于整机的 GPU 总数）              |
| `orders[x].ct`           | `int`      | 创建时间（UNIX 时间）                                          |
| `orders[x].p`            | `int`      | 当前使用的代理集群                                              |
| `orders[x].specs`        | `[]string` | 服务器规格                                                  |
| `orders[x].si`           | `int`      | 唯一服务器 ID                                               |
| `orders[x].pub_cluster`  | `[]string` | 带端口转发的公开端点                                             |
| `orders[x].tcp_ports`    | `[]string` | TCP 端口转发                                               |
| `orders[x].http_port`    | `string`   | 通过 HTTPS 代理转发的容器端口                                     |
| `orders[x].spot`         | `bool`     | 表示这是现货订单                                               |
| `orders[x].expired`      | `bool`     | 表示订单已过期                                                |

**输入：**

```
curl -XGET -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' 'https://api.clore.ai/v1/my_orders?return_completed=true'
```

**输出：**

```
{
  "orders": [
    {
      "id": 38,
      "fee": 5,
      "creation_fee": 3e-7,
      "price": 0.00001,
      "mrl": 262800,
      "image": "cloreai/ubuntu20.04-jupyter",
      "currency": "bitcoin",
      "spend": 6.944444444444445e-9,
      "ct": 1667401396,
      "p": 1,
      "specs": {
        "mb": "Z590 GAMING X",
        "cpu": "11th Gen Intel(R) Core(TM) i9-11900 @ 2.50GHz",
        "cpus": "8/16",
        "ram": 62.67348861694336,
        "disk": "NVMe disk 247.3623046875GB",
        "disk_speed": 2000,
        "gpu": "1x NVIDIA GeForce GTX 1080 Ti",
        "gpuram": 11,
        "net": {
          "up": 26.38,
          "down": 118.42,
        }
      },
      "si": 6,
      "pub_cluster": [ "n1.c1.clorecloud.net", "n2.c1.clorecloud.net" ],
      "tcp_ports": [ "22:10000" ],
      "http_port": "8888"
    },{
      "id": 36,
      "fee": 2.5,
      "creation_fee": 1e-7,
      "price": 0.00001,
      "mrl": 262800,
      "image": "cloreai/ubuntu20.04-jupyter",
      "currency": "bitcoin",
      "spend": 1.3888888888888888e-7,
      "ct": 1667248597,
      "specs": {
        "mb": "Z590 GAMING X",
        "cpu": "11th Gen Intel(R) Core(TM) i9-11900 @ 2.50GHz",
        "cpus": "8/16",
        "ram": 62.67348861694336,
        "disk": "NVMe disk 247.3623046875GB",
        "disk_speed": 2000,
        "gpu": "1x NVIDIA GeForce GTX 1080 Ti",
        "gpuram": 11,
        "net": {
          "up": 26.38,
          "down": 118.42,
        }
      },
      "si": 6,
      "spot": true,
      "expired": true,
      "tcp_ports": []
    }
  ],
  "limit": 13,
  "code": 0
}
```

#### 6. `现货市场` <a href="#id-6-spot_marketplace" id="id-6-spot_marketplace"></a>

**关于**

获取特定服务器的现货市场

**请求头**

| 字段     | 类型       | 必填 | 描述     |
| ------ | -------- | -- | ------ |
| `auth` | `string` | 是  | API 令牌 |

**查询字符串**

| 字段   | 类型    | 必填 | 描述       |
| ---- | ----- | -- | -------- |
| `市场` | `int` | 是  | 唯一服务器 ID |

**输出**

| 字段                             | 类型       | 描述                  |
| ------------------------------ | -------- | ------------------- |
| `code`                         | `int`    | 状态码                 |
| `存在`                           | `bool`   | 验证市场是否存在            |
| `市场`                           | `object` | 市场                  |
| `market.offers`                | `数组`     | 该服务器的租赁报价           |
| `market.offers[x].offer_id`    | `int`    | 唯一报价 ID             |
| `market.offers[x].bid`         | `float`  | 报价的每日价格（以该报价的货币计）   |
| `market.offers[x].currency`    | `string` | 报价的货币               |
| `market.offers[x].active`      | `bool`   | 此报价当前正在使用           |
| `market.offers[x].my`          | `bool`   | 此报价归我所有             |
| `market.server`                | `object` | 服务器信息               |
| `market.server.min_pricing`    | `object` | 每种可接受货币的最低每日报价      |
| `market.server.mrl`            | `int`    | 最大租赁时长，以 **小时**     |
| `market.server.visibility`     | `string` | 只有在可见性为公开时才能创建报价    |
| `market.server.online`         | `bool`   | 服务器在线               |
| `market.currency_rates_in_usd` | `object` | 用于比较跨货币报价的实时 USD 汇率 |

> 报价可以使用服务器接受的任何货币；竞争报价按其 **USD 价值** （使用 `currency_rates_in_usd`），而不是面值。
>
> ⚠️ **于 2026 年 8 月更改：** `market.server.mrl` 现在以 **小时** （之前为秒）。该值读作 `262800` 现在读作 `73`.

**输入：**

```
curl -XGET -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' 'https://api.clore.ai/v1/spot_marketplace?market=6'
```

**输出：**

```
{
  "market": {
    "offers": [
      {
        "offer_id": 39,
        "bid": 0.0000042,
        "active": true,
        "my": true,
        "currency": "bitcoin"
      }
    ],
    "server": {
      "min_pricing": {
        "bitcoin": 0.000001
      },
      "mrl": 73,
      "visibility": "public",
      "online": true
    },
    "currency_rates_in_usd": {
      "bitcoin": 110000,
      "CLORE-Blockchain": 0.0045,
      "USD-Blockchain": 1
    }
  },
  "exists": true,
  "code": 0
}
```

#### 7. `set_server_settings` <a href="#id-7-set_server_settings" id="id-7-set_server_settings"></a>

**关于**

配置你提供的服务器设置 [clore.ai](http://clore.ai/) 市场

**请求头**

| 字段     | 类型       | 必填 | 描述                     |
| ------ | -------- | -- | ---------------------- |
| `auth` | `string` | 是  | API 令牌                 |
| `内容类型` | `string` | 是  | 必须为 `application/json` |

**请求体**

| 字段                           | 类型       | 必填  | 描述                                                                                                  |
| ---------------------------- | -------- | --- | --------------------------------------------------------------------------------------------------- |
| `name`                       | `string` | 是   | 用户选择的服务器名称                                                                                          |
| `availability`               | `bool`   | 是   | 服务器能否出租                                                                                             |
| `mrl`                        | `int`    | 是   | 服务器最大租赁时长，以 **小时** (6 到 3000)                                                                       |
| `bitcoin_on_demand`          | `float`  | 是   | 按需价格（BTC/天）                                                                                         |
| `bitcoin_spot`               | `float`  | 是   | 最低现货价格（BTC/天）                                                                                       |
| `CLORE-Blockchain_on_demand` | `float`  | 否   | 按需价格（CLORE/天）                                                                                       |
| `CLORE-Blockchain_spot`      | `float`  | 否   | 最低现货价格（CLORE/天）                                                                                     |
| `USD-Blockchain_on_demand`   | `float`  | 否   | 按需价格（USD/天）                                                                                         |
| `USD-Blockchain_spot`        | `float`  | 否   | 最低现货价格（USD/天）                                                                                       |
| `enabled-bitcoin`            | `bool`   | 否\* | 为此服务器接受比特币                                                                                          |
| `enabled-CLORE-Blockchain`   | `bool`   | 否\* | 为此服务器接受 CLORE                                                                                       |
| `enabled-USD-Blockchain`     | `bool`   | 否\* | 为此服务器接受 USD 稳定币                                                                                     |
| `autoprice`                  | `object` | 否   | 按货币自动定价：设置一个货币键（`bitcoin`, `CLORE-Blockchain`）为 `"usd"` 用于基于 USD 的自动定价，或 `false` 用于固定定价             |
| `usd_pricing`                | `object` | 否   | 按货币设置 USD 价格目标，例如 `{ "bitcoin": { "on_demand": 10, "spot": 5 } }` — 仅用于货币设为 `autoprice` 的情况 `"usd"` |

> \* **可接受货币列表由 `enabled-*` 标志在每次调用时重建。** 没有其 `enabled-<currency>: true` 标志（或没有有效价格）的货币会从服务器的可接受货币中移除——省略所有标志会使服务器在任何货币下都无法出租。务必为 `enabled-<currency>: true` 你希望继续接受的每种货币都发送。
>
> 每日价格按货币设有上限：BTC 0.000001–0.1，CLORE 0.1–5,000,000，USD 0.1–10,000。
>
> 当某种货币以 USD 自动定价时，其列出的加密货币价格取自 `usd_pricing` 按实时汇率（约每 10 分钟重新计算）以及任何 `<currency>_on_demand` / `<currency>_spot` 为它发送的值会被忽略。 `usd_pricing` 目标值是整台服务器的 $/天 数值，并按 USD 范围（0.1–1,000）验证；超出范围的值会被限制到最近的边界。

**输出**

| 字段     | 类型    | 描述  |
| ------ | ----- | --- |
| `code` | `int` | 状态码 |

**示例**

让我们为从当前钱包发送的交易创建一个发送证明。

**输入：**

```
curl -XPOST -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' -H "Content-type: application/json" -d '{
    "name": "Jan Vykydal",
    "availability":true,
    "mrl":96,
    "enabled-bitcoin":true,
    "bitcoin_on_demand":0.0001,
    "bitcoin_spot":0.00000113
}' 'https://api.clore.ai/v1/set_server_settings'
```

**输出：**

```
{
  "code": 0
}
```

#### 8. `设置现货价格` <a href="#id-8-set_spot_price" id="id-8-set_spot_price"></a>

**关于**

为你的现货市场报价设置每日价格

**请求头**

| 字段     | 类型       | 必填 | 描述                     |
| ------ | -------- | -- | ---------------------- |
| `auth` | `string` | 是  | API 令牌                 |
| `内容类型` | `string` | 是  | 必须为 `application/json` |

**请求体**

| 字段              | 类型      | 必填 | 描述       |
| --------------- | ------- | -- | -------- |
| `order_id`      | `int`   | 是  | 唯一报价 ID  |
| `desired_price` | `float` | 是  | 你的每日报价价格 |

> **低于服务器当前现货底价的价格** 会被拒绝，并附上当前最低价：
>
> ```
> { "error": "amount_too_low", "min_price": 0.0000012, "code": 6 }
> ```

**示例**

让我们尝试更新现货市场价格

**输入 1（降价幅度太大）：**

```
curl -XPOST -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' -H "Content-type: application/json" -d '{
    "order_id":39,
    "desired_price":0.00000200
}' 'https://api.clore.ai/v1/set_spot_price'
```

**可能的输出 1（降价幅度太大）：**\
你可以最多将现货市场报价价格下调 0.00000100 ₿

| 字段         | 类型       | 描述             |
| ---------- | -------- | -------------- |
| `code`     | `int`    | 状态码            |
| `error`    | `string` | 错误描述字段         |
| `max_step` | `float`  | 你当前可下调价格的最低可能值 |

```
{
    "error":"exceeded_max_step",
    "max_step":0.0000032,
    "code":6
}
```

**输入 2（有效的降价幅度）：**

```
curl -XPOST -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' -H "Content-type: application/json" -d '{
    "order_id":39,
    "desired_price":0.00000320
}' 'https://api.clore.ai/v1/set_spot_price'
```

**可能的输出 2（有效的降价幅度）：**

```
{
    "code": 0
}
```

**输入 3（在发送输入 2 后进一步降价）：**

```
curl -XPOST -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' -H "Content-type: application/json" -d '{
    "order_id":39,
    "desired_price":0.00000220
}' 'https://api.clore.ai/v1/set_spot_price
```

**可能的输出 3（在发送输入 2 后进一步降价）：**\
你可以每 600 秒下调一次现货价格

| 字段                 | 类型       | 描述                 |
| ------------------ | -------- | ------------------ |
| `code`             | `int`    | 状态码                |
| `error`            | `string` | 错误描述字段             |
| `time_to_lowering` | `float`  | 到下一次可以下调价格的剩余时间（秒） |

```
{
    "error":"can_lower_every_600_seconds",
    "time_to_lowering":513,
    "code":6
}
```

#### 9. `cancel_order` <a href="#id-9-cancel_order" id="id-9-cancel_order"></a>

**关于**

取消一个活跃订单或现货报价

**请求头**

| 字段     | 类型       | 必填 | 描述                     |
| ------ | -------- | -- | ---------------------- |
| `auth` | `string` | 是  | API 令牌                 |
| `内容类型` | `string` | 是  | 必须为 `application/json` |

**请求体**

| 字段      | 类型       | 必填 | 描述                                                               |
| ------- | -------- | -- | ---------------------------------------------------------------- |
| `id`    | `int`    | 是  | 唯一订单/报价 ID                                                       |
| `issue` | `string` | 否  | 如果你遇到了服务器的任何问题，可以向 [clore.ai](http://clore.ai/) 团队报告，最多 2048 个字符 |

**输出**

| 字段     | 类型    | 描述  |
| ------ | ----- | --- |
| `code` | `int` | 状态码 |

**示例**

取消订单/报价

**输入：**\
在此示例中，我们报告的是 GPU #1 的问题；如果你没有问题，请不要包含 issue 字段。\
你可以在 text 字段中写任何消息，我们会进行调查

```
curl -XPOST -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' -H "Content-type: application/json" -d '{
    "id":39,
    "issue":"GPU #1 Was overheating and throttling"
}' 'https://api.clore.ai/v1/cancel_order'
```

**输出：**

```
{
  "code": 0
}
```

#### 10. `create_order` <a href="#id-10-create_order" id="id-10-create_order"></a>

**关于**

你可以使用此端点创建现货报价或按需订单

**请求头**

| 字段     | 类型       | 必填 | 描述                     |
| ------ | -------- | -- | ---------------------- |
| `auth` | `string` | 是  | API 令牌                 |
| `内容类型` | `string` | 是  | 必须为 `application/json` |

**请求体**

| 字段                   | 类型       | 必填  | 描述                                                                                                                         |
| -------------------- | -------- | --- | -------------------------------------------------------------------------------------------------------------------------- |
| `currency`           | `string` | 是   | 货币名称                                                                                                                       |
| `image`              | `string` | 是   | 来自 dockerhub 的有效镜像                                                                                                         |
| `renting_server`     | `int`    | 是   | 你想租用的服务器 ID                                                                                                                |
| `type`               | `string` | 是   | `按需` 或 `现货`                                                                                                                |
| `spotprice`          | `float`  | 取决于 | 创建现货订单时必填的现货市场每日报价价格                                                                                                       |
| `ports`              | `object` | 否   | 端口转发配置，最多 5 条记录                                                                                                            |
| `env`                | `object` | 否   | <p>环境变量，转为字符串后总长度限制为 12288 个字符。<br>变量名 - 最多 128 个符号，不能包含 <code>-</code><br>变量值 - 最多 1536 个符号<br>仅保留前 30 个有效变量；其余会被静默丢弃</p> |
| `jupyter_token`      | `string` | 否   | 用于包含 jupyter notebook 的镜像的 Jupyter 令牌，最多 32 个字符 \*                                                                         |
| `ssh_key`            | `string` | 否   | 用于带 SSH 的镜像的 SSH 密钥，最多 3072 个字符 \*                                                                                         |
| `ssh_password`       | `string` | 否   | 用于带 SSH 的镜像的 SSH 密码，最多 32 个字符 \*                                                                                           |
| `command`            | `string` | 否   | 订单创建后将在服务器上运行命令                                                                                                            |
| `required_price`     | `float`  | 否   | 指定你希望以何种价格启动订单；如果机器所有者更改价格，则订单不会启动（仅按需）                                                                                    |
| `gpu_count`          | `int`    | 否   | 要在支持部分租用的服务器上租用的 GPU 数量 [部分租用](/clore.ai/clore.ai-eng-zh/mian-xiang-zu-ke/partial-gpu-rental.md)。省略则租用整台设备。仅按需，仅限同构设备      |
| `gpu_indices`        | `[]int`  | 否   | 要租用的从 0 开始的 GPU 插槽索引；长度必须等于 `gpu_count`。从 `partial_gpu_rental.free_indices`中取空闲插槽。省略则让后端自动选择空闲 GPU                         |
| `autossh_entrypoint` | `bool`   | 否   | 使用 clore.ai 入口点，它会自动部署 SSH 服务器和自定义 `/root/onstart.sh` 脚本                                                                   |

带星号标记的字段只能输入此正则组中的字符 `/^[a-zA-Z0-9\\s-=.@+/]+$/`

**输出**

| 字段     | 类型    | 描述  |
| ------ | ----- | --- |
| `code` | `int` | 状态码 |

> **低于服务器底价的现货报价** 会被拒绝，并附上当前最低价，因此你可以立即重试：
>
> ```
> { "error": "too_low_price", "min_price": 0.0000012, "code": 6 }
> ```
>
> 底价大约每 10 分钟根据实时币价重新计算一次，因此从市场列表读到的价格可能会略有过时——务必使用返回的 `min_price` 进行重试。

**示例**

**输入 1（创建现货报价）：**

```
curl -XPOST -H 'auth: 6FcuR7ibcwKR1Z32lEFoSotzUUtzKO2H' -H "Content-type: application/json" -d '
{
    "currency":"bitcoin",
    "image":"cloreai/ubuntu20.04-jupyter",
    "renting_server":6,
    "type":"spot",
    "spotprice":0.000001,
    "ports":{
        "22":"tcp",
        "8888":"http"
    },
    "env":{
        "VARIABLE_NAME":"VARIABLE_VALUE",
    },
    "jupyter_token":"hoZluOjbCOQ5D5yH7R",
    "ssh_password":"Hpcj08ZaOpCbTmn1Eu",
    "command":"#!/bin/sh\napt update -y && apt install htop"
}' 'https://api.clore.ai/v1/create_order'
```

**输出 1（创建现货报价）：**

```
{
  "code":0
}
```

**输入 2（创建按需订单）：**

```
curl -XPOST -H 'auth: 6FcuR7ibcwKR1Z32lEFoSotzUUtzKO2H' -H "Content-type: application/json" -d '
{
    "currency":"bitcoin",
    "image":"cloreai/ubuntu20.04-jupyter",
    "renting_server":6,
    "type":"on-demand",
    "ports":{
        "22":"tcp",
        "8888":"http"
    },
    "env":{
        "VARIABLE_NAME":"VARIABLE_VALUE",
    },
    "jupyter_token":"hoZluOjbCOQ5D5yH7R",
    "ssh_password":"Hpcj08ZaOpCbTmn1Eu",
    "command":"#!/bin/sh\napt update -y && apt install htop"
}' 'https://api.clore.ai/v1/create_order'
```

**输出 2（创建按需订单）：**

```
{
  "code":0
}
```

#### 11. `renter_fees` <a href="#id-11-renter_fees" id="id-11-renter_fees"></a>

**关于**

获取当前费用配置：基础租客费用、PoH 费用减免设置、订单创建费用以及你的 PoH 余额

**请求头**

| 字段     | 类型       | 必填 | 描述     |
| ------ | -------- | -- | ------ |
| `auth` | `string` | 是  | API 令牌 |

**输出**

| 字段                                 | 类型       | 描述                    |
| ---------------------------------- | -------- | --------------------- |
| `code`                             | `int`    | 状态码                   |
| `renter_fees.on_demand`            | `object` | 按需订单的各货币基础费用（%）       |
| `renter_fees.spot`                 | `object` | 现货订单的各货币基础费用（%）       |
| `poh_config.max_reduction_percent` | `int`    | 通过 PoH 获得的最大基础费用减免（%） |
| `poh_config.max_poh_amount`        | `int`    | 达到最大减免时的 PoH 余额       |
| `creation_fees.on_demand`          | `object` | 每种货币的订单创建费用           |
| `creation_fees.spot`               | `object` | 每种货币的现货订单创建费用         |
| `poh_balance`                      | `float`  | 你的 PoH CLORE 余额       |

**输入：**

```
curl -XGET -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' 'https://api.clore.ai/v1/renter_fees'
```

**输出：**

```
{
  "renter_fees": {
    "on_demand": {
      "base": { "bitcoin": 5, "CLORE-Blockchain": 5, "USD-Blockchain": 5 }
    },
    "spot": {
      "base": { "bitcoin": 1.25, "CLORE-Blockchain": 1.25, "USD-Blockchain": 1.25 }
    }
  },
  "poh_config": { "max_reduction_percent": 50, "max_poh_amount": 2000000 },
  "creation_fees": {
    "on_demand": { "bitcoin": 3e-7, "CLORE-Blockchain": 0.5, "USD-Blockchain": 0.1 },
    "spot": { "bitcoin": 1e-7, "CLORE-Blockchain": 0.05, "USD-Blockchain": 0.005 }
  },
  "poh_balance": 5000,
  "code": 0
}
```

#### 12. `cancel_orders` <a href="#id-12-cancel_orders" id="id-12-cancel_orders"></a>

**关于**

一次取消多个订单（每次请求最多 256 个）

**请求头**

| 字段     | 类型       | 必填 | 描述                     |
| ------ | -------- | -- | ---------------------- |
| `auth` | `string` | 是  | API 令牌                 |
| `内容类型` | `string` | 是  | 必须为 `application/json` |

**请求体**

| 字段          | 类型      | 必填 | 描述                 |
| ----------- | ------- | -- | ------------------ |
| `order_ids` | `[]int` | 是  | 要取消的订单 ID，最多 256 个 |

**输出**

| 字段                 | 类型      | 描述         |
| ------------------ | ------- | ---------- |
| `code`             | `int`   | 状态码        |
| `failed_to_cancel` | `[]int` | 无法取消的订单 ID |

**输入：**

```
curl -XPOST -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' -H "Content-type: application/json" -d '{
    "order_ids": [38, 39]
}' 'https://api.clore.ai/v1/cancel_orders'
```

**输出：**

```
{
  "failed_to_cancel": [],
  "code": 0
}
```

#### 13. `poh_balance` <a href="#id-13-poh_balance" id="id-13-poh_balance"></a>

**关于**

获取你的持有证明余额：项目、总额，以及 PoH Marketplace 报价金额

**请求头**

| 字段     | 类型       | 必填 | 描述     |
| ------ | -------- | -- | ------ |
| `auth` | `string` | 是  | API 令牌 |

**输出**

| 字段                                            | 类型         | 描述             |
| --------------------------------------------- | ---------- | -------------- |
| `code`                                        | `int`      | 状态码            |
| `items`                                       | `[]object` | 你的 PoH 项目及各自余额 |
| `balance.total`                               | `float`    | 所有项目的 PoH 总余额  |
| `balance.free_amount`                         | `float`    | 未被报价锁定的 PoH 余额 |
| `balance.reward_amount`                       | `float`    | 符合奖励资格的余额      |
| `balance.offers.rented_amount`                | `float`    | 出租给其他用户的金额     |
| `balance.offers.rented_on_marketplace_amount` | `float`    | 在 PoH 市场上列出的金额 |
| `balance.offers.leased_amount`                | `float`    | 从其他用户租用的金额     |

**输入：**

```
curl -XGET -H 'auth: b8qwqRAL5W7YDyDJeB4XANVvKndbrrPk' 'https://api.clore.ai/v1/poh_balance'
```

**输出：**

```
{
  "items": [ { "balance": 5000 } ],
  "balance": {
    "total": 5000,
    "free_amount": 4000,
    "reward_amount": 5000,
    "offers": {
      "rented_amount": 0,
      "rented_on_marketplace_amount": 1000,
      "rented_finished_amount": 0,
      "leased_amount": 0
    }
  },
  "code": 0
}
```

#### 14. `server-config.json` <a href="#id-14-server-config-json" id="id-14-server-config-json"></a>

**关于**

获取静态 API 配置数据。无需身份验证

**输入：**

```
curl -XGET 'https://api.clore.ai/v1/server-config.json'
```

#### 15. `get_relay` <a href="#id-15-get_relay" id="id-15-get_relay"></a>

**关于**

获取适用于您检测到的国家的 TCP 转发中继节点。无需身份验证

**输出**

| 字段        | 类型       | 描述       |
| --------- | -------- | -------- |
| `code`    | `int`    | 状态码      |
| `country` | `string` | 检测到的国家代码 |
| `nodes`   | `object` | 可用的中继节点  |

**输入：**

```
curl -XGET 'https://api.clore.ai/v1/get_relay'
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.clore.ai/clore.ai/clore.ai-eng-zh/mian-xiang-zhu-ji-fang/api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
