跳转至

查询space可用的硬件配置列表

GET /api/v5/spaces/hardware

查询 space 可用的硬件配置(服务器规格)列表,支持分页,并可按 AI 设备类型(CPU / NPU)过滤。

访问令牌支持说明

  • AtomGit 用户访问令牌(AtomGit user access tokens)

是否允许匿名访问

此接口允许匿名访问

请求参数

参数名 位置 类型 必填 说明
page query integer 否 页码,从 1 开始;默认 1
per_page query integer 否 每页返回条数;默认 20
ai_device_type query string 否 AI 设备类型,枚举:CPU / NPU;不传则返回全部类型的硬件配置

响应参数

字段 类型 必返 可为空 说明
page_num integer 是 否 当前页码
page_size integer 是 否 每页返回条数
total integer 是 否 总记录数
page_count integer 是 否 总页数
content array<object> 是 否 硬件配置列表

content 数组元素对象

字段 类型 必返 可为空 说明
content[].id string 是 否 服务器标识ID,示例 r150el8k9aqm4fpgcz7dt6oxs2inybhj
content[].name string 是 否 服务器规格名称,如「CPU basic 2 vCPU 16 GB」
content[].ram string 是 否 服务器内存大小,单位 Gi 或 Mi,如 500Mi、1Gi
content[].cpu string 是 否 服务器 CPU 的核数,如 0.5、1
content[].ai_accelerate object 是 是 服务器 AI 加速卡的规格;普通 CPU 规格时可能为 null

content[].ai_accelerate 对象

字段 类型 必返 可为空 说明
content[].ai_accelerate.device string 是 是 设备的类型,如 NVIDIA GPU V100 或 Ascend NPU D910
content[].ai_accelerate.request string 是 是 申请的设备数量,默认 1
content[].ai_accelerate.v_ram integer 是 是 需要的显存大小,单位 GB,如 16

失败响应

400 参数错误

{
  "error_code": 400,
  "error_code_name": "PARAMETER_ERROR",
  "error_message": "参数 page 类型不正确"
}

401 未认证

{
  "error_code": 401,
  "error_code_name": "UNAUTHORIZED",
  "error_message": "缺少或无效的访问令牌"
}

HTTP 响应状态码

状态码 说明
200 成功(OK)
400 参数错误(Bad Request)
401 需要认证(Requires authentication)
403 禁止访问(Forbidden)
500 系统内部错误(Internal Server Error)

请求示例

参数说明

本接口允许匿名访问,示例中可选择性携带访问令牌;ai_device_type 为可选参数,示例按 NPU 过滤第一页、每页 20 条。 <token> 替换为你的 AtomGit 用户访问令牌(可选,携带时可获得更完整的权限)。

cURL

curl -X GET 'https://api.atomgit.com/api/v5/spaces/hardware?page=1&per_page=20&ai_device_type=NPU' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer <token>'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/spaces/hardware?page=1&per_page=20&ai_device_type=NPU", {
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer <YOUR-TOKEN>",
  },
});

if (!response.ok) {
  throw new Error("请求失败: " + response.status);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.get(
    "https://api.atomgit.com/api/v5/spaces/hardware",
    params={"page": 1, "per_page": 20, "ai_device_type": "NPU"},
    headers={
        "Accept": "application/json",
        "Authorization": "Bearer <YOUR-TOKEN>",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

响应示例

状态码: 200

{
  "page_num": 1,
  "page_size": 20,
  "total": 2,
  "page_count": 1,
  "content": [
    {
      "id": "r150el8k9aqm4fpgcz7dt6oxs2inybhj",
      "name": "CPU basic 2 vCPU 16 GB",
      "ram": "16Gi",
      "cpu": "2",
      "ai_accelerate": null
    },
    {
      "id": "a8c9d1e2f3b4a5c6d7e8f9a0b1c2d3e4",
      "name": "NPU basic 1 Ascend 910",
      "ram": "32Gi",
      "cpu": "8",
      "ai_accelerate": {
        "device": "Ascend NPU D910",
        "request": "1",
        "v_ram": 16
      }
    }
  ]
}

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc