fix(usage): bill Codex Fast from requested tier#415
Conversation
Select the request-side service tier for Codex usage while preserving response-tier precedence for other providers. Keep requested and reported tiers separately across normalization, import, and persistence, with regression coverage for both provider semantics.
Use the requested tier for Codex fallback pricing and retain response-tier billing semantics for other providers. Expose both requested and reported tiers in realtime monitoring, preserve legacy Codex identity metadata, and add localized regression coverage.
|
@seakee |
这个问题之前考虑过,但当前 CPAMP 无法仅从使用数据中获取 payload.override 后的最终 tier。 以下两种请求会产生完全相同的使用数据:
Codex 即使实际发送 priority,响应也可能报告 default,因此响应字段也不能作为可靠依据。 要彻底解决,必须由 CLIProxyAPI 在应用 override 后,从最终出站请求中提取 tier,并在使用数据中增加例如: { CPAMP读取 CPA 配置并自行复算理论上可尝试,但规则可能依赖请求头、协议、原始 payload 和匹配顺序,无法保证准确,不建议作为计费依据。所以根源生还是需要 CPA 去做的,根据以往我给 CPA 提 PR 好久都不会看的经验,建议你直接去 CPA 那边提 issue,这样就有可能会得到解决。 |
Summary
Fix Codex Fast usage pricing when CPA records a requested priority tier but reports default in the upstream response. Requested and reported tiers remain separately available for diagnosis.
Scope
Changes
User Impact
Codex OAuth requests made with priority or Fast mode are priced with the expected multiplier even when the response reports default. Realtime monitoring shows both requested and reported tiers.
Compatibility / Runtime Notes
Data / Security Notes
No schema or sensitive-data changes. Existing requested and reported tier fields remain separate. Historical pre-aggregated rows are not automatically repriced.
Risk / Rollback
Risk level: Low
Rollback notes: Revert the two commits to restore response-tier precedence and the previous single-tier presentation.
Verification
Commands / evidence:
Build was not rerun because this change does not alter bundling or asset behavior.
Screenshots / Recordings
Not captured. The visible change is limited to requested/reported tier labels and is covered by the realtime panel render test.
Docs
Docs decision: This corrects existing monitoring and billing semantics without adding configuration or a new workflow.
Related
Refs #372
Refs router-for-me/CLIProxyAPI#4486.