Skip to content

feat: add xAI/Grok cost tracking to unified budget system#10

Merged
0xNyk merged 1 commit into
mainfrom
feat/xai-cost-tracking
Mar 7, 2026
Merged

feat: add xAI/Grok cost tracking to unified budget system#10
0xNyk merged 1 commit into
mainfrom
feat/xai-cost-tracking

Conversation

@0xNyk

@0xNyk 0xNyk commented Mar 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Wire trackCostDirect() into all xAI API call sites so Grok usage is visible in budget enforcement, daily summaries, and xint costs CLI
  • Add 6 xAI operation rates to COST_RATES (grok_chat, grok_analyze, grok_vision, grok_sentiment, xai_article, xai_x_search)
  • Track actual cost from MODEL_PRICING + token usage in grok.ts, article.ts, x_search.ts
  • Add tests for trackCostDirect and xAI cost rates (21/21 pass)

Test plan

  • bun test lib/costs.test.ts — 21/21 pass
  • All xAI calls now feed into unified cost tracking
  • xint costs today shows both X API and Grok usage

Wire trackCostDirect() into all xAI API call sites (grokChat,
analyzeImage, fetchArticle, xSearch) so Grok usage is visible
in budget enforcement, daily summaries, and `xint costs` CLI.

- Add 6 xAI operation rates to COST_RATES
- Add trackCostDirect() for token-based costs with known USD amounts
- Track actual cost from MODEL_PRICING + token usage in grok.ts
- Track xAI Responses API costs in article.ts and x_search.ts
- Add tests for trackCostDirect and xAI cost rates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@0xNyk 0xNyk merged commit 6904dd7 into main Mar 7, 2026
@0xNyk 0xNyk deleted the feat/xai-cost-tracking branch March 16, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant