Skip to content
This repository was archived by the owner on Jul 24, 2026. It is now read-only.

Expose cache hit rate and model distribution in AI usage API - #44

Merged
leoxk merged 1 commit into
mainfrom
codex/ai-usage-cache-models
Jul 21, 2026
Merged

Expose cache hit rate and model distribution in AI usage API#44
leoxk merged 1 commit into
mainfrom
codex/ai-usage-cache-models

Conversation

@leoxk

@leoxk leoxk commented Jul 21, 2026

Copy link
Copy Markdown
Owner

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

扩展 username-scoped AI Usage API,在每个 API key 的现有滚动 Token 统计旁增加 7 天缓存命中率和模型分布。缓存命中率按 cache_tokens / prompt_tokens 计算;模型分布按输入与输出 Token 总量降序返回。响应升级为 schema version 4,现有字段保持不变。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • Bug fix 说明: 本变更不是 Bug fix。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

  • go test ./model ./service ./router 通过。
  • go test ./... 中所有可编译包通过;仓库根包因未生成 web/classic/dist/index.html 无法在纯后端检出中编译,这是现有前端构建前置条件。
  • 生产只读查询计划显示 7 天明细读取约 122 ms;接口结果继续使用现有 5 分钟缓存。

@leoxk
leoxk merged commit 3a5b8ef into main Jul 21, 2026
5 checks passed
@leoxk
leoxk deleted the codex/ai-usage-cache-models branch July 21, 2026 05:05
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.

1 participant