GPU服务API文档
GPU实例
查询实例当前计费信息

GetCompShareInstanceUserPrice — 查询实例当前计费信息

接口说明

查询创建算力共享实例的价格。可指定单一计费模式查询,也可不传 ChargeType 同时获取所有计费模式(按月、按天、按时、抢占式)的价格。


请求参数

名称类型必填描述示例值
ActionString接口名称GetCompShareInstanceUserPrice
RegionString地域cn-wlcb
ZoneString可用区cn-wlcb-01
GpuTypeStringGPU 类型4090
GPUIntegerGPU 卡数1
CPUIntegerCPU 核数16
MemoryInteger内存大小,单位 MB65536
ChargeTypeString计费模式。不传则同时返回所有模式的价格。枚举值:Month(按月)、Day(按天)、Postpay(后付费)、Spot(抢占式)Month

响应参数

名称类型描述示例值
ActionString响应名称GetCompShareInstanceUserPriceResponse
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_user_price({
            "Zone": "cn-wlcb-01",
            "GpuType": "4090",
            "GPU": 1,
            "CPU": 16,
            "Memory": 64 * 1024,
        })
        for price in resp.get("PriceDetails", []):
            print(f"  {price['ChargeType']}: 实例 {price.get('Instance', 0)} 元")
    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.NewGetCompShareInstanceUserPriceRequest()
	req.GpuType = ucloud.String("4090")
	req.GPU = ucloud.Int(1)
	req.CPU = ucloud.Int(16)
	req.Memory = ucloud.Int(64 * 1024)
 
	resp, err := client.GetCompShareInstanceUserPrice(req)
	if err != nil {
		fmt.Printf("查询失败: %s\n", err)
		return
	}
	for _, price := range resp.PriceDetails {
		fmt.Printf("  %s: 实例 %.2f 元\n", price.ChargeType, *price.Instance)
	}
}

响应示例

{
  "Action": "GetCompShareInstanceUserPriceResponse",
  "RetCode": 0,
  "PriceDetails": [
    {"ChargeType": "Month", "Instance": 1068.00, "SystemDisks": 120.00},
    {"ChargeType": "Day", "Instance": 71.20, "SystemDisks": 8.00},
    {"ChargeType": "Postpay", "Instance": 1.48, "SystemDisks": 0.18},
    {"ChargeType": "Spot", "Instance": 1.04, "SystemDisks": 0.18, "InstanceDiscountType": 0}
  ],
  "OriginalPriceDetails": [
    {"ChargeType": "Month", "Instance": 1068.00, "SystemDisks": 120.00},
    {"ChargeType": "Day", "Instance": 71.20, "SystemDisks": 8.00},
    {"ChargeType": "Postpay", "Instance": 1.66, "SystemDisks": 0.18},
    {"ChargeType": "Spot", "Instance": 1.66, "SystemDisks": 0.18}
  ]
}
Copyright © 2026 沪ICP备12020087号-61