组织 API

2026-10-20

组织 API

基础地址

加载中…

接入

加载中…

事实与边界

事实说明
组织由 Key 决定调用方的 API Key 解析出唯一的组织;路径里没有组织 ID,组织的任何有效 API Key 都可读本域
只覆盖实际扣费统计组织实际被扣的费用,按结算币种(人民币 CNY 或美元 USD)计;组织的赠送额度先于现金被扣,也在其中
字段名按 FOCUS 1.3BilledCost、ServiceName、ConsumedQuantity 等列名与 FOCUS 1.3 规范逐字一致
时间一律 UTC窗口边界与时间桶都是 UTC ISO 8601;桶对齐到整点或自然日
查询窗口上限 93 天查询费用 / 查询用量 / 用量事件一次最多查 93 天;更久的账用费用明细导出,它按天在服务端分页
分页是不透明游标列表带 has_more 与 next_page;把 next_page 原样放进 page 参数取下一页

金额都是十进制字符串(如 "0.001234"),币种见同一行的 BillingCurrency(CNY 或 USD);不要用浮点数相加——对账请按字符串精确十进制求和,且不同币种不要相加。

这里只统计从资金账户以美元扣费的用量;Credits 余额不在这个域。鉴权方式见鉴权。

端点

方法路径说明支持
GET/v1/costs查询费用● 支持
GET/v1/usage查询用量● 支持
GET/v1/events列出用量事件● 支持
GET/v1/events/{id}查看单个用量事件● 支持
GET/v1/charges导出费用明细● 支持

与官方的差异

  • 聚合信封照 OpenAI organization usage/costs、分桶与 estimated 标记照 AWS GetCostAndUsage、列名按 FOCUS 1.3、明细导出照 Vercel charges 的 JSONL。只给原始事实:占比、环比、前 N 名等派生视图不在本域,请在调用方自行计算。

参数与字段的权威定义以本站 /meta/v1/openapi.yaml 公开的规范与 FOCUS 1.3 规范为准。

错误按 problem+json 格式返回,参见错误;额度与响应头参见限流。

查询费用

GET /organization/v1/costs● 支持

官方参考 ↗

请求参数

  • 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. The window widens to whole local buckets; a day that crosses a daylight-saving change lasts 23 or 25 hours. starting_at and ending_at stay UTC instants.

  • group_byarray可选

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

  • pagestring可选

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

返回

200 page

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

响应

HTTP 200

Cost page

application/json

名称类型说明
objectstringObject type; always `page`.
dataarray<object>Cost buckets in time order, one per hour or day of the requested window.
data[].objectstringObject type; always `bucket`.
data[].starting_atstringStart of the bucket, UTC, inclusive.
data[].ending_atstringEnd of the bucket, UTC, exclusive.
data[].estimatedbooleanAlways false; kept for the AWS GetCostAndUsage shape.
data[].resultsarray<object>Aggregates of the bucket, one entry per group requested with group_by.
has_morebooleanWhether more results exist beyond this page; request again with `page` set to `next_page` to read them.
next_pagestring | nullOpaque cursor for the next page; null on the last page. Pass it unchanged as `page`.

响应字段

字段说明
object固定 "page"
data[].object固定 "bucket"
data[].starting_at / data[].ending_at桶的起止时间(UTC,整点或自然日对齐)
data[].estimated恒为 false:费用入账即为最终金额;保留该字段是为了与 AWS GetCostAndUsage 的形状一致
data[].results[].ServiceName产生用量的服务名(仅在请求 group_by 含 ServiceName 时出现)
data[].results[].ServiceCategoryFOCUS 服务类别(仅按请求出现)
data[].results[].ResourceId / data[].results[].ResourceName资源 ID 与显示名;ResourceName 随 ResourceId 附带,解析不到显示名时等于 ResourceId
data[].results[].BilledCost该桶该组的费用,十进制字符串,币种见 BillingCurrency
data[].results[].BillingCurrency扣费币种,CNY 或 USD;同一组在一个桶里用过两种币种时分成两行
has_more / next_page是否还有下一页;下一页的不透明游标(null 表示没有更多)

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

查询用量

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. The window widens to whole local buckets; a day that crosses a daylight-saving change lasts 23 or 25 hours. starting_at and ending_at stay UTC instants.

  • group_byarray可选

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

  • pagestring可选

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

返回

200 page

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

响应

HTTP 200

Usage page

application/json

名称类型说明
objectstringObject type; always `page`.
dataarray<object>Usage buckets in time order, one per hour or day of the requested window.
data[].objectstringObject type; always `bucket`.
data[].starting_atstringStart of the bucket, UTC, inclusive.
data[].ending_atstringEnd of the bucket, UTC, exclusive.
data[].estimatedbooleanAlways false; kept for the AWS GetCostAndUsage shape.
data[].resultsarray<object>Aggregates of the bucket, one entry per group requested with group_by.
has_morebooleanWhether more results exist beyond this page; request again with `page` set to `next_page` to read them.
next_pagestring | nullOpaque 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游标分页,与查询费用相同

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

列出用量事件

GET /organization/v1/events● 支持

官方参考 ↗

请求参数

  • starting_atstring必填

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

  • ending_atstring必填

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

  • limitinteger可选

    query: 每页条数,1–100,默认 25

  • pagestring可选

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

返回

200 page

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

响应

HTTP 200

Event page

application/json

名称类型说明
objectstringObject type; always `page`.
dataarray<object>Usage events, newest first.
data[].objectstringObject type; always `usage.event`.
data[].idstringId of the usage event; pass it to getOrganizationEvent.
data[].occurred_atstringTime at which the usage happened, UTC.
data[].ServiceNamestringName of the platform service that produced the usage (the source service of the usage event).
data[].ServiceCategorystringCategory of the service; a service without a registered category reports its own name.
data[].ResourceIdstringId of the resource that the usage belongs to.
data[].ResourceNamestringDisplay name of the resource; falls back to ResourceId when no name is known.
data[].BilledCoststringAmount billed in USD as an exact decimal string; unsettled usage counts as 0 until it settles.
data[].BillingCurrencystringCurrency of BilledCost; always `USD`.
data[].ChargeClassstring | null`Correction` for an event that corrects an earlier charge (its BilledCost is negative); null for ordinary usage.
data[].request_idstring | nullX-Request-Id of the API call that produced the usage; null for usage that does not come from a request.
data[].settlementobjectHow the usage was charged: settlement state, any shortfall, and why nothing was charged.
data[].linesarray<object>Metering lines mapped from the billing measurements; the priced split (ListUnitPrice, PricingUnit, BilledCost) rides only GET /events/{id}.
has_morebooleanWhether more results exist beyond this page; request again with `page` set to `next_page` to read them.
next_pagestring | nullOpaque cursor for the next page; null on the last page. Pass it unchanged as `page`.

响应字段

字段说明
object固定 "page"
data[].object固定 "usage.event"
data[].id事件 id;查单条明细、对账都用它
data[].occurred_at事件发生时间(UTC)
data[].ServiceName / ServiceCategory / ResourceId / ResourceNameFOCUS 服务与资源列
data[].BilledCost / BillingCurrency事件费用(十进制字符串)与扣费币种(CNY 或 USD)
data[].ChargeClass更正事件为 "Correction"(费用为负数),普通事件为 null
data[].request_id产生这次用量的那次 API 调用响应头 X-Request-Id 的值,可拿去调用日志里查同一次请求
data[].settlement.statussettled(已扣费)/ no_charge(已记录,不收费)/ rejected(计费拒绝了这次扣费)
data[].settlement.shortfall / data[].settlement.zero_reason目前恒为 null,保留给之后的结算细节
has_more / next_page按发生时间倒序逐页;游标不透明,不重复、不遗漏

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

查看单个用量事件

GET /organization/v1/events/{id}● 支持

官方参考 ↗

请求参数

  • idstring必填

    path: 用量事件 id,来自用量事件列表的 data[].id

返回

200 usage.event

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

响应

HTTP 200

The usage event

application/json

名称类型说明
objectstringObject type; always `usage.event`.
idstringId of the usage event; pass it to getOrganizationEvent.
occurred_atstringTime at which the usage happened, UTC.
ServiceNamestringName of the platform service that produced the usage (the source service of the usage event).
ServiceCategorystringCategory of the service; a service without a registered category reports its own name.
ResourceIdstringId of the resource that the usage belongs to.
ResourceNamestringDisplay name of the resource; falls back to ResourceId when no name is known.
BilledCoststringAmount billed in USD as an exact decimal string; unsettled usage counts as 0 until it settles.
BillingCurrencystringCurrency of BilledCost; always `USD`.
ChargeClassstring | null`Correction` for an event that corrects an earlier charge (its BilledCost is negative); null for ordinary usage.
request_idstring | nullX-Request-Id of the API call that produced the usage; null for usage that does not come from a request.
settlementobjectHow the usage was charged: settlement state, any shortfall, and why nothing was charged.
settlement.statusstringSettlement state of the event.
settlement.shortfallstring | nullUSD amount that could not be charged, as a decimal string, when status is settled_with_shortfall; null otherwise.
settlement.zero_reasonstring | nullWhy nothing was charged for the event: `byok` when the caller used its own provider key; null when a charge applies.
linesarray<object>Priced lines of the event; their BilledCost values add up to the event's BilledCost.
lines[].meterstringKey of the meter that measured the line.
lines[].display_namestringEnglish label of the meter; falls back to the meter key in list pages.
lines[].ConsumedQuantitystringQuantity consumed, an exact decimal string in ConsumedUnit.
lines[].ConsumedUnitstringUnit of ConsumedQuantity as reported by the metering line; quantities of different units are never added together.
lines[].ListUnitPricestring | nullList price in USD per PricingUnit as a decimal string; null when the line is not priced.
lines[].PricingUnitstring | nullUnit that ListUnitPrice applies to; null when the line is not priced.
lines[].BilledCoststringAmount billed for this line in USD as a decimal string.
x_Chargesarray<object>The transactions that paid this event; their BilledCost sums to the event's BilledCost.
x_Charges[].transaction_idstringThe id of the billing transaction that paid part of this event.
x_Charges[].BilledCoststringAmount billed in USD as an exact decimal string; unsettled usage counts as 0 until it settles.
x_Charges[].BillingCurrencystringCurrency of BilledCost; always `USD`.
x_Charges[].sub_accountstringWhich balance the transaction was taken from.

响应字段

字段说明
object / id / occurred_at固定 "usage.event"、事件 id、发生时间(UTC)
ServiceName / ServiceCategory / ResourceId / ResourceName / BilledCost / BillingCurrency / ChargeClass / request_id / settlement与用量事件列表中同一事件完全相同的字段
lines[].meter / lines[].display_name计量项标识与其英文显示名
lines[].ConsumedQuantity / ConsumedUnit该计量项的消耗数量与单位
lines[].ListUnitPrice / PricingUnit恒为 null:计费按整个事件定价,没有逐计量项的单价
lines[].BilledCost该计量项的费用,等于事件的 BilledCost
x_Charges[]支付这个事件的交易:transaction_id、BilledCost、BillingCurrency,以及 sub_account(promotional 赠送额度或 cash 现金;赠送额度先扣)。各笔相加等于事件的 BilledCost

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

导出费用明细

GET /organization/v1/charges● 支持

官方参考 ↗

请求参数

  • starting_atstring必填

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

  • ending_atstring必填

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

返回

200

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

响应

HTTP 200

FOCUS 1.3 JSONL stream

application/x-ndjson

名称类型说明
ChargePeriodStartstringStart of the charge period (the event time), UTC.
ChargePeriodEndstringEnd of the charge period (the event time), UTC.
BilledCoststringAmount billed in USD as an exact decimal string; unsettled usage counts as 0 until it settles.
BillingCurrencystringCurrency of BilledCost; always `USD`.
ServiceNamestringName of the platform service that produced the usage (the source service of the usage event).
ServiceCategorystringCategory of the service; a service without a registered category reports its own name.
ResourceIdstringId of the resource that the usage belongs to.
ResourceNamestringDisplay name of the resource; falls back to ResourceId when no name is known.
ConsumedQuantitystringQuantity consumed, an exact decimal string in ConsumedUnit.
ConsumedUnitstringUnit of ConsumedQuantity as reported by the metering line; quantities of different units are never added together.
ChargeCategorystringKind of charge.
ChargeClassstring | null`Correction` for an event that corrects an earlier charge (its BilledCost is negative); null for ordinary usage.
ChargeDescriptionstringText such as `<service>/<offering> usage` that says what was charged.
x_RequestIdstring | nullAlways null in the export; look up the request id of an event with getOrganizationEvent.
x_EventIdstringId of the usage event this record comes from; pass it to getOrganizationEvent.

响应字段

字段说明
ChargePeriodStart / ChargePeriodEnd计费周期起止(UTC)
BilledCost / BillingCurrency该事件费用(十进制字符串)与扣费币种(CNY 或 USD)
ServiceName / ServiceCategory / ResourceId / ResourceNameFOCUS 服务与资源列
ConsumedQuantity / ConsumedUnit消耗数量与计量单位
ChargeCategoryUsage(用量)或 Adjustment(调整)
ChargeClass更正记录为 "Correction",普通记录为 null
ChargeDescription计量项的人类可读描述
x_RequestId / x_EventId产生这条记录的 API 调用的 X-Request-Id;对应的用量事件 id

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