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: found issues before merge. Reviewed August 12, 2026, 5:14 AM ET / 09:14 UTC. ClawSweeper reviewWhat this changesThis PR adds models.dev pricing lookup and Pi-session cost reporting for Alibaba plan, z.ai, and DeepSeek providers in CodexBar’s cost command. Merge readinessKeep open: the prior P1 blocker remains on the current head, which can estimate costs from the wrong regional catalog; the branch is also dirty against current main. Priority: P2 Review scores
Verification
How this fits togetherCodexBar reads local Pi session records and uses cached models.dev prices to estimate provider costs for CLI and dashboard output. The selected provider’s stored region must determine which vendor catalog supplies those rates. flowchart LR
A[Pi session records] --> C[Cost scanner]
B[Provider and region settings] --> C
C --> D[Catalog selection]
E[Cached models.dev catalog] --> D
D --> F[Cost estimate]
F --> G[CLI and dashboard output]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Carry an explicit selected pricing catalog or persisted provider region into the cost scanner, select one regional catalog rather than an ordered fallback, and cover divergent international and China fixtures. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: use a fixture where the same model has different international and China-region prices, configure Alibaba CN or z.ai BigModel CN, and the current provider-only lookup selects the wrong catalog. Is this the best way to solve the issue? No. Ordered catalog fallback cannot represent an already persisted regional choice; the selected region or catalog must be passed into pricing resolution. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a90dfed5c264. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (29 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.