跳转到主要内容
POST
/
gpus
/
v2
/
templates
创建模板
curl --request POST \
  --url https://api.ppio.com/gpus/v2/templates \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "name": "pytorch-2.3-cuda12",
  "type": "instance",
  "image": "registry.example.com/ml/pytorch:2.3-cuda12",
  "registry_auth_id": "auth-001",
  "command": "",
  "entrypoint": "/bin/bash",
  "rootfs_size_gb": 50,
  "ports": [
    {
      "protocol": "http",
      "port": 8888
    }
  ],
  "envs": [
    {
      "key": "ENV",
      "value": "prod"
    }
  ],
  "metadata": {
    "readme": "PyTorch 2.3 with CUDA 12",
    "logo": "https://example.com/logo.png",
    "description": "PyTorch development template",
    "author": "PAI",
    "tags": [
      "pytorch",
      "cuda"
    ]
  },
  "min_cuda_version": "12.2"
}
'
{
  "template_id": "tpl-001"
}

请求头

Content-Type
string
必填

枚举值:application/json。

Authorization
string
必填

Bearer 身份验证格式,例如:Bearer {{API 密钥}}

请求体

application/json
name
string
必填

模板名称。

示例:

"pytorch-2.3-cuda12"

type
string
必填

模板类型。

示例:

"instance"

image
string
必填

镜像地址。

示例:

"registry.example.com/ml/pytorch:2.3-cuda12"

registry_auth_id
string

镜像仓库认证 ID。

示例:

"auth-001"

command
string

启动命令。

示例:

""

entrypoint
string

镜像入口命令。

示例:

"/bin/bash"

rootfs_size_gb
integer

系统盘大小。单位为 GB。

示例:

50

ports
object[]

暴露端口配置。

envs
object[]

环境变量。

metadata
object

模板元数据。

min_cuda_version
string

最低 CUDA 版本。

示例:

"12.2"

响应

200 - application/json

创建成功

template_id
string

模板 ID

示例:

"tpl-001"

最后修改于 2026年6月22日