创建实例
curl --request POST \
--url https://api.ppio.com/gpus/v2/instances \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"name": "example-instance",
"product_id": "product-id",
"image": "registry.example.com/namespace/image:tag",
"billing": {
"mode": "prepaid"
},
"resource": {
"rootfs_size_gb": 20,
"gpu_num": 1,
"min_cuda_version": ""
},
"registry_auth_id": "registry-auth-id",
"entrypoint": "",
"command": "",
"envs": [
{
"key": "ENV_NAME",
"value": "ENV_VALUE"
}
],
"ports": [
{
"port": 8080,
"protocol": "tcp"
}
],
"network": {
"id": "vpc-550e8400-e29b-41d4-a716-446655440000",
"ip": "10.2.1.1"
},
"volumes": [
{
"type": "network",
"id": "network-storage-id",
"mount_point": "/data"
}
],
"candidate_regions": [
"region-id"
],
"tools": {
"jupyter": {
"enabled": true,
"port": 8888,
"protocol": "http"
}
},
"auto_migrate": {
"enabled": false,
"include_system_disk": false
}
}
'import requests
url = "https://api.ppio.com/gpus/v2/instances"
payload = {
"name": "example-instance",
"product_id": "product-id",
"image": "registry.example.com/namespace/image:tag",
"billing": { "mode": "prepaid" },
"resource": {
"rootfs_size_gb": 20,
"gpu_num": 1,
"min_cuda_version": ""
},
"registry_auth_id": "registry-auth-id",
"entrypoint": "",
"command": "",
"envs": [
{
"key": "ENV_NAME",
"value": "ENV_VALUE"
}
],
"ports": [
{
"port": 8080,
"protocol": "tcp"
}
],
"network": {
"id": "vpc-550e8400-e29b-41d4-a716-446655440000",
"ip": "10.2.1.1"
},
"volumes": [
{
"type": "network",
"id": "network-storage-id",
"mount_point": "/data"
}
],
"candidate_regions": ["region-id"],
"tools": { "jupyter": {
"enabled": True,
"port": 8888,
"protocol": "http"
} },
"auto_migrate": {
"enabled": False,
"include_system_disk": False
}
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({
name: 'example-instance',
product_id: 'product-id',
image: 'registry.example.com/namespace/image:tag',
billing: {mode: 'prepaid'},
resource: {rootfs_size_gb: 20, gpu_num: 1, min_cuda_version: ''},
registry_auth_id: 'registry-auth-id',
entrypoint: '',
command: '',
envs: [{key: 'ENV_NAME', value: 'ENV_VALUE'}],
ports: [{port: 8080, protocol: 'tcp'}],
network: {id: 'vpc-550e8400-e29b-41d4-a716-446655440000', ip: '10.2.1.1'},
volumes: [{type: 'network', id: 'network-storage-id', mount_point: '/data'}],
candidate_regions: ['region-id'],
tools: {jupyter: {enabled: true, port: 8888, protocol: 'http'}},
auto_migrate: {enabled: false, include_system_disk: false}
})
};
fetch('https://api.ppio.com/gpus/v2/instances', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ppio.com/gpus/v2/instances",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'example-instance',
'product_id' => 'product-id',
'image' => 'registry.example.com/namespace/image:tag',
'billing' => [
'mode' => 'prepaid'
],
'resource' => [
'rootfs_size_gb' => 20,
'gpu_num' => 1,
'min_cuda_version' => ''
],
'registry_auth_id' => 'registry-auth-id',
'entrypoint' => '',
'command' => '',
'envs' => [
[
'key' => 'ENV_NAME',
'value' => 'ENV_VALUE'
]
],
'ports' => [
[
'port' => 8080,
'protocol' => 'tcp'
]
],
'network' => [
'id' => 'vpc-550e8400-e29b-41d4-a716-446655440000',
'ip' => '10.2.1.1'
],
'volumes' => [
[
'type' => 'network',
'id' => 'network-storage-id',
'mount_point' => '/data'
]
],
'candidate_regions' => [
'region-id'
],
'tools' => [
'jupyter' => [
'enabled' => true,
'port' => 8888,
'protocol' => 'http'
]
],
'auto_migrate' => [
'enabled' => false,
'include_system_disk' => false
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ppio.com/gpus/v2/instances"
payload := strings.NewReader("{\n \"name\": \"example-instance\",\n \"product_id\": \"product-id\",\n \"image\": \"registry.example.com/namespace/image:tag\",\n \"billing\": {\n \"mode\": \"prepaid\"\n },\n \"resource\": {\n \"rootfs_size_gb\": 20,\n \"gpu_num\": 1,\n \"min_cuda_version\": \"\"\n },\n \"registry_auth_id\": \"registry-auth-id\",\n \"entrypoint\": \"\",\n \"command\": \"\",\n \"envs\": [\n {\n \"key\": \"ENV_NAME\",\n \"value\": \"ENV_VALUE\"\n }\n ],\n \"ports\": [\n {\n \"port\": 8080,\n \"protocol\": \"tcp\"\n }\n ],\n \"network\": {\n \"id\": \"vpc-550e8400-e29b-41d4-a716-446655440000\",\n \"ip\": \"10.2.1.1\"\n },\n \"volumes\": [\n {\n \"type\": \"network\",\n \"id\": \"network-storage-id\",\n \"mount_point\": \"/data\"\n }\n ],\n \"candidate_regions\": [\n \"region-id\"\n ],\n \"tools\": {\n \"jupyter\": {\n \"enabled\": true,\n \"port\": 8888,\n \"protocol\": \"http\"\n }\n },\n \"auto_migrate\": {\n \"enabled\": false,\n \"include_system_disk\": false\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ppio.com/gpus/v2/instances")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"name\": \"example-instance\",\n \"product_id\": \"product-id\",\n \"image\": \"registry.example.com/namespace/image:tag\",\n \"billing\": {\n \"mode\": \"prepaid\"\n },\n \"resource\": {\n \"rootfs_size_gb\": 20,\n \"gpu_num\": 1,\n \"min_cuda_version\": \"\"\n },\n \"registry_auth_id\": \"registry-auth-id\",\n \"entrypoint\": \"\",\n \"command\": \"\",\n \"envs\": [\n {\n \"key\": \"ENV_NAME\",\n \"value\": \"ENV_VALUE\"\n }\n ],\n \"ports\": [\n {\n \"port\": 8080,\n \"protocol\": \"tcp\"\n }\n ],\n \"network\": {\n \"id\": \"vpc-550e8400-e29b-41d4-a716-446655440000\",\n \"ip\": \"10.2.1.1\"\n },\n \"volumes\": [\n {\n \"type\": \"network\",\n \"id\": \"network-storage-id\",\n \"mount_point\": \"/data\"\n }\n ],\n \"candidate_regions\": [\n \"region-id\"\n ],\n \"tools\": {\n \"jupyter\": {\n \"enabled\": true,\n \"port\": 8888,\n \"protocol\": \"http\"\n }\n },\n \"auto_migrate\": {\n \"enabled\": false,\n \"include_system_disk\": false\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ppio.com/gpus/v2/instances")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"name\": \"example-instance\",\n \"product_id\": \"product-id\",\n \"image\": \"registry.example.com/namespace/image:tag\",\n \"billing\": {\n \"mode\": \"prepaid\"\n },\n \"resource\": {\n \"rootfs_size_gb\": 20,\n \"gpu_num\": 1,\n \"min_cuda_version\": \"\"\n },\n \"registry_auth_id\": \"registry-auth-id\",\n \"entrypoint\": \"\",\n \"command\": \"\",\n \"envs\": [\n {\n \"key\": \"ENV_NAME\",\n \"value\": \"ENV_VALUE\"\n }\n ],\n \"ports\": [\n {\n \"port\": 8080,\n \"protocol\": \"tcp\"\n }\n ],\n \"network\": {\n \"id\": \"vpc-550e8400-e29b-41d4-a716-446655440000\",\n \"ip\": \"10.2.1.1\"\n },\n \"volumes\": [\n {\n \"type\": \"network\",\n \"id\": \"network-storage-id\",\n \"mount_point\": \"/data\"\n }\n ],\n \"candidate_regions\": [\n \"region-id\"\n ],\n \"tools\": {\n \"jupyter\": {\n \"enabled\": true,\n \"port\": 8888,\n \"protocol\": \"http\"\n }\n },\n \"auto_migrate\": {\n \"enabled\": false,\n \"include_system_disk\": false\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "ca338f12f3"
}实例
创建实例
POST
/
gpus
/
v2
/
instances
创建实例
curl --request POST \
--url https://api.ppio.com/gpus/v2/instances \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"name": "example-instance",
"product_id": "product-id",
"image": "registry.example.com/namespace/image:tag",
"billing": {
"mode": "prepaid"
},
"resource": {
"rootfs_size_gb": 20,
"gpu_num": 1,
"min_cuda_version": ""
},
"registry_auth_id": "registry-auth-id",
"entrypoint": "",
"command": "",
"envs": [
{
"key": "ENV_NAME",
"value": "ENV_VALUE"
}
],
"ports": [
{
"port": 8080,
"protocol": "tcp"
}
],
"network": {
"id": "vpc-550e8400-e29b-41d4-a716-446655440000",
"ip": "10.2.1.1"
},
"volumes": [
{
"type": "network",
"id": "network-storage-id",
"mount_point": "/data"
}
],
"candidate_regions": [
"region-id"
],
"tools": {
"jupyter": {
"enabled": true,
"port": 8888,
"protocol": "http"
}
},
"auto_migrate": {
"enabled": false,
"include_system_disk": false
}
}
'import requests
url = "https://api.ppio.com/gpus/v2/instances"
payload = {
"name": "example-instance",
"product_id": "product-id",
"image": "registry.example.com/namespace/image:tag",
"billing": { "mode": "prepaid" },
"resource": {
"rootfs_size_gb": 20,
"gpu_num": 1,
"min_cuda_version": ""
},
"registry_auth_id": "registry-auth-id",
"entrypoint": "",
"command": "",
"envs": [
{
"key": "ENV_NAME",
"value": "ENV_VALUE"
}
],
"ports": [
{
"port": 8080,
"protocol": "tcp"
}
],
"network": {
"id": "vpc-550e8400-e29b-41d4-a716-446655440000",
"ip": "10.2.1.1"
},
"volumes": [
{
"type": "network",
"id": "network-storage-id",
"mount_point": "/data"
}
],
"candidate_regions": ["region-id"],
"tools": { "jupyter": {
"enabled": True,
"port": 8888,
"protocol": "http"
} },
"auto_migrate": {
"enabled": False,
"include_system_disk": False
}
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({
name: 'example-instance',
product_id: 'product-id',
image: 'registry.example.com/namespace/image:tag',
billing: {mode: 'prepaid'},
resource: {rootfs_size_gb: 20, gpu_num: 1, min_cuda_version: ''},
registry_auth_id: 'registry-auth-id',
entrypoint: '',
command: '',
envs: [{key: 'ENV_NAME', value: 'ENV_VALUE'}],
ports: [{port: 8080, protocol: 'tcp'}],
network: {id: 'vpc-550e8400-e29b-41d4-a716-446655440000', ip: '10.2.1.1'},
volumes: [{type: 'network', id: 'network-storage-id', mount_point: '/data'}],
candidate_regions: ['region-id'],
tools: {jupyter: {enabled: true, port: 8888, protocol: 'http'}},
auto_migrate: {enabled: false, include_system_disk: false}
})
};
fetch('https://api.ppio.com/gpus/v2/instances', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ppio.com/gpus/v2/instances",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'example-instance',
'product_id' => 'product-id',
'image' => 'registry.example.com/namespace/image:tag',
'billing' => [
'mode' => 'prepaid'
],
'resource' => [
'rootfs_size_gb' => 20,
'gpu_num' => 1,
'min_cuda_version' => ''
],
'registry_auth_id' => 'registry-auth-id',
'entrypoint' => '',
'command' => '',
'envs' => [
[
'key' => 'ENV_NAME',
'value' => 'ENV_VALUE'
]
],
'ports' => [
[
'port' => 8080,
'protocol' => 'tcp'
]
],
'network' => [
'id' => 'vpc-550e8400-e29b-41d4-a716-446655440000',
'ip' => '10.2.1.1'
],
'volumes' => [
[
'type' => 'network',
'id' => 'network-storage-id',
'mount_point' => '/data'
]
],
'candidate_regions' => [
'region-id'
],
'tools' => [
'jupyter' => [
'enabled' => true,
'port' => 8888,
'protocol' => 'http'
]
],
'auto_migrate' => [
'enabled' => false,
'include_system_disk' => false
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ppio.com/gpus/v2/instances"
payload := strings.NewReader("{\n \"name\": \"example-instance\",\n \"product_id\": \"product-id\",\n \"image\": \"registry.example.com/namespace/image:tag\",\n \"billing\": {\n \"mode\": \"prepaid\"\n },\n \"resource\": {\n \"rootfs_size_gb\": 20,\n \"gpu_num\": 1,\n \"min_cuda_version\": \"\"\n },\n \"registry_auth_id\": \"registry-auth-id\",\n \"entrypoint\": \"\",\n \"command\": \"\",\n \"envs\": [\n {\n \"key\": \"ENV_NAME\",\n \"value\": \"ENV_VALUE\"\n }\n ],\n \"ports\": [\n {\n \"port\": 8080,\n \"protocol\": \"tcp\"\n }\n ],\n \"network\": {\n \"id\": \"vpc-550e8400-e29b-41d4-a716-446655440000\",\n \"ip\": \"10.2.1.1\"\n },\n \"volumes\": [\n {\n \"type\": \"network\",\n \"id\": \"network-storage-id\",\n \"mount_point\": \"/data\"\n }\n ],\n \"candidate_regions\": [\n \"region-id\"\n ],\n \"tools\": {\n \"jupyter\": {\n \"enabled\": true,\n \"port\": 8888,\n \"protocol\": \"http\"\n }\n },\n \"auto_migrate\": {\n \"enabled\": false,\n \"include_system_disk\": false\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ppio.com/gpus/v2/instances")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"name\": \"example-instance\",\n \"product_id\": \"product-id\",\n \"image\": \"registry.example.com/namespace/image:tag\",\n \"billing\": {\n \"mode\": \"prepaid\"\n },\n \"resource\": {\n \"rootfs_size_gb\": 20,\n \"gpu_num\": 1,\n \"min_cuda_version\": \"\"\n },\n \"registry_auth_id\": \"registry-auth-id\",\n \"entrypoint\": \"\",\n \"command\": \"\",\n \"envs\": [\n {\n \"key\": \"ENV_NAME\",\n \"value\": \"ENV_VALUE\"\n }\n ],\n \"ports\": [\n {\n \"port\": 8080,\n \"protocol\": \"tcp\"\n }\n ],\n \"network\": {\n \"id\": \"vpc-550e8400-e29b-41d4-a716-446655440000\",\n \"ip\": \"10.2.1.1\"\n },\n \"volumes\": [\n {\n \"type\": \"network\",\n \"id\": \"network-storage-id\",\n \"mount_point\": \"/data\"\n }\n ],\n \"candidate_regions\": [\n \"region-id\"\n ],\n \"tools\": {\n \"jupyter\": {\n \"enabled\": true,\n \"port\": 8888,\n \"protocol\": \"http\"\n }\n },\n \"auto_migrate\": {\n \"enabled\": false,\n \"include_system_disk\": false\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ppio.com/gpus/v2/instances")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"name\": \"example-instance\",\n \"product_id\": \"product-id\",\n \"image\": \"registry.example.com/namespace/image:tag\",\n \"billing\": {\n \"mode\": \"prepaid\"\n },\n \"resource\": {\n \"rootfs_size_gb\": 20,\n \"gpu_num\": 1,\n \"min_cuda_version\": \"\"\n },\n \"registry_auth_id\": \"registry-auth-id\",\n \"entrypoint\": \"\",\n \"command\": \"\",\n \"envs\": [\n {\n \"key\": \"ENV_NAME\",\n \"value\": \"ENV_VALUE\"\n }\n ],\n \"ports\": [\n {\n \"port\": 8080,\n \"protocol\": \"tcp\"\n }\n ],\n \"network\": {\n \"id\": \"vpc-550e8400-e29b-41d4-a716-446655440000\",\n \"ip\": \"10.2.1.1\"\n },\n \"volumes\": [\n {\n \"type\": \"network\",\n \"id\": \"network-storage-id\",\n \"mount_point\": \"/data\"\n }\n ],\n \"candidate_regions\": [\n \"region-id\"\n ],\n \"tools\": {\n \"jupyter\": {\n \"enabled\": true,\n \"port\": 8888,\n \"protocol\": \"http\"\n }\n },\n \"auto_migrate\": {\n \"enabled\": false,\n \"include_system_disk\": false\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "ca338f12f3"
}请求头
枚举值:application/json。
Bearer 身份验证格式,例如:Bearer {{API 密钥}}。
请求体
application/json
实例名称。字符串,长度限制:1-255 字符。
示例:
"example-instance"
产品 ID。
示例:
"product-id"
镜像地址。字符串,长度限制:1-500 字符。
示例:
"registry.example.com/namespace/image:tag"
计费配置。
Show child attributes
Show child attributes
资源配置。
Show child attributes
Show child attributes
实例类型。可选值:gpu、cpu。默认值:gpu。
可用选项:
gpu, cpu 已保存的镜像认证 ID。字符串,长度限制:0-255 字符。
示例:
"registry-auth-id"
容器 entrypoint。
示例:
""
容器启动命令。
示例:
""
环境变量列表。
Show child attributes
Show child attributes
暴露端口列表。
Show child attributes
Show child attributes
VPC 网络配置。
Show child attributes
Show child attributes
数据盘/网络存储挂载列表。
Show child attributes
Show child attributes
候选调度区域列表。最终只会调度到其中一个区域。
示例:
["region-id"]
实例工具配置。当前仅支持 Jupyter。
Show child attributes
Show child attributes
自动迁移配置。
Show child attributes
Show child attributes
响应
200 - application/json
创建成功
创建成功后的实例 ID
示例:
"ca338f12f3"
最后修改于 2026年6月22日
⌘I