API

介绍

CLORE.AI api 可用于将您的工作负载自动部署到 CLORE.AI

首先您需要获取 API 密钥 alt text alt text


API 响应

响应以 JSON 格式返回,可能包含不同字段

始终返回的字段是 code,表示状态

code 字段

代码
描述

0

正常

1

数据库错误

2

无效的输入数据

3

无效的 API 令牌

4

无效的端点

5

超过每秒 1 次请求限制

6

错误在以下字段中指定 错误 字段


端点

1. 钱包

关于

返回钱包和余额

请求头

字段
类型
必需
描述

auth

字符串

API 令牌

输出

字段
类型
描述

代码

整数

状态码

钱包

[]字符串

钱包数组

示例

输入:

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. 我的服务器

关于

返回您在提供给 的服务器 clore.ai 市场

请求头

字段
类型
必需
描述

auth

字符串

API 令牌

输出

字段
类型
描述

代码

整数

状态码

限制

整数

您可以拥有的服务器最大数量

服务器

[]字符串

服务器数组

servers[x].name

字符串

用户选择的服务器名称

servers[x].connected

字符串

该服务器是否曾连接到 clore.ai

servers[x].visibility

字符串

在市场上的可见性

servers[x].pricing

[]字符串

按需每日价格

servers[x].online

布尔值

服务器是否在线

servers[x].min_spot_pricing

[]字符串

在现货市场出租的最低每日价格

servers[x].init_token

字符串

初始化令牌

servers[x].specs

[]字符串

服务器规格

示例

输入:

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
}

*美元尚未实现

3. 服务器配置

关于

获取特定服务器的配置

请求头

字段
类型
必需
描述

auth

字符串

API 令牌

Content-type

字符串

必须为 application/json

请求体

字段
类型
必需
描述

server_name

字符串

服务器名称

输出

字段
类型
描述

代码

整数

状态码

creation_completed

布尔值

服务器创建是否完成

config

[]字符串

服务器的配置

config.name

字符串

用户选择的服务器名称

config.connected

布尔值

该服务器是否曾连接到 clore.ai

config.visibility

字符串

在市场上的可见性

config.pricing

[]字符串

按需每日价格

config.spot_pricing

[]字符串

在现货市场出租的最低每日价格

config.mrl

整数

最长租赁时长(小时)

config.online

布尔值

服务器是否在线

config.initialized

布尔值

该服务器是否曾连接到 clore.ai

config.id

整数

唯一服务器 ID

config.rental_status

整数

0 - 未出租 | 1 - 在现货市场出租 | 2 - 按需出租

config.specs

[]字符串

服务器规格

config.background_job

[]字符串

未出租时的后台任务

示例

输入:

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
}

*美元尚未实现

4. 市场

关于

获取市场

请求头

字段
类型
必需
描述

auth

字符串

API 令牌

输出

字段
类型
描述

代码

整数

状态码

我的服务器

[]字符串

您提供给 的服务器 ID 数组 clore.ai (不能被出租)

服务器

[]字符串

市场上的公开服务器数组

servers[x].id

整数

唯一服务器 ID

servers[x].owner

整数

唯一所有者 ID

servers[x].mrl

整数

最长租赁时长(小时)

servers[x].price.on_demand

[]字符串

按需每日价格

servers[x].spot

[]字符串

现货市场的最低每日价格

servers[x].rented

布尔值

服务器是否被按需出租

servers[x].specs

[]字符串

服务器规格

示例

获取市场

输入:

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. 我的订单

关于

获取您的订单

请求头

字段
类型
必需
描述

auth

字符串

API 令牌

查询字符串

字段
类型
必需
描述

return_completed

布尔值

返回已完成(过期)的订单

输出

字段
类型
描述

代码

整数

状态码

限制

整数

活动订单的最大数量

订单

[]字符串

订单数组

orders[x].id

整数

唯一订单 ID

orders[x].fee

浮点数

支付给 的费用(%) clore.ai

orders[x].creation_fee

浮点数

支付给 的创建费用 clore.ai

orders[x].price

浮点数

订单价格(每日费用)

orders[x].mrl

整数

订单最大租赁时长(秒)

orders[x].image

字符串

使用的 docker 镜像

orders[x].currency

字符串

计费使用的货币

orders[x].spend

浮点数

订单花费金额

orders[x].ct

整数

创建时间(UNIX 时间)

orders[x].p

整数

当前使用的代理集群

orders[x].specs

[]字符串

服务器规格

orders[x].si

整数

唯一服务器 ID

orders[x].pub_cluster

[]字符串

具有端口转发的公共端点

orders[x].tcp_ports

[]字符串

TCP 端口转发

orders[x].http_port

字符串

通过 HTTPS 代理转发的容器端口

orders[x].spot

布尔值

表明这是现货订单

orders[x].expired

布尔值

表明订单已过期

输入:

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. 现货市场

关于

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

请求头

字段
类型
必需
描述

auth

字符串

API 令牌

查询字符串

字段
类型
必需
描述

市场

整数

唯一服务器 ID

输出

字段
类型
描述

代码

整数

状态码

存在

布尔值

验证市场是否存在

市场

对象

市场

market.offers

数组

服务器的租赁报价

market.offers[x].offer_id

整数

唯一报价 ID

market.offers[x].bid

浮点数

所报的每日价格

market.offers[x].active

布尔值

此报价当前是否被使用

market.offers[x].my

布尔值

此报价是否由我拥有

market.server

对象

服务器信息

market.server.min_pricing

对象

最低报价每日价格

market.server.mrl

整数

最大租赁时长(秒)

market.server.visibility

字符串

只有当可见性为公开时才能创建报价

market.server.online

布尔值

服务器在线

输入:

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. 设置服务器设置

关于

配置您在 提供的服务器设置 clore.ai 市场

请求头

字段
类型
必需
描述

auth

字符串

API 令牌

Content-type

字符串

必须为 application/json

请求体

字段
类型
必需
描述

名称

字符串

用户选择的服务器名称

可用性

布尔值

服务器是否可以被出租

mrl

整数

服务器最大租赁时长

按需

浮点数

您服务器按需的每日价格

现货

浮点数

现货报价的最低每日价格

输出

字段
类型
描述

代码

整数

状态码

示例

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

输入:

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. 设置现货价格

关于

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

请求头

字段
类型
必需
描述

auth

字符串

API 令牌

Content-type

字符串

必须为 application/json

请求体

字段
类型
必需
描述

order_id

整数

唯一报价 ID

期望价格

浮点数

您所报价的每日价格

示例

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

输入 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 ₿

字段
类型
描述

代码

整数

状态码

错误

字符串

错误描述字段

max_step

浮点数

当前可将价格降低到的最低可能值

{
    "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 秒只能降低一次现货价格

字段
类型
描述

代码

整数

状态码

错误

字符串

错误描述字段

time_to_lowering

浮点数

距离下一次可降低价格的剩余时间(秒)

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

9. 取消订单

关于

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

请求头

字段
类型
必需
描述

auth

字符串

API 令牌

Content-type

字符串

必须为 application/json

请求体

字段
类型
必需
描述

id

整数

唯一订单/报价 ID

问题

字符串

如果您遇到服务器的任何问题,您可以向 团队报告,最多 2048 个字符 clore.ai 团队,最多 2048 个字符

输出

字段
类型
描述

代码

整数

状态码

示例

取消订单/报价

输入: 在此示例中,我们报告 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. 创建订单

关于

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

请求头

字段
类型
必需
描述

auth

字符串

API 令牌

Content-type

字符串

必须为 application/json

请求体

字段
类型
必需
描述

货币

字符串

货币名称

镜像

字符串

来自 Docker Hub 的有效镜像

租用服务器

整数

您想租用的服务器 ID

类型

字符串

按需现货

现货价格

浮点数

取决于

在现货市场上报价的每日价格,创建现货订单时必需

端口

对象

端口转发配置,最多 5 条记录

环境变量

对象

环境变量,在字符串化后总计限制为 12000 字符。 变量名 - 最多 128 个字符 变量值 - 最多 1536 个字符

jupyter_token

字符串

具有 Jupyter 笔记本的镜像的 Jupyter 令牌,最多 32 个字符 *

ssh_key

字符串

带有 SSH 的镜像的 SSH 密钥,最多 3072 个字符 *

ssh_password

字符串

带有 SSH 的镜像的 SSH 密码,最多 32 个字符 *

命令

字符串

订单创建后将在服务器上运行的命令

required_price

浮点数

指定您想要启动订单的价格,如果机器所有者更改价格,则订单不会启动(仅限按需)

autossh_entrypoint

布尔值

使用 clore.ai 入口点,它会自动部署 SSH 服务器和自定义 /root/onstart.sh 脚本

* 对带星号的字段,您只能输入来自此正则表达式组的字符 /^[a-zA-Z0-9\s-=.@+/]+$/

输出

字段
类型
描述

代码

整数

状态码

示例

输入 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
}

最后更新于

这有帮助吗?