外观
OpenAPI 规格查询
创建实例和云磁盘前,应先查询当前账号在目标区域可购买的规格。规格、价格和可用数量会变化,不建议长期缓存或硬编码。
请求均需携带 OpenAPI 鉴权 Header。
查询实例规格
获取指定区域当前可用的 GPU/CPU、内存、磁盘和价格信息。创建实例时使用返回的 spec_id、spec_type 及硬件字段。
http
GET /api/spec/list输入参数
| 参数 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
region | Query | string | 是 | 区域,例如 cn-north-a |
capacity_type | Query | string | 否 | ondemand 按需实例;spot 竞价实例;不传则查询全部 |
gpu_name、gpu_num、lowest_cpu_per_gpu、lowest_mem_per_gpu 和 lowest_cuda 为预留筛选参数,当前客户端不应依赖这些参数完成筛选。
请求示例
shell
curl "$DAMODEL_API/api/spec/list?region=cn-north-a&capacity_type=ondemand" \
-H "X-Damodel-Token: $DAMODEL_TOKEN" \
-H "X-Damodel-Timestamp: $(date +%s)"输出字段
result 是规格数组。
| 字段 | 类型 | 说明 |
|---|---|---|
spec_id | integer | 规格 ID,创建实例时原样传入 |
spec_type | string | 规格编码,创建实例时原样传入 |
capacity_type | string | ondemand 或 spot |
gpu_name | string | GPU 型号;CPU 规格可能返回 CPU 标识 |
gpu_mem | integer | 单张 GPU 显存,单位 MB |
max_gpu_count | integer | 当前允许购买的最大 GPU 数量;为 0 时不可创建 |
cpu_per_gpu | integer | 每张 GPU 对应的 CPU 核数 |
mem_per_gpu | integer | 每张 GPU 对应的内存,单位 GB |
sys_disk_size | integer | 默认系统盘大小,单位 GB |
data_disk_size | integer | 默认数据盘大小,单位 GB |
data_disk_expand_quota | integer | 数据盘最大可扩容额度,单位 GB |
highest_cuda | string | 该规格支持的最高 CUDA 版本 |
support_ib_network | integer | 1 支持 IB 网络,0 不支持 |
hourly_price | number | 按小时价格 |
daily_price | number | 按日价格 |
monthly_price | number | 按月价格 |
hourly_data_disk_price | number | 扩容数据盘每 GB 小时价格 |
daily_data_disk_price | number | 扩容数据盘每 GB 日价格 |
monthly_data_disk_price | number | 扩容数据盘每 GB 月价格 |
hourly_discount / daily_discount / monthly_discount | number | 对应周期折扣 |
*_discount_status | integer | 0 无活动、1 已作废、2 未生效、3 已过期、4 生效中、5 生效且有下一活动 |
rush_sale_status | integer | 0 普通规格,1 抢购规格 |
响应示例
json
{
"result": [
{
"spec_id": 12,
"spec_type": "gpu-rtx4090-1",
"capacity_type": "ondemand",
"gpu_name": "NVIDIA-GeForce-RTX-4090",
"gpu_mem": 24564,
"max_gpu_count": 2,
"cpu_per_gpu": 16,
"mem_per_gpu": 64,
"sys_disk_size": 30,
"data_disk_size": 50,
"data_disk_expand_quota": 500,
"highest_cuda": "12.4",
"support_ib_network": 0,
"hourly_price": 2.5,
"daily_price": 55,
"monthly_price": 1500
}
],
"response_metadata": {
"request_id": "request-id",
"trace_id": "trace-id",
"action": "",
"version": "",
"service": "",
"error": null
}
}可能的错误
code_n | code | 说明 |
|---|---|---|
| 100002 | InvalidParameter | region 缺失,或 capacity_type 不是允许值 |
| 100006 | InvalidToken | API Key 或时间戳无效 |
| 100014 | InternalError | 查询规格或价格失败 |
查询云磁盘规格
获取当前允许用户创建的云磁盘规格。创建云磁盘时使用返回的 id 作为 spec_id。
http
GET /api/storage/cloud_disk/spec输入参数
| 参数 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
spec_alias | Query | string | 否 | 按规格名称模糊查询 |
spec_types | Query | integer[] | 否 | 逗号分隔;1 RBD、2 FS、3 S3 |
support_ib_network | Query | integer | 否 | 0 不返回仅限 IB 的规格,1 允许返回支持 IB 的规格 |
page | Query | integer | 否 | 页码;page 和 page_size 都不传时返回全部 |
page_size | Query | integer | 否 | 每页数量 |
请求示例
shell
curl "$DAMODEL_API/api/storage/cloud_disk/spec?page=1&page_size=20" \
-H "X-Damodel-Token: $DAMODEL_TOKEN" \
-H "X-Damodel-Timestamp: $(date +%s)"输出字段
result 是分页对象,规格数组位于 result.data。
| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 云磁盘规格 ID |
spec_alias | string | 用户可见的规格名称 |
multiple_mounting | boolean | 是否支持同时挂载到多个实例 |
max_size_g | integer | 单个云磁盘最大容量,单位 GiB |
storage_class_type | integer | 1 RBD、2 FS、3 S3 |
json
{
"result": {
"total": 1,
"page": 1,
"page_size": 20,
"total_page": 1,
"data": [
{
"id": 3,
"spec_alias": "超速文件存储",
"multiple_mounting": true,
"max_size_g": 10240,
"storage_class_type": 2
}
]
},
"response_metadata": {
"request_id": "request-id",
"trace_id": "trace-id",
"action": "",
"version": "",
"service": "",
"error": null
}
}可能的错误
code_n | code | 说明 |
|---|---|---|
| 100002 | InvalidParameter | 分页或筛选参数不合法 |
| 100006 | InvalidToken | API Key 或时间戳无效 |
| 100042 | PermissionDenied | 子账号没有存储权限 |
| 100014 | InternalError | 云磁盘规格服务不可用 |
