{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"这篇解决什么问题"}]},{"type":"text","value":"：让财务系统、ERP 或看板能自动从 Tare 拉取账目，不用人工登录控制台。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"对账 API 是给"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"机器"}]},{"type":"text","value":"用的账务接口。它用 Reconciliation key（对账 key）认证，不用 Inference key（推理 key），也不需要模拟登录控制台。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"什么时候用对账 API"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"每天同步余额和交易流水。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"月底拉取已锁定的账单。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"按 key、模型、日期拆分用量。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"对比 Tare 的账目和你上游供应商的账单。"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"接入建议"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"创建一把 Reconciliation key。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"给它设置过期时间。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"从 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/whoami"}]},{"type":"text","value":" 开始，先确认账号、账期和时区。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"同步 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/balance"}]},{"type":"text","value":" 和 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/transactions"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"月底同步 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/statements"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"需要业务拆分时，拉 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/usage/daily"}]},{"type":"text","value":" 和 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/attribution"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"需要核对上游账单时，拉 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/reconciliation"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Reconciliation key "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"只能读账"}]},{"type":"text","value":"，不能调用模型，也不能管理 key。反过来也一样，"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"不要把能花钱的 Inference key 放进财务系统"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"img","properties":{"src":"diagram:integration-api-sequence","alt":"对账 API 的接入顺序：从 whoami 起步，到月底拉账单","data-block":"true"},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"详细说明"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"用对账 key，不要用推理 key"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"对账接口需要一把"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"对账 key"}]},{"type":"text","value":"（integration key）。在控制台 API Keys 页新建，类型选 Reconciliation；也可以由平台代为签发。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"三类 key 的权限互不重叠。用错类型会返回"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"明确的拒绝"}]},{"type":"text","value":"，而不是含糊的 401："}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Key 类型"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"权限"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"推理 key"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"调用模型"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"对账 key"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"读取报表，"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"不能调用模型"}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"母钥"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"管理 key，"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"既不能调用模型，也不能读取账务"}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"接口"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Base："},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"https://tare.jamerly.ai/v1/integration"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"路径"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"用途"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/whoami"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"这把 key 属于谁、当前账期、可访问的资源"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/balance"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"余额、授信额度、可用额度、累计充值与消费"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/transactions"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"流水，分页"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/statements"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"月度账单列表"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/statements/{period}"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"某一期的账单，如 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"2026-07"}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/usage/daily"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"按天的用量，可按 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"apiKeyId"}]},{"type":"text","value":" 过滤"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/attribution"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"成本、请求数、重试 / 工具失败浪费，"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"按模型、按阶段（stage）拆分"}]},{"type":"text","value":"。目前不支持按 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage_label"}]},{"type":"text","value":"、"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"task_id"}]},{"type":"text","value":"、"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"action_code"}]},{"type":"text","value":" 过滤，只有 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" / "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"to"}]},{"type":"text","value":" / "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"apiKeyId"}]},{"type":"text","value":" 三个参数"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/reconciliation"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"平台账目与上游账单的差异"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"curl https://tare.jamerly.ai/v1/integration/balance \\\n  -H \"Authorization: Bearer $TARE_INTEGRATION_KEY\"\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"这个响应只包一层"}]},{"type":"text","value":"（"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"response.data.balance"}]},{"type":"text","value":"）。如果你自己在前面又架了一层 Java 网关、经它转发这个路径（而不是像上面这样直接打 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"tare.jamerly.ai"}]},{"type":"text","value":"），网关会再套一层它自己的信封，变成两层嵌套（"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"response.data.data.balance"}]},{"type":"text","value":"）。具体怎么判断自己拿到的是哪一种，见"},{"type":"element","tagName":"a","properties":{"href":"errors"},"children":[{"type":"text","value":"错误码"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"粒度：余额是账号级，用量可以按 key 拆"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/balance"}]},{"type":"text","value":" 和 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/transactions"}]},{"type":"text","value":" 是"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"账号级"}]},{"type":"text","value":"的，同一个账号下所有 key 共享一个钱包。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"这和 key 的定位一致："},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"一把 key 是一个账单单元"}]},{"type":"text","value":"，用量可以按 key 拆，余额是共享的。要限制单把 key 的消费，请用"},{"type":"element","tagName":"a","properties":{"href":"provisioning"},"children":[{"type":"text","value":"母钥"}]},{"type":"text","value":" 的 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit"}]},{"type":"text","value":"，那是另一套机制。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"按 key 拆用量"}]},{"type":"text","value":"："},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/usage/daily?apiKeyId=…"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"两个限制"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"单次查询窗口上限 100 天。"}]},{"type":"text","value":" 一年的对账要分四次拉取。超出会返回明确错误，不会静默截断——一个从 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"from=2020-01-01"}]},{"type":"text","value":" 起算的定时任务，会在这里明确失败，而不是拿到一份被悄悄砍短的数据。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"限流 1200 次 / 分钟"}]},{"type":"text","value":"，与模型流量分开计算。对账往往要按天、按 key、按模型翻上百页，按模型那一档的阈值"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"会在首次接入时就 429"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"字段稳定性"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"这些接口的返回字段是"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"稳定承诺"}]},{"type":"text","value":"，不会因为后续实现调整而改名。需要 OpenAPI / JSON Schema 描述文件时，见"},{"type":"element","tagName":"a","properties":{"href":"endpoints"},"children":[{"type":"text","value":"接口列表"}]},{"type":"text","value":" 最后一节。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"对账的两个前提"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"账期按某个时区切分。"}]},{"type":"text","value":" "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"2026-07"}]},{"type":"text","value":" 只是一个字符串，它的起始时刻并不自明，所以每个响应都会带上切分所用的时区。如果你那边按别的时区切分月份，月末当天的用量会落入不同月份，两边永远对不平，而且差额小到足以被误认为舍入误差。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"迟到的更正计入下一期。"}]},{"type":"text","value":" 已锁定的账单不会被改写。如果你的 ERP 预期「更正到达后，上个月的数字会跟着变」，那不会发生。请到当期去找补差行，它会注明来自哪个月。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"下一步"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"想理解账单为什么会锁定、补差从哪来：读 "},{"type":"element","tagName":"a","properties":{"href":"statements"},"children":[{"type":"text","value":"账单与发票"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"想弄清哪些费用算在你头上：读 "},{"type":"element","tagName":"a","properties":{"href":"billing"},"children":[{"type":"text","value":"计费规则"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"想看全部可用接口：读 "},{"type":"element","tagName":"a","properties":{"href":"endpoints"},"children":[{"type":"text","value":"接口列表"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"}]}]}