> 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-ti-gong-zhe/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="/files/b6f33201d600a5b2eaf90783bf185d7925476c8e" 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`  | 错误详见 `错误` 字段 |

***

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

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

**关于**

返回钱包和余额

**请求头**

| 字段     | 类型    | 必填 | 描述     |
| ------ | ----- | -- | ------ |
| `auth` | `字符串` | 是  | 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` | `字符串` | 是  | API 令牌 |

**输出**

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

**示例**

**输入：**

```
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 计的值在 `定价` 对象反映主机启用时的基于 USD 的定价模式。

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

**关于**

获取特定服务器的配置

**请求头**

| 字段             | 类型    | 必填 | 描述                     |
| -------------- | ----- | -- | ---------------------- |
| `auth`         | `字符串` | 是  | API 令牌                 |
| `Content-Type` | `字符串` | 是  | 必须为 `application/json` |

**正文**

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

**输出**

| 字段                      | 类型         | 描述                                                                  |
| ----------------------- | ---------- | ------------------------------------------------------------------- |
| `code`                  | `int`      | 状态码                                                                 |
| `creation_completed`    | `bool`     | 服务器创建是否完成                                                           |
| `config`                | `[]string` | 服务器配置                                                               |
| `config.name`           | `字符串`      | 用户选择的服务器名称                                                          |
| `config.connected`      | `bool`     | 该服务器是否曾连接到 [clore.ai](http://clore.ai/)                             |
| `config.visibility`     | `字符串`      | 市场可见性                                                               |
| `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 - 按需出租                                  |
| `config.specs`          | `[]string` | 服务器规格                                                               |
| `config.background_job` | `[]string` | 未出租时的后台任务                                                           |
| `config.tenants`        | `[]object` | 服务器上的活跃订单： `rental_type`, `货币`, `价格`, `remaining_time`, `gpu_count` |

> `server_config` 也返回相同的 rental-state 和 update-channel 字段 `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 计的值在 `定价` 对象反映主机启用时的基于 USD 的定价模式。

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

**关于**

获取市场

**请求头**

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

**输出**

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

**示例**

获取市场

**输入：**

```
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` | `字符串` | 是  | API 令牌 |

**查询字符串**

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

**输出**

| 字段                       | 类型         | 描述                                      |
| ------------------------ | ---------- | --------------------------------------- |
| `code`                   | `int`      | 状态码                                     |
| `限制`                     | `int`      | 活跃订单的最大数量                               |
| `订单`                     | `[]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`        | `字符串`      | 使用的 Docker 镜像                           |
| `orders[x].currency`     | `字符串`      | 用于计费的货币                                 |
| `orders[x].spend`        | `float`    | 订单花费金额                                  |
| `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`    | `字符串`      | 通过 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. `spot_marketplace` <a href="#id-6-spot_marketplace" id="id-6-spot_marketplace"></a>

**关于**

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

**请求头**

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

**查询字符串**

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

**输出**

| 字段                          | 类型       | 描述                |
| --------------------------- | -------- | ----------------- |
| `code`                      | `int`    | 状态码               |
| `存在`                        | `bool`   | 验证市场是否存在          |
| `market`                    | `object` | 市场                |
| `market.offers`             | `数组`     | 服务器租赁报价           |
| `market.offers[x].offer_id` | `int`    | 唯一报价 ID           |
| `market.offers[x].bid`      | `float`  | 每日报价              |
| `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`  | `字符串`    | 仅当可见性为公开时，你才能创建报价 |
| `market.server.online`      | `bool`   | 服务器在线             |

**输入：**

```
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
      }
    ],
    "server": {
      "min_pricing": {
        "bitcoin": 0.000001
      },
      "mrl": 262800,
      "visibility": "public",
      "online": true
    }
  },
  "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`         | `字符串` | 是  | API 令牌                 |
| `Content-Type` | `字符串` | 是  | 必须为 `application/json` |

**正文**

| 字段    | 类型      | 必填 | 描述            |
| ----- | ------- | -- | ------------- |
| `名称`  | `字符串`   | 是  | 用户选择的服务器名称    |
| `可用性` | `bool`  | 是  | 服务器是否可出租      |
| `mrl` | `int`   | 是  | 服务器最长租赁时长     |
| `按需`  | `float` | 是  | 你的服务器按需每日价格   |
| `现货`  | `float` | 是  | SPOT 报价的最低日价格 |

> 每日价格上限为 0.015 BTC / 600,000 CLORE / 1,000 USD。

**输出**

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

**示例**

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

**输入：**

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

**输出：**

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

#### 8. `set_spot_price` <a href="#id-8-set_spot_price" id="id-8-set_spot_price"></a>

**关于**

在您的 SPOT 市场报价中设置每日价格

**请求头**

| 字段             | 类型    | 必填 | 描述                     |
| -------------- | ----- | -- | ---------------------- |
| `auth`         | `字符串` | 是  | API 令牌                 |
| `Content-Type` | `字符串` | 是  | 必须为 `application/json` |

**正文**

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

**示例**

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

**输入 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`   | 状态码              |
| `错误`       | `字符串`   | 错误描述字段           |
| `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`   | 状态码              |
| `错误`               | `字符串`   | 错误描述字段           |
| `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`         | `字符串` | 是  | API 令牌                 |
| `Content-Type` | `字符串` | 是  | 必须为 `application/json` |

**正文**

| 字段   | 类型    | 必填 | 描述                                                                  |
| ---- | ----- | -- | ------------------------------------------------------------------- |
| `id` | `int` | 是  | 唯一的订单/报价 ID                                                         |
| `问题` | `字符串` | 否  | 如果您在服务器方面遇到任何问题，可以将其报告给 [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 过热并降频"
}' 'https://api.clore.ai/v1/cancel_order'
```

**输出：**

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

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

**关于**

您可以使用此端点创建现货报价或按需订单\
此端点也只允许每 5 秒 1 次请求

**请求头**

| 字段             | 类型    | 必填 | 描述                     |
| -------------- | ----- | -- | ---------------------- |
| `auth`         | `字符串` | 是  | API 令牌                 |
| `Content-Type` | `字符串` | 是  | 必须为 `application/json` |

**正文**

| 字段                   | 类型       | 必填  | 描述                                                                                                                            |
| -------------------- | -------- | --- | ----------------------------------------------------------------------------------------------------------------------------- |
| `货币`                 | `字符串`    | 是   | 货币名称                                                                                                                          |
| `镜像`                 | `字符串`    | 是   | 来自 dockerhub 的有效镜像                                                                                                            |
| `renting_server`     | `int`    | 是   | 您想租用的服务器 ID                                                                                                                   |
| `类型`                 | `字符串`    | 是   | `按需` 或 `现货`                                                                                                                   |
| `spotprice`          | `float`  | 取决于 | 现货市场上的每日报价价格，创建现货订单时必填                                                                                                        |
| `ports`              | `object` | 否   | 端口转发配置，最多 5 条记录                                                                                                               |
| `env`                | `object` | 否   | <p>环境变量，字符串化后总计限制为 12000 个字符。<br>变量名 - 最多 128 个符号<br>变量值 - 最多 1536 个符号</p>                                                    |
| `jupyter_token`      | `字符串`    | 否   | 用于包含 jupyter notebooks 的镜像的 Jupyter 令牌，最多 32 个字符 \*                                                                           |
| `ssh_key`            | `字符串`    | 否   | 用于包含 SSH 的镜像的 SSH 密钥，最多 3072 个字符 \*                                                                                           |
| `ssh_password`       | `字符串`    | 否   | 用于包含 SSH 的镜像的 SSH 密码，最多 32 个字符 \*                                                                                             |
| `command`            | `字符串`    | 否   | 订单创建后，命令将在服务器上运行                                                                                                              |
| `required_price`     | `float`  | 否   | 指定您希望订单开始时的价格，如果机器所有者更改了价格，则订单不会启动（仅按需）                                                                                       |
| `gpu_count`          | `int`    | 否   | 在支持以下功能的服务器上要租用的 GPU 数量 [部分租赁](/clore.ai/clore.ai-eng-zh/mian-xiang-zu-yong-zhe/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` | 状态码 |

**示例**

**输入 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` | `字符串` | 是  | 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`         | `字符串` | 是  | API 令牌                 |
| `Content-Type` | `字符串` | 是  | 必须为 `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 市场报价金额

**请求头**

| 字段     | 类型    | 必填 | 描述     |
| ------ | ----- | -- | ------ |
| `auth` | `字符串` | 是  | 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` | `字符串`    | 检测到的国家代码 |
| `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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
