Skip to content

OpenAPI 规格查询

创建实例和云磁盘前,应先查询当前账号在目标区域可购买的规格。规格、价格和可用数量会变化,不建议长期缓存或硬编码。

请求均需携带 OpenAPI 鉴权 Header

查询实例规格

获取指定区域当前可用的 GPU/CPU、内存、磁盘和价格信息。创建实例时使用返回的 spec_idspec_type 及硬件字段。

http
GET /api/spec/list

输入参数

参数位置类型必填说明
regionQuerystring区域,例如 cn-north-a
capacity_typeQuerystringondemand 按需实例;spot 竞价实例;不传则查询全部

gpu_namegpu_numlowest_cpu_per_gpulowest_mem_per_gpulowest_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_idinteger规格 ID,创建实例时原样传入
spec_typestring规格编码,创建实例时原样传入
capacity_typestringondemandspot
gpu_namestringGPU 型号;CPU 规格可能返回 CPU 标识
gpu_meminteger单张 GPU 显存,单位 MB
max_gpu_countinteger当前允许购买的最大 GPU 数量;为 0 时不可创建
cpu_per_gpuinteger每张 GPU 对应的 CPU 核数
mem_per_gpuinteger每张 GPU 对应的内存,单位 GB
sys_disk_sizeinteger默认系统盘大小,单位 GB
data_disk_sizeinteger默认数据盘大小,单位 GB
data_disk_expand_quotainteger数据盘最大可扩容额度,单位 GB
highest_cudastring该规格支持的最高 CUDA 版本
support_ib_networkinteger1 支持 IB 网络,0 不支持
hourly_pricenumber按小时价格
daily_pricenumber按日价格
monthly_pricenumber按月价格
hourly_data_disk_pricenumber扩容数据盘每 GB 小时价格
daily_data_disk_pricenumber扩容数据盘每 GB 日价格
monthly_data_disk_pricenumber扩容数据盘每 GB 月价格
hourly_discount / daily_discount / monthly_discountnumber对应周期折扣
*_discount_statusinteger0 无活动、1 已作废、2 未生效、3 已过期、4 生效中、5 生效且有下一活动
rush_sale_statusinteger0 普通规格,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_ncode说明
100002InvalidParameterregion 缺失,或 capacity_type 不是允许值
100006InvalidTokenAPI Key 或时间戳无效
100014InternalError查询规格或价格失败

查询云磁盘规格

获取当前允许用户创建的云磁盘规格。创建云磁盘时使用返回的 id 作为 spec_id

http
GET /api/storage/cloud_disk/spec

输入参数

参数位置类型必填说明
spec_aliasQuerystring按规格名称模糊查询
spec_typesQueryinteger[]逗号分隔;1 RBD、2 FS、3 S3
support_ib_networkQueryinteger0 不返回仅限 IB 的规格,1 允许返回支持 IB 的规格
pageQueryinteger页码;pagepage_size 都不传时返回全部
page_sizeQueryinteger每页数量

请求示例

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

字段类型说明
idinteger云磁盘规格 ID
spec_aliasstring用户可见的规格名称
multiple_mountingboolean是否支持同时挂载到多个实例
max_size_ginteger单个云磁盘最大容量,单位 GiB
storage_class_typeinteger1 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_ncode说明
100002InvalidParameter分页或筛选参数不合法
100006InvalidTokenAPI Key 或时间戳无效
100042PermissionDenied子账号没有存储权限
100014InternalError云磁盘规格服务不可用