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 15, 2026, 12:20 PM ET / 16:20 UTC. ClawSweeper reviewWhat this changesThe PR adds models.dev-backed Pi-session cost estimates and Merge readinessKeep open: the PR remains useful, but its catalog selection ignores the configured regional provider profile, so China-region Alibaba and BigModel CN z.ai users can receive incorrect cost estimates. Priority: P2 Review scores
Verification
How this fits togetherCodexBar reads local Pi session JSONL files and combines token counts with cached models.dev pricing to produce menu and CLI cost reports. Provider configuration determines which regional service endpoint a profile represents, so pricing must use the matching catalog. flowchart LR
A[Pi session files] --> B[Cost scanner]
C[Provider profile region] --> D[Catalog selection]
E[models.dev cache] --> D
D --> B
B --> F[Daily cost report]
F --> G[Menu and CLI cost output]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Make cost estimates follow the already-configured provider region and preserve correct estimates across region changes. Do we have a high-confidence way to reproduce the issue? Yes—source reproducible: configure an Alibaba China or z.ai BigModel CN profile with catalog entries that differ from global rates; the new lookup accepts only the provider and always uses its fixed global-first order. Is this the best way to solve the issue? No: the provider-scoped lookup is the right seam, but it must receive the existing regional profile selection and make cached Pi prices sensitive to it. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f15f142a7787. LabelsLabel justifications:
EvidenceAcceptance criteria:
What 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 (31 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
740a86b to
5ce6ad6
Compare
|
@steipete — this PR has been rebased onto latest main and is ready for review. Thanks! |
a3b98f8 to
63704d9
Compare
…DevCostUSD out of enum to satisfy lint limits
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.
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.
63704d9 to
c79a442
Compare
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.