鉴权示例
API 接口调用地址:
https://api-v1.huixingyun.com/在进行接口请求时,所有请求需通过Token进行身份验证。在HTTP请求头中加入
Authorization字段,其值设为Token字符串。Authorization: "token"请求示例
curl -X "POST" "https://api-v1.huixingyun.com/gpu/images/mine" \
-H 'Content-Type: application/json' \
-H 'Authorization: 2292c8da-bac5-****-****-2cd2e6a0ae30' \
-d $'{
"room_name": "105"
}'
Token管理
生成Token
为了获取用于API调用的Token,用户需要通过以下接口提交用户名、密码以及自定义的Token名称。
请求
POST
/generate/token请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| username | 是 | String | 账号用户名 |
| password | 是 | String | 账号密码 |
| name | 是 | String | 自定义的Token名称,用于标识Token的用途或角色 |
请求示例
curl --location 'https://api-v1.huixingyun.com/generate/token' \
--header 'Content-Type: application/json' \
--data '{
"username":"xxxxxx",
"password":"xxxxx",
"name":"管理token"
}
'返回示例
{
"token": {
"name": "管理token",
"scope": "global",
"status": "active",
"token": "edfb5419-****-****-9093-42c7f731bad1",
"update_at": "2024-06-21T11:22:44+08:00",
"create_at": "2024-06-21T11:22:44+08:00"
}
}
删除Token
当Token不再需要时,用户可以通过以下接口删除指定的Token。
请求
POST
/delete/token请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| username | 是 | String | 账号用户名 |
| password | 是 | String | 账号密码 |
| token | 是 | String | 要删除的Token值(多个用逗号分隔) |
请求示例
curl --location 'https://api-v1.huixingyun.com/delete/token' \
--header 'Content-Type: application/json' \
--data '{
"username":"xxxxxx",
"password":"xxxxxx",
"token":"11b34725-xxxx-xxxx-xxxx-fc02a3630c21"
}
'返回示例
{"success":true}查询所有Token
用户可以查询自己账号下所有的Token信息。
请求
POST
/all/tokens请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| username | 是 | String | 用户名 |
| password | 是 | String | 密码 |
返回示例
{
"tokens": [
{
"name": "管理员",
"scope": "global",
"status": "active",
"token":"11b34725-xxxx-xxxx-xxxx-fc02a3630c21",
"create_at": "2024-06-21T11:27:33+08:00",
"update_at": "2024-06-21T11:27:33+08:00"
},
{
"name": "管理员",
"scope": "global",
"status": "active",
"token":"11b34725-xxxx-xxxx-xxxx-fc02a3630c21",
"create_at": "2024-06-21T11:28:48+08:00",
"update_at": "2024-06-21T11:28:48+08:00"
}
// 更多Token信息...
]
}
GPU 实例管理
获取 GPU 云主机列表
查询所有的 GPU 云主机产品
请求
POST
/gpu/product/list请求参数
无
返回参数
| 参数名称 | 描述 |
| name | GPU 型号 |
| gpu_type | GPU 实例类型 |
| disk_cap | 可扩容磁盘的大小 |
| memory | 内存大小 |
| cpu | cpu核数 |
| room_name | 归属区 |
| gpu_remain | 单次下单可租用的 GPU 最大张数 |
| disk_one | 系统盘大小,默认60GB |
| disk_data_one | 数据盘大小,默认100GB |
| gpu_ram | GPU显存 |
返回示例
{
"items": [
{
"name": "NVIDIA 4090 免费版",
"gpu_type": "geforce_rtx_4090_free_102",
"disk_cap": 1340,
"memory": 90,
"cpu": 16,
"room_name": "102",
"gpu_remain": 1,
"disk_one": 60,
"disk_data_one": 100,
"gpu_ram": 24
},
{
"name": "NVIDIA 4090",
"gpu_type": "geforce_rtx_4090_16u100m_106",
"disk_cap": 4000,
"memory": 100,
"cpu": 16,
"room_name": "106",
"gpu_remain": 8,
"disk_one": 60,
"disk_data_one": 100,
"gpu_ram": 24
},
{
"name": "NVIDIA 4090",
"gpu_type": "geforce_rtx_4090_16u60m_106",
"disk_cap": 4000,
"memory": 60,
"cpu": 16,
"room_name": "106",
"gpu_remain": 8,
"disk_one": 60,
"disk_data_one": 100,
"gpu_ram": 24
}
],
"total_items": 3获取应用列表
查询所有的GPU应用产品
请求
POST
/gpu/application/list请求参数
无
返回参数
除了包含GPU云主机列表中的参数外,还包括以下参数:
| 参数名称 | 描述 |
| app_type | GPU 应用类型 |
| memory | 内存大小 |
| cpu | cpu核数 |
| disk_one | 系统盘大小,默认60GB |
| disk_data_one | 数据盘大小,默认100GB |
| title | GPU 应用命名 |
返回示例
{
"items": [
{
"app_type": "sd-webui",
"memory": 100,
"cpu": 16,
"disk_one": 60,
"disk_data_one": 100,
"title": "Stable Diffusion WebUI"
},
{
"app_type": "comfyui",
"memory": 100,
"cpu": 16,
"disk_one": 60,
"disk_data_one": 100,
"title": "ComfyUI"
},
{
"app_type": "fooocus",
"memory": 100,
"cpu": 16,
"disk_one": 60,
"disk_data_one": 100,
"title": "Fooocus"
},
{
"app_type": "rvc-webui",
"memory": 100,
"cpu": 16,
"disk_one": 60,
"disk_data_one": 100,
"title": "RVC WebUI"
},
{
"app_type": "openwebui",
"memory": 100,
"cpu": 16,
"disk_one": 60,
"disk_data_one": 100,
"title": "Open WebUI"
},
{
"app_type": "comfyui-clay",
"memory": 100,
"cpu": 16,
"disk_one": 60,
"disk_data_one": 100,
"title": "ComfyUI-Clay"
}
],
"total_items": 6
}查询镜像
查询公共镜像
请求
POST
/gpu/images/list请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| gpu_type | 是 | String | GPU 实例类型 |
返回参数
| 参数名称 | 描述 |
| name | 镜像名称 |
| image_id | 镜像id |
| scene | 使用场景 |
| os | 操作系统 |
| description | 镜像描述,预安装的软件和依赖 |
| room_name | 归属区 |
返回示例
{
"items": [
{
"name": "app-openwebui_20240525",
"image_id": "0917a7f0-1c03-11ef-9f0d-4faf337438da",
"scene": "Gpu",
"os": "linux",
"description": "ubuntu 22.04, nvidia_driver 535.161.08, miniconda py310_23.11.0-2, jupyterlab 4.1.2, filebrowser 2.27.0, Ollama 0.1.32, ComfyUI 18c151b, OpenWebUI 0.1.123,",
"room_name": "105"
},
// 更多镜像信息...
],
"total_items": 5
}
查询自定义镜像
查询自定义镜像
请求
POST
/gpu/images/mine请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| room_name | 是 | String | 区 |
返回参数
| 参数名称 | 描述 |
| name | 镜像名称 |
| image_id | 镜像id |
| scene | 使用场景 |
| os | 操作系统 |
| description | 镜像描述,预安装的软件和依赖 |
| room_name | 归属区 |
返回示例
{
"items": [
{
"name": "镜像1",
"image_id": "9b2b140e-8d2c-xxxx-xxxx-78ecb2a1ac9b",
"scene": "Gpu",
"os": "linux",
"description": "创建时间: 2024-06-20 17:46:58",
"room_name": "105"
},
{
"name": "镜像2",
"image_id": "1b66a8fb-8708-xxxx-xxxx-9714585ec6b2",
"scene": "Gpu",
"os": "linux",
"description": "创建时间: 2024-06-20 18:53:24",
"room_name": "105"
}
],
"total_items": 2
}创建GPU云主机
下单生成实例
请求
POST
/gpu/instances/buy请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| image_id | 是 | String | 镜像id |
| num | 是 | int | 下单实例数量 |
| gpu_type | 是 | String | GPU 实例类型 |
| gpu_count | 是 | int | 每个实例包含的gpu卡数量 |
| extra_disk_cap | 否 | int | 扩容的数据盘大小,100累加,单位GB |
| pay_unit | 是 | int | 计费方式 按小时:4 ; 按天:1 ;按月:2 |
| room_name | 是 | String | 区 |
返回参数
| 参数名称 | 描述 |
| success_instance | 创建成功的实例个数 |
| fail_instance | 创建失败的实例个数 |
| success | 成功列表 |
| fails | 失败列表 |
| order_uid | 订单号 |
请求示例
curl --location 'https://api-v1.huixingyun.com/gpu/instances/buy' \
--header 'Authorization: 87471d0a-xxxx-xxxx-xxxx-de93651034fc' \
--header 'Content-Type: application/json' \
--data '{
"image_id":"e9f1f1de-xxxx-xxxx-xxxx-f7011c487486",
"num":"1",
"gpu_type":"geforce_rtx_4090_16u100m_106",
"gpu_count":"1",
"extra_disk_cap":"100",
"pay_unit":"4",
"room_name":"106"
}
'返回示例
{
"success_instance": 1,
"fail_instance": 0,
"success": [
{
"order_uid": "20240705173xxxx20674"
}
],
"fails": []
}创建应用
下单创建应用
请求
POST
/gpu/application/buy请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| num | 是 | int | 下单应用数量 |
| pay_unit | 是 | int | 计费方式 按小时:4 ; 按天:1 ;按月:2 |
| app_type | 是 | String | GPU 应用类型 |
返回参数
| 参数名称 | 描述 |
| success_instance | 创建成功的应用个数 |
| fail_instance | 创建失败的应用个数 |
| success | 成功列表 |
| fails | 失败列表 |
| order_uid | 订单号 |
请求示例
curl --location 'https://api-v1.huixingyun.com/gpu/application/buy' \
--header 'Authorization: 87471d0a-xxxx-xxxx-xxxx-de93651034fc' \
--header 'Content-Type: application/json' \
--data '{
"num":"1",
"app_type":"sd-webui",
"pay_unit":"4"
}
'返回示例
{
"success_instance": 1,
"fail_instance": 0,
"success": [
{
"order_uid": "20240708143xxx021122"
}
],
"fails": []
}获取实例列表
获取实例列表
请求
POST
/gpu/instances/list请求参数
无
返回参数
| 参数名称 | 描述 |
| custom_ports | GPU实例的自定义端口号 |
| app_metadata | GPU 应用的元数据 |
| gid | 实例id |
| name | 实例名称 |
| image | 镜像信息 |
| size | GPU 实例配置信息 |
| ip | 主机地址 |
| pay_method | 计费方式 |
| status | 实例状态 |
| create_at | 创建时间 |
| expire_at | 到期时间 |
| username | 远程登录用户名 |
| port | 远程登录端口 |
| room_name | 区 |
| password | 远程登录密码 |
| order_uid | 实例对应的订单号 |
返回示例
{
"items": [
{
"custom_ports": [],
"app_metadata": {},
"gid": "gpu-105b63811xxxxxa4cb082",
"name": "NVIDIA 4090 * 1",
"image": {
"image_id": "04c852e9-91a3-xxxx-b5de-a07acc51c39f",
"name": "0705测试",
"scene": "Gpu",
"os": "linux",
"description": "创建时间: 2024-07-05 14:09:31"
},
"size": {
"gpu_type": "geforce_rtx_4090_16u100m_105",
"scene": "Gpu",
"disk_free": "160",
"gpu_ram": 24,
"gpu_model": "NVIDIA 4090 * 1",
"memory": 100,
"cpu": 16,
"gpu": "1"
},
"ip": "xxxxx",
"pay_method": "Month",
"status": "Stopped",
"create_at": "2024-07-05T15:21:21+08:00",
"expire_at": "2024-08-04T15:23:27+08:00",
"username": "root",
"port": xxxx,
"room_name": "105",
"password": "xxxx"
"order_uid": "20240705173xxxx20674"
}
],
"total": "1"
}
实例关机
操作实例关机
请求
POST
/gpu/instances/stop请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| gid | 是 | String | 实例id,如多个用“,”分隔 |
| card_less | 是 | bool | 是否无卡关机 |
请求示例
curl --location 'https://api-v1.huixingyun.com/gpu/instances/stop' \
--header 'Authorization: 87471d0a-xxxx-xxxx-xxxx-de93651034fc' \
--header 'Content-Type: application/json' \
--data '{
"gid":"gpu-105e085xxxxxf4940e799",
"card_less":false
}
'返回示例
{
"fails": [],
"success": [
"gpu-101f5cxxxxxc554715bf"
]
}
实例重启
操作实例重启
请求
POST
/gpu/instances/restart请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| gid | 是 | String | 实例id,如多个用“,”分隔 |
返回示例
{
"fails": [],
"success": [
"gpu-101bc3209xxxx58442686",
"gpu-101f5c582xxxx54715bf"
]
}
实例开机
1、操作实例普通关机状态下再开机
请求
/gpu/instances/start请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| gid | 是 | String | 实例id,如多个用“,”分隔 |
返回示例
{
"fails": [],
"success": [
"gpu-101bc320xxxxxf58442686",
"gpu-101f5c58xxxxx554715bf"
]
}
2、操作实例无卡关机状态下再开机
请求
/gpu/instances/cardless/start请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| gid | 是 | String | 实例id,如多个用“,”分隔 |
返回示例
{
"fails": [],
"success": [
"gpu-101bc320xxxxxf58442686",
"gpu-101f5c58xxxxx554715bf"
]
}
保存镜像
操作实例保存镜像
请求
POST
/gpu/instance/snapshot请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| gid | 是 | String | 单个实例id |
| name | 是 | String | 镜像名称 |
返回示例
{ success: true }重装镜像
操作实例重装镜像,暂不支持跨镜像系统重装
请求
POST
/gpu/instances/rebuild请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| gid | 是 | String | 实例id,如多个用“,”分隔 |
| image_id | 是 | String | 镜像id |
返回示例
{
"fails": [],
"success": [
"gpu-101bc320xxxxf58442686",
"gpu-101f5c58xxxxc554715bf"
]
}销毁实例
仅支持销毁按时计费的实例,且需要先把实例关机
请求
POST
/gpu/instances/destroy请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| gid | 是 | String | 实例id,如多个用“,”分隔 |
返回示例
{
"fails": [],
"success": [
"gpu-101bc3209c2xxxx442686",
"gpu-101f5c58214xxxx4715bf"
]
}修改实例计费模式
按时计费可以选择转换计费模式为包天/包月,包天的实例可转为包月
请求
POST
/gpu/instances/lengthen请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| gid | 是 | String | 实例id,如多个用“,”分隔 |
| pay_unit | 是 | int | 计费模式,1: 按天,2: 按月 |
返回示例
{
"fails": [],
"success": [
"gpu-101bc3209c2xxxx442686",
"gpu-101f5c58214xxxx4715bf"
]
}实例续费
续费可以按照实例当前的计费模式延长到期时间,按时计费实例不支持续费
请求
POST
/gpu/instances/renew请求参数
| 参数名称 | 必填 | 类型 | 描述 |
| gid | 是 | String | 实例id,如多个用“,”分隔 |
| pay_period | 是 | int | 续费周期,当值为1时,原计费周期为天的话,这时续费1天,如为月时,续费1个月(计费模式为按天时,可续费周期为1、3、7;按月时,可续费周期为1、3、12) |
返回示例
{
"fails": [],
"success": [
"gpu-101bc3209c2xxxx442686",
"gpu-101f5c58214xxxx4715bf"
]
}