资讯 文档
技术能力
语音技术
文字识别
人脸与人体
图像技术
语言与知识
视频技术

查询算力单元详情

功能介绍

用于查询指定算力单元详细信息。

使用说明

本文API支持通过Python SDK、Go SDK、Java SDK 和 Node.js SDK调用,调用流程请参考SDK安装及使用流程

权限说明

调用本文API,需符合以下权限要求,权限介绍及分配,请查看角色与权限控制列表账号创建与权限分配。需具有以下任一权限:

  • 完全控制千帆大模型平台的权限:QianfanFullControlAccessPolicy
  • 运维操作千帆大模型平台预测服务的权限:QianfanServiceOperateAccessPolicy
  • 只读访问千帆大模型平台预测服务的权限:QianfanServiceReadAccessPolicy

SDK调用

调用示例

import os
from qianfan  import resources

# 通过环境变量初始化认证信息
# 使用安全认证AK/SK调用,替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk,如何获取请查看https://cloud.baidu.com/doc/Reference/s/9jwvz2egb
os.environ["QIANFAN_ACCESS_KEY"] = "your_iam_ak"
os.environ["QIANFAN_SECRET_KEY"] = "your_iam_sk"

resp = resources.console.utils.call_action(
    # 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
    "/v2/computeunit", 
    # 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action 
    "DescribeComputeUnit", 
    # 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
    {
        "instanceId":"unit-xxx"
    }
)
print(resp.body)
package main

import (
    "context"
    "fmt"
    "os"

    "github.com/baidubce/bce-qianfan-sdk/go/qianfan"
)

func main() {
     // 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
    os.Setenv("QIANFAN_ACCESS_KEY", "your_iam_ak")
    os.Setenv("QIANFAN_SECRET_KEY", "your_iam_sk")
    
    ca := qianfan.NewConsoleAction()
    
    res, err := ca.Call(context.TODO(), 
     // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
    "/v2/computeunit",
    // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action 
     "DescribeComputeUnit",
     // 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
      map[string]interface{}{
        "instanceId":"unit-xxx",
    })
    if err != nil {
        panic(err)
    }
    fmt.Println(string(res.Body))
    
}
import com.baidubce.qianfan.Qianfan;
import com.baidubce.qianfan.model.console.ConsoleResponse;
import com.baidubce.qianfan.util.CollUtils;
import com.baidubce.qianfan.util.Json;
import java.util.Map;

public class Dome {
    public static void main(String args[]){
        // 使用安全认证AK/SK鉴权,替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
        Qianfan qianfan = new Qianfan("your_iam_ak", "your_iam_sk");
        
        ConsoleResponse<Map<String, Object>> response = qianfan.console()
                // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
                .route("/v2/computeunit")
                // 调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action 
                .action("DescribeComputeUnit")
                // 需要传入参数的场景,可以自行封装请求类,或者使用Map.of()来构建请求Body
                // Java 8可以使用SDK提供的CollUtils.mapOf()来替代Map.of()
                // 请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
                .body(CollUtils.mapOf(
                     "instanceId","unit-xxx"
                ))
                .execute();

        System.out.println(Json.serialize(response));
    }
}
import {consoleAction, setEnvVariable} from "@baiducloud/qianfan";

// 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
setEnvVariable('QIANFAN_ACCESS_KEY','your_iam_ak');
setEnvVariable('QIANFAN_SECRET_KEY','your_iam_sk');

async function main() {
  //base_api_route:调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求结构-请求地址的后缀
  //action:调用本文API,该参数值为固定值,无需修改;对应API调用文档-请求参数-Query参数的Action 
  //data:请查看本文请求参数说明,根据实际使用选择参数;对应API调用文档-请求参数-Body参数
  const res = await consoleAction({base_api_route: '/v2/computeunit', action: 'DescribeComputeUnit', data: {
        "instanceId":"unit-xxx"
  });    
    
  console.log(res);
}

main();

返回示例

{
    "requestId":"1bef3f87-c5b2-4419-936b-50f9884f10d4",
    "result": {
        "computeUnitInstance": {
            "instanceId": "unit-xxx",
            "region": "bj",
            "status": "Running",
            "type": "gpu-1",
            "totalComputeUnits": 4,
            "usedComputeUnits": 2,
            "paymentTiming": "Prepaid",
            "startTime": "2024-12-03T06:24:03Z",
            "expiredTime": "2025-01-03T06:24:03Z",
            "reservationLength": 1,
            "reservationTimeUnit": "MONTH",
            "creator": "xxx",
            "autoRenew": {
                "renewTime": 4,
                "renewTimeUnit": "month"
            }
        },
        "serviceInfoList": [
            {
                "serviceName": "xxxx",
                "serviceId": "svco-xxxx",
                "runStatus": "Serving",
                "deployedComputingUnits": 1,
                "creator": "xxxx"
            }
        ]
    }
}
{
    "requestId":"1bef3f87-c5b2-4419-936b-50f9884f10d4",
    "result": {
        "computeUnitInstance": {
            "instanceId": "unit-xxx",
            "region": "bj",
            "status": "Running",
            "type": "gpu-1",
            "totalComputeUnits": 4,
            "usedComputeUnits": 2,
            "paymentTiming": "Prepaid",
            "startTime": "2024-12-03T06:24:03Z",
            "expiredTime": "2025-01-03T06:24:03Z",
            "reservationLength": 1,
            "reservationTimeUnit": "MONTH",
            "creator": "xxx",
            "autoRenew": {
                "renewTime": 4,
                "renewTimeUnit": "month"
            }
        },
        "serviceInfoList": [
            {
                "serviceName": "xxxx",
                "serviceId": "svco-xxxx",
                "runStatus": "Serving",
                "deployedComputingUnits": 1,
                "creator": "xxxx"
            }
        ]
    }
}
{
    "requestId":"1bef3f87-c5b2-4419-936b-50f9884f10d4",
    "result": {
        "computeUnitInstance": {
            "instanceId": "unit-xxx",
            "region": "bj",
            "status": "Running",
            "type": "gpu-1",
            "totalComputeUnits": 4,
            "usedComputeUnits": 2,
            "paymentTiming": "Prepaid",
            "startTime": "2024-12-03T06:24:03Z",
            "expiredTime": "2025-01-03T06:24:03Z",
            "reservationLength": 1,
            "reservationTimeUnit": "MONTH",
            "creator": "xxx",
            "autoRenew": {
                "renewTime": 4,
                "renewTimeUnit": "month"
            }
        },
        "serviceInfoList": [
            {
                "serviceName": "xxxx",
                "serviceId": "svco-xxxx",
                "runStatus": "Serving",
                "deployedComputingUnits": 1,
                "creator": "xxxx"
            }
        ]
    }
}
{
    requestId:'1bef3f87-c5b2-4419-936b-50f9884f10d4',
    result: {
        computeUnitInstance: {
            instanceId: 'unit-xxx',
            region: 'bj',
            status: 'Running',
            type: 'gpu-1',
            totalComputeUnits: 4,
            usedComputeUnits: 2,
            paymentTiming: 'Prepaid',
            startTime: '2024-12-03T06:24:03Z',
            expiredTime: '2025-01-03T06:24:03Z',
            reservationLength: 1,
            reservationTimeUnit: 'MONTH',
            creator: 'xxx',
            autoRenew: {
                renewTime: 4,
                renewTimeUnit: 'month'
            }
        },
        serviceInfoList: [
            {
                serviceName: 'xxxx',
                serviceId: 'svco-xxxx',
                runStatus: 'Serving',
                deployedComputingUnits: 1,
                creator: 'xxxx'
            }
        ]
    }
}

请求参数

名称 类型 必填 描述
instanceId string 实例ID,说明:该字段通过调用购买算力单元接口,返回的instanceId获取

返回参数

名称 类型 描述
requestId string 请求ID
result object 请求结果

result说明

名称 类型 描述
computeUnitInstance object 资源信息
serviceUsageList List<serviceInfo> 服务信息

computeUnitInstance说明

名称 类型 描述
instanceId string 实例ID
region string 资源地域,具体值如下:
· bj:北京
· bd:保定
· sz:苏州
· gz:广州
· yq:阳泉
· global:全局
status string 资源状态,具体值如下:
· Creating:创建中
· CreateFailed:创建失败
· Running:使用中
· Releasing:释放中
· Released:已释放
· Reconfiguring:变配中
· ReconfigureFailed:变配失败
type string 资源类型,具体值如下:
· CPU:cpu
· 加速卡I型:gpu-1
· 加速卡Ⅱ型:gpu-2
· 加速卡Ⅲ型:gpu-3
· 加速卡Ⅳ型:gpu-4
· 加速卡Ⅴ型:gpu-5
· 加速卡Ⅵ型:gpu-6
totalComputeUnits int 算力单元总数
usedComputeUnits int 已用算力单元数
paymentTiming string 资源付费类型,具体值如下:
· Prepaid:预付费
· Postpaid:后付费
startTime string 算力单元实例的开始时间
expiredTime string 算力单元实例的到期时间
releaseTime string 自动释放时间,说明:当资源付费类型为后付费且有设置自动释放时间时,返回该字段
reservationLength int 实例时长,说明:当资源付费类型为预付费,即paymentTiming=Prepaid时,返回该字段
reservationTimeUnit string 实例时长单位,说明:当资源付费类型为预付费,即paymentTiming=Prepaid时,返回该字段
creator string 资源创建人
autoRenew object 自动续费设置信息,说明:当资源付费类型为预付费且有设置自动续费规则时,返回该字段

autoRenew说明

名称 类型 描述
renewTime int 续费时长
renewTimeUnit string 续费时长单位,具体值如下:
· MONTH:月
· YEAR:年

serviceInfo说明

名称 类型 描述
serviceName string 服务名称
serviceId string 服务ID
runStatus string 服务状态,具体值如下:
· New:待发布
· Deploying:发布中
· Serving:已发布
· Failed:发布失败
· Deactivating:下线中
· DeactivationFailed:下线失败
scaleStatus string 扩缩容状态,具体值如下:
· ScalingIn:缩容中
· ScalingOut:扩容中
· ScalingFailed:扩缩容失败
deployedComputingUnits int 部署使用算力单元数,等于单副本算力单元数*部署副本数
creator string 创建人
上一篇
查询算力单元列表
下一篇
算力单元变配