Skip to content

feat(accounts): estimate Claude OAuth and setup-token window costs - #8900

Merged
Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
stevelee477:feat/claude-window-cost-estimate
Nov 20, 2026
Merged

Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
stevelee477:feat/claude-window-cost-estimate

Conversation

@stevelee477

Copy link
Copy Markdown
Contributor

Claude OAuth 和 setup token 的用量窗口已有使用率,但缺少满额费用估算。这个改动复用现有 OpenAI 7d 的计算方式,在 Claude 通用 5h / 7d 窗口显示“预计总费用”。例如窗口费用 $12、使用率 40%,显示预计总费用 $30。

改动

  • 后端按上游重置时间减去窗口长度,查询对应的本地账号费用,避免把 5h 费用配上 7d 使用率。缓存按账号和窗口隔离,重置时间变化后立即失效。
  • 前端按 window_stats.cost * 100 / utilization 估算;使用率未知、费用或使用率无效时隐藏。重置时间缺失、窗口过期或推导起点在未来时不补费用统计。
  • setup token 继续使用响应头被动采样,不增加需要 profile scope 的上游请求。7d S / 7d F 缺少相同模型范围的费用统计,因此不套用全账号费用。

估算沿用账号费用口径,包含账号倍率。它表示按当前使用情况推算的满额费用,不代表官方账单;站外使用、采样延迟和模型组合都会影响结果。

验证

  • 前端账号用量、进度条和语言键完整性测试:94 项通过。
  • 后端窗口费用、setup token 周采样和批量查询测试:36 项(含子测试)通过。
  • 前端类型检查、修改文件的 ESLint、git diff --check 通过。

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@stevelee477

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Nov 17, 2026
@Wei-Shaw
Wei-Shaw merged commit 88ff563 into Wei-Shaw:main Nov 20, 2026
10 of 11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants