跳转到内容
EN

查询用量

GET/organization/v1/usage● 支持

官方参考 ↗

请求参数

  • starting_atstring必填

    query: 窗口开始(含),UTC ISO 8601,如 2026-09-26T00:00:00Z

  • ending_atstring必填

    query: 窗口结束(不含),UTC ISO 8601;距 starting_at 最多 93 天(费用明细导出无此限制)

  • bucket_widthstring必填

    query: 时间桶宽度:1h(整点对齐)或 1d(自然日对齐),一律 UTC

    取值 1h1d
  • time_zonestring可选
    默认 "UTC"

    query: IANA time zone name (for example Asia/Shanghai) whose local hours or days form the buckets. Defaults to UTC. Offsets such as +08:00 are rejected. Only zones whose UTC offset is a whole number of hours across the whole window are supported; zones such as Asia/Kolkata (+05:30) or Asia/Kathmandu (+05:45) are rejected with 400 VALIDATION_ERROR, because Billing buckets in UTC hours and a local hour of those zones straddles two of them. With bucket_width=1d the window widens to whole local days, each bucket carries its real UTC starting_at and ending_at, and a day that crosses a daylight-saving change lasts 23 or 25 hours; the whole window is then answered in one page (has_more is false and page is not accepted). starting_at and ending_at stay UTC instants.

  • group_byarray可选

    query: 分组列,可重复:ServiceName、ServiceCategory、ResourceId、ConsumedUnit;查询用量时 ConsumedUnit 恒被服务端拆出

  • pagestring可选

    query: 上一页响应里 next_page 给出的不透明游标,原样带回即可

返回

200 page

错误按 problem+json 格式返回,参见 错误码

请求示例

curl
curl "https://api.deepraxis.com/organization/v1/usage?starting_at=2026-09-26T00:00:00Z&ending_at=2026-09-27T00:00:00Z&bucket_width=1d&group_by=ResourceId" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
Python
import requests

opts = dict(
    base_url="https://api.deepraxis.com/organization/v1",
    api_key="$PRAXIS_API_KEY",
)

# /organization 是我们自己的组织用量形状,直接发 HTTP 请求(Bearer 认证)
resp = requests.get(
    f"{opts['base_url']}/usage?starting_at=2026-09-26T00:00:00Z&ending_at=2026-09-27T00:00:00Z&bucket_width=1d&group_by=ResourceId",
    headers={"Authorization": f"Bearer {opts['api_key']}"},
)
print(resp.status_code, resp.json())
TypeScript
const opts = {
  baseURL: "https://api.deepraxis.com/organization/v1",
  apiKey: "$PRAXIS_API_KEY",
};

// /organization 是我们自己的组织用量形状,直接发 HTTP 请求(Bearer 认证)
const resp = await fetch(`${opts.baseURL}/usage?starting_at=2026-09-26T00:00:00Z&ending_at=2026-09-27T00:00:00Z&bucket_width=1d&group_by=ResourceId`, {
  headers: { Authorization: `Bearer ${opts.apiKey}` },
});
console.log(resp.status, await resp.json());

响应示例 200

{
  "object": "page",
  "data": [
    {
      "object": "bucket",
      "starting_at": "2026-10-15T00:00:00.000Z",
      "ending_at": "2026-10-16T00:00:00.000Z",
      "estimated": false,
      "results": [
        {
          "ServiceName": "router",
          "ServiceCategory": "AI and Machine Learning",
          "ResourceId": "deepseek-v4-flash",
          "ResourceName": "deepseek-v4-flash",
          "ConsumedQuantity": "1",
          "ConsumedUnit": "request",
          "x_EventCount": "1"
        }
      ]
    }
  ],
  "has_more": false,
  "next_page": null
}

响应

HTTP 200

Usage page

application/json

名称 类型 说明
object string Object type; always page.
data array<object> Usage buckets in time order, one per hour or day of the requested window.
data[].object string Object type; always bucket.
data[].starting_at string Start of the bucket, UTC, inclusive.
data[].ending_at string End of the bucket, UTC, exclusive.
data[].estimated boolean Always false; kept for the AWS GetCostAndUsage shape.
data[].results array<object> Aggregates of the bucket, one entry per group requested with group_by.
has_more boolean Whether more results exist beyond this page; request again with page set to next_page to read them.
next_page string | null Opaque cursor for the next page; null on the last page. Pass it unchanged as page.

响应字段

字段说明
object / data[].object固定 “page” / 固定 “bucket”
data[].starting_at / data[].ending_at / data[].estimated桶的起止(UTC)与 estimated 标记(恒为 false),与查询费用相同
data[].results[].ServiceName / ServiceCategory服务列(仅按请求出现)
data[].results[].ResourceId / data[].results[].ResourceName资源列;ResourceName 随 ResourceId 附带
data[].results[].ConsumedQuantity该桶该组的消耗数量,十进制字符串
data[].results[].ConsumedUnit计量单位;不同单位各成一行,永远不会相加
has_more / next_page游标分页,与查询费用相同

支付一个事件的交易明细见查看单个用量事件。