GPU服务API文档
GPU实例
查询创建实例价格

GetCompShareInstancePrice — 查询创建实例价格

接口说明

查询创建算力共享实例的价格,返回实例、磁盘、镜像的分项价格明细。


请求参数

名称类型必填描述示例值
ActionString接口名称GetCompShareInstancePrice
RegionString地域cn-wlcb
ZoneString可用区cn-wlcb-01
GpuTypeStringGPU 类型4090
GpuIntegerGPU 卡数1
CpuIntegerCPU 核数16
MemoryInteger内存大小,单位 MB65536
ChargeTypeString计费模式。不传则同时返回所有模式的价格。枚举值:MonthDayDynamicPostpaySpotMonth
Disks.N.IsBootBoolean是否为系统盘true
Disks.N.TypeString磁盘类型CLOUD_SSD
Disks.N.SizeInteger磁盘大小(GB)60
Volumes.N.TypeString共享存储类型UDisk
Volumes.N.SizeInteger共享存储大小(GB)100
CompShareImageIdString镜像 ID(付费社区镜像时需传入)compshareImage-xxxx
QuantityInteger购买时长,默认 11

响应参数

名称类型描述示例值
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",    # 替换为你的公钥,从 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"   // 替换为你的公钥,从 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}
  ]
}
Copyright © 2026 沪ICP备12020087号-61