Skip to Content
GPU 接口文档GPU实例查询创建实例价格
GPU API 接口

查询创建实例价格

接口说明

查询创建优云智算 GPU 实例的价格,返回实例、磁盘、镜像的分项价格明细。

POSThttps://api.compshare.cnActionGetCompShareInstancePrice

请求参数

名称类型必填描述示例值
ActionString是接口名称GetCompShareInstancePrice
RegionString是地域cn-wlcb
ZoneString是可用区cn-wlcb-01
GpuTypeString是GPU 类型4090
GpuInteger是GPU 卡数1
CpuInteger是CPU 核数16
MemoryInteger是内存大小,单位 MB65536
ChargeTypeString否计费模式。不传则同时返回所有模式的价格。枚举值:Month、Day、Dynamic、Postpay、SpotMonth
DisksArray of Object否磁盘配置数组[{"IsBoot":true,"Type":"CLOUD_SSD","Size":60}]
VolumesArray of Object否共享存储配置数组[{"Type":"UDisk","Size":100}]
CompShareImageIdString否镜像 ID(付费社区镜像时需传入)compshareImage-xxxx
QuantityInteger否购买时长,默认 11

Disks 元素结构

字段类型描述
IsBootBoolean是否为系统盘
TypeString磁盘类型
SizeInteger磁盘大小(GB)
CouponIdString云盘代金券 ID

Volumes 元素结构

字段类型描述
TypeString共享存储类型
SizeInteger共享存储大小(GB)

响应参数

名称类型描述示例值
ActionString响应名称GetCompShareInstancePriceResponse
RetCodeInteger返回码,0 为成功0
PriceDetailsArray of Object折后价格明细—
OriginalPriceDetailsArray of Object原价明细(结构同 PriceDetails)—
ListPriceDetailsArray of Object目录价明细(结构同 PriceDetails)—

PriceDetails 元素结构

名称类型描述
ChargeTypeString计费模式
InstanceFloat实例价格(CPU + 内存 + GPU,元)
DisksFloat数据盘价格(元)
SystemDisksFloat系统盘价格(元)
CompShareImageFloat镜像价格(元,仅付费社区镜像)
InstanceDiscountTypeInteger折扣类型。1:夜间折扣,2:节日折扣

请求示例

Python(使用 UCloud SDK)

from ucloud.core import exc from ucloud.client import Client def main(): client = Client({ "region": "cn-wlcb", "public_key": "my_public_key", # 替换为你的公钥(控制台 账户中心 → API 密钥:https://console.compshare.cn/uaccount/api_manage) "private_key": "my_private_key", # 替换为你的私钥 "base_url": "https://api.compshare.cn", }) try: resp = client.ucompshare().get_comp_share_instance_price({ "Zone": "cn-wlcb-01", "GpuType": "4090", "Gpu": 1, "Cpu": 16, "Memory": 64 * 1024, "ChargeType": "Month", "Disks": [{"IsBoot": True, "Type": "CLOUD_SSD", "Size": 60}], }) for p in resp.get("PriceDetails", []): print(f" 实例: {p.get('Instance')} 元, 系统盘: {p.get('SystemDisks')} 元") except exc.UCloudException as e: print(e) if __name__ == "__main__": main()

Go(使用 UCloud SDK)

package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.Zone = "cn-wlcb-01" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥(控制台 账户中心 → API 密钥:https://console.compshare.cn/uaccount/api_manage) credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewGetCompShareInstancePriceRequest() req.GpuType = ucloud.String("4090") req.Gpu = ucloud.Int(1) req.Cpu = ucloud.Int(16) req.Memory = ucloud.Int(64 * 1024) req.ChargeType = ucloud.String("Month") resp, err := client.GetCompShareInstancePrice(req) if err != nil { fmt.Printf("查询失败: %s\n", err) return } for _, p := range resp.PriceDetails { fmt.Printf(" 实例: %.2f 元\n", *p.Instance) } }

响应示例

{ "Action": "GetCompShareInstancePriceResponse", "RetCode": 0, "PriceDetails": [ {"ChargeType": "Month", "Instance": 1068.00, "SystemDisks": 120.00} ], "OriginalPriceDetails": [ {"ChargeType": "Month", "Instance": 1068.00, "SystemDisks": 120.00} ], "ListPriceDetails": [ {"ChargeType": "Month", "Instance": 1068.00, "SystemDisks": 120.00} ] }
Last updated on