Add China API models.dev pricing lookup - #2376
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac458da2f6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs changes before merge. Reviewed August 9, 2026, 6:38 PM ET / 22:38 UTC. ClawSweeper reviewWhat this changesAdds models.dev pricing lookup and Pi-session cost reporting for Alibaba plans, z.ai, and DeepSeek through CodexBar’s cost command. Merge readiness⛔ Blocked by patch quality or review findings - 4 items remain Keep open. The useful cost-reporting capability is not on current main, but the rebased PR still prices China-region configurations through fixed catalog priority, so configured China users can receive incorrect estimates. Priority: P2 Review scores
Verification
How this fits togetherCodexBar’s cost command reads local Pi session JSONL usage and applies cached models.dev rates to produce daily and session cost estimates. Provider descriptors expose those estimates in the CLI and app. flowchart LR
A[Pi session JSONL] --> B[Cost scanner]
C[Provider settings] --> B
D[models.dev catalog cache] --> E[Pricing lookup]
B --> E
E --> F[Daily cost report]
F --> G[Cost CLI and app]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Thread the already-persisted provider region into pricing-catalog selection and prove divergent international/China catalog rates through the normal cost path before merging. Do we have a high-confidence way to reproduce the issue? Yes. Set Alibaba to China mainland or z.ai to BigModel CN and use fixtures with overlapping model IDs but divergent regional prices; the current resolver has no region input to select the matching catalog. Is this the best way to solve the issue? No. Provider-specific lookup is the right seam, but fixed catalog order is not sufficient where existing provider settings choose a different regional endpoint and price catalog. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a0d77c37f9cc. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (28 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
68c556c to
bccd82b
Compare
|
Thanks for the models.dev pricing series! The China API provider mappings (Alibaba, z.ai, DeepSeek) here haven't landed on |
0fdb20e to
43dcba1
Compare
…DevCostUSD out of enum to satisfy lint limits
The hash commits were dropped during the rebase. Regenerate the final hash now that all China pricing changes are applied.
ClawSweeper flagged that .alibaba and .alibabatokenplan fell back to the direct 'alibaba' catalog when their dedicated plan catalogs lacked a model. Plan billing can differ from direct API billing, so return no estimate instead. Add regression coverage for missing plan-catalog rows.
740a86b to
5ce6ad6
Compare
|
@steipete — this PR has been rebased onto latest main and is ready for review. Thanks! |
After rebasing the China API models.dev pricing work, ProviderArchitectureGatekeeperTests failed because new provider-specific branches (Alibaba, Zai, DeepSeek) appeared in shared cost code and existing allowlist anchors shifted. Add '// Provider-specific by design:' markers at each provider-owned dispatch point, update the gatekeeper's hardcoded supportsTokenSnapshot set and shifted suppressed references, and remove obsolete CostUsageFetcher/PiSessionCostScanner allowlist entries whose anchors no longer match. Closes provider-architecture gatekeeper failures on the China API rebase.
Summary
models.devpricing lookup for China API provider families.alibaba-coding-plan/alibaba-coding-plan-cn, Alibaba token plans toalibaba-token-plan/alibaba-token-plan-cn, z.ai tozai/zai-coding-plan, and DeepSeek todeepseek.codexbar cost.Proof
models.devprovider pricing mappings. PR feat(providers): add Qwen Cloud individual token-plan provider #2361 adds Qwen Cloud token-plan usage, not Qwen model pricing lookup.git grep -n -E "glm-5\.1|glm-5v-turbo|qwen3\.7-max|deepseek-v4-pro" origin/main -- Sources Tests docshttps://models.dev/api.jsonshowed these live provider keys:alibaba,alibaba-cn,alibaba-coding-plan,alibaba-coding-plan-cn,alibaba-token-plan,alibaba-token-plan-cn,deepseek,zai,zai-coding-plan,zhipuai,zhipuai-coding-plan.alibaba-coding-plan:qwen3.7-max/ input 2.5 / output 7.5 / cache_read 0.5 / cache_write 3.125alibaba-token-plan:qwen3.7-plus/ input 0 / output 0 / cache_read 0 / cache_write 0zai:glm-5v-turbo/ input 1.2 / output 4 / cache_read 0.24 / cache_write 0zhipuai:glm-5v-turbo/ input 5 / output 22 / cache_read 1.2 / cache_write 0, intentionally not used for z.ai routingdeepseek:deepseek-v4-pro/ input 0.435 / output 0.87 / cache_read 0.003625 / context 1000000models.devfixture with deliberately divergent fallback entries, then verifiesPiSessionCostScanner.loadDailyReportcomputes provider-scopedcostUSDfor Alibaba coding plan, Alibaba token plan, z.ai, and DeepSeek Pi JSONL rows..pi/agent/sessions/2026-07-28T10-00-00-000Z_china-proof.jsonlcontaining only assistant rows. No real account files, Keychain, or browser cookies were read. Command shape:HOME=[temp] CFFIXED_USER_HOME=[temp] XDG_CONFIG_HOME=[temp]/.config XDG_CACHE_HOME=[temp]/.cache .build/debug/CodexBarCLI cost --provider <provider> --format json --pretty --refresh{ "provider" : "alibaba", "source" : "local", "sessionTokens" : 150000, "sessionCostUSD" : 0.625, "daily" : [{ "date" : "2026-07-28", "modelBreakdowns" : [{ "modelName" : "qwen3.7-max", "totalTokens" : 150000, "cost" : 0.625 }] }] } { "provider" : "alibabatokenplan", "source" : "local", "sessionTokens" : 150000, "sessionCostUSD" : 0, "daily" : [{ "date" : "2026-07-28", "modelBreakdowns" : [{ "modelName" : "qwen3.7-plus", "totalTokens" : 150000, "cost" : 0 }] }] } { "provider" : "zai", "source" : "local", "sessionTokens" : 180000, "sessionCostUSD" : 0.3224, "daily" : [{ "date" : "2026-07-28", "modelBreakdowns" : [{ "modelName" : "glm-5v-turbo", "totalTokens" : 180000, "cost" : 0.3224 }] }] } { "provider" : "deepseek", "source" : "local", "sessionTokens" : 160000, "sessionCostUSD" : 0.08703625, "daily" : [{ "date" : "2026-07-28", "modelBreakdowns" : [{ "modelName" : "deepseek-v4-pro", "totalTokens" : 160000, "cost" : 0.08703625 }] }] }models.devcatalog foralibaba-token-plan/qwen3.7-plus.Verification
CLANG_MODULE_CACHE_PATH=/private/tmp/codexbar-clang-cache swift test --disable-sandbox --scratch-path /Users/mosaab/Documents/Projects/CodexBar/.build --filter PiSessionCostScannerTests: 19 tests passed.CLANG_MODULE_CACHE_PATH=/private/tmp/codexbar-clang-cache swift test --disable-sandbox --scratch-path /Users/mosaab/Documents/Projects/CodexBar/.build --filter 'provider lookup resolves current China API models': 1 test passed.git diff --check: clean.make checkcompleted generated parser hash, package/docs/locales checks, SwiftFormat lint mode, and SwiftLint strict with 0 violations, then exited on the sandbox-only macOS plist cache write permission error after lint shutdown.No live provider probes, browser-cookie imports, or Keychain reads were run.