BEEOS CLOUD / DEVELOPER REFERENCE
用量
用量汇总。
概览
usage domain 返回你的产品的用量汇总。
1 个操作 · SDK 资源:TypeScript cloud.usage · Python cloud.usage · Go cloud.Usage · API 总览
主要对象
ServerUsageSummary:用量汇总。
ServerUsageSummary
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
total_bc | string | 是 | 统计周期内的总费用,单位为 BC micros(BeeOS Credit,即 BC,的百万分之一),十进制字符串。例如 1500000 即 1.5 BC。 |
total_records | integer | 是 | 统计周期内的用量记录数。 |
by_category | map<string, string> | 是 | 统计周期内按类别统计的费用,单位为 BC micros,十进制字符串,以类别为键。周期内没有用量的类别不出现。 |
by_app | map<string, string> | 否 | 按应用统计的费用,单位为 BC micros,十进制字符串。Server API key 只能看到自己的应用,因此不向它们返回该字段。 |
category_counts | map<string, integer> | 是 | 统计周期内按类别统计的用量记录数,以类别为键。周期内没有用量的类别不出现。 |
完整字段和使用该对象的方法见附录。
典型流程
- 调用
usage.getSummary;其period参数取day、week或month。
方法
| 方法 | HTTP | 摘要 |
|---|---|---|
| usage.getSummary | GET /v1/usage/summary | 获取用量汇总 |
usage.getSummary
GET /v1/usage/summary · Operation ID getUsageSummary
获取用量汇总
SDK 方法
| 语言 | 方法 | 签名 |
|---|---|---|
| TypeScript | cloud.usage.getSummary | getSummary(query: Models.GetUsageSummaryQuery): Promise<Models.GetUsageSummaryResponse> |
| Python | cloud.usage.get_summary | def get_summary(self, options: GetUsageSummaryOptions | None = None) -> ServerUsageSummary |
| Go | cloud.Usage.GetSummary | func (r *UsageResource) GetSummary(ctx context.Context, options GetUsageSummaryOptions) (ServerUsageSummary, error) |
参数
| 参数 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
period | query | string | 否 | 统计窗口的长度,窗口截止到现在:day 为最近 24 小时(默认),week 为最近 7 天,month 为最近 30 天。窗口随当前时间移动,不按自然日划分。 可选值: "day", "week", "month". |
category | query | string | 否 | 只统计该类别的用量,取 by_category 中出现的键之一。省略则统计所有类别。 |
响应
200 · application/json · Schema: ServerUsageSummary
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
total_bc | string | 是 | 统计周期内的总费用,单位为 BC micros(BeeOS Credit,即 BC,的百万分之一),十进制字符串。例如 1500000 即 1.5 BC。 |
total_records | integer | 是 | 统计周期内的用量记录数。 |
by_category | map<string, string> | 是 | 统计周期内按类别统计的费用,单位为 BC micros,十进制字符串,以类别为键。周期内没有用量的类别不出现。 |
by_app | map<string, string> | 否 | 按应用统计的费用,单位为 BC micros,十进制字符串。Server API key 只能看到自己的应用,因此不向它们返回该字段。 |
category_counts | map<string, integer> | 是 | 统计周期内按类别统计的用量记录数,以类别为键。周期内没有用量的类别不出现。 |
错误
| 状态码 | Schema | 说明 |
|---|---|---|
| 其他(default) | ErrorResponse | Cloud Server 错误 |
错误 schema 见错误。
示例
import { BeeOSClient } from "@beeos-ai/cloud-sdk";
const cloud = new BeeOSClient({
baseURL: "https://api.cloud.beeos.ai/v1",
apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.usage.getSummary({});
console.log(result);BeeOS Cloud返回文档首页