Add Google and xAI models.dev pricing lookup - #2377
Conversation
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 12:31 PM ET / 16:31 UTC. ClawSweeper reviewWhat this changesAdds models.dev-backed local Pi-session cost estimates and cost-CLI support for Gemini, Vertex AI, and Grok. Merge readinessKeep open: current main still lacks this provider-cost coverage, the prior gatekeeper blocker is addressed on the new head, and the PR has credible isolated runtime proof. A maintainer should audit the broad gatekeeper reclassification before merge. Priority: P2 Review scores
Verification
How this fits togetherCodexBar scans local Pi/OMP session JSONL, maps each provider and model to cached models.dev pricing, then emits token and cost snapshots for the menu bar and CLI. This PR expands that pipeline from Codex/Claude to Google, Vertex AI, and xAI sessions. flowchart LR
A[Pi and OMP session JSONL] --> B[Provider and model mapping]
B --> C[models.dev pricing cache]
C --> D[Local cost scanner]
D --> E[Token cost snapshot]
E --> F[Cost CLI and dashboard]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the additive provider mappings after a maintainer confirms the gatekeeper refresh preserves the intended architecture checks. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug report; the PR supplies an isolated after-fix CLI run using synthetic Pi sessions for all three provider paths. Is this the best way to solve the issue? Yes. It extends the existing models.dev cache and Pi cost-scanning path rather than adding a parallel pricing store, while preserving provider-scoped catalog selection. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f15f142a7787. LabelsLabel 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 (33 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:
|
2d19620 to
b99340f
Compare
87ad75c to
1eac100
Compare
1eac100 to
46c997f
Compare
|
@steipete — this PR has been rebased onto latest main and is ready for review. Thanks! |
b836225 to
034e534
Compare
…DevCostUSD out of enum to satisfy lint limits
ClawSweeper flagged that a custom codexHomePath should continue to suppress merging default Pi-session spend. Add a test verifying ambient scans merge Pi while scoped scans do not.
After rebasing the Google/xAI models.dev pricing work, ProviderArchitectureGatekeeperTests failed because new provider-specific branches (Gemini, Grok, VertexAI) 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 Google/xAI rebase.
034e534 to
8dee931
Compare
Summary
models.devlookup seam for Google/Gemini, Vertex AI, and xAI/Grok providers.google, Vertex AI togoogle-vertexwithgooglefallback, and Grok toxai.codexbar cost.Proof
models.dev.git grep -n -E "gemini-3\.5-flash|gemini-3\.1-pro-preview|gemini-3\.1-flash-lite|grok-4\.5|grok-4\.3|grok-4\.20" origin/main -- Sources Tests docshttps://models.dev/api.jsonshowed:google:gemini-3.5-flash/ Gemini 3.5 Flash / input 1.5 / output 9 / cache_read 0.15 / context 1048576google:gemini-3.1-pro-preview/ Gemini 3.1 Pro Preview / input 2 / output 12 / cache_read 0.2 / context 1048576google:gemini-3.1-flash-lite/ Gemini 3.1 Flash Lite / input 0.25 / output 1.5 / cache_read 0.025 / context 1048576xai:grok-4.5/ Grok 4.5 / input 2 / output 6 / cache_read 0.3 / context 500000xai:grok-4.3/ Grok 4.3 / input 1.25 / output 2.5 / cache_read 0.2 / context 1000000xai:grok-4.20-0309-reasoning/ Grok 4.20 (Reasoning) / input 1.25 / output 2.5 / cache_read 0.2 / context 1000000models.devfixture data with separategoogle,google-vertex, andxairates, then verifiesPiSessionCostScanner.loadDailyReportcomputes provider-scoped costs for Pi JSONL rows:google/gemini-3.5-flash: 160 tokens, cost0.0006015google-vertex/gemini-3.1-pro-preview: 160 tokens, cost0.0008171, proving Vertex uses the Vertex catalog before Google fallbackxai/grok-4.5: 160 tokens, cost0.000503.pi/agent/sessions/2026-07-28T10-00-00-000Z_google-xai-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" : "gemini", "source" : "local", "sessionTokens" : 160000, "sessionCostUSD" : 0.6015, "daily" : [{ "date" : "2026-07-28", "modelBreakdowns" : [{ "modelName" : "gemini-3.5-flash", "totalTokens" : 160000, "cost" : 0.6015 }] }] } { "provider" : "vertexai", "source" : "local", "sessionTokens" : 160000, "sessionCostUSD" : 0.802, "daily" : [{ "date" : "2026-07-28", "modelBreakdowns" : [{ "modelName" : "gemini-3.1-pro-preview", "totalTokens" : 160000, "cost" : 0.802 }] }] } { "provider" : "grok", "source" : "local", "sessionTokens" : 160000, "sessionCostUSD" : 0.503, "daily" : [{ "date" : "2026-07-28", "modelBreakdowns" : [{ "modelName" : "grok-4.5", "totalTokens" : 160000, "cost" : 0.503 }] }] }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 Google and xAI 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.