Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

XAI Budget

The XAI budget system tracks and limits usage of external AI APIs (xAI Grok, Cerebras) to prevent runaway costs while enabling strategic use for evaluation and critique.

Budget Tracking

budget = scheduler.get_xai_budget()
# budget.daily_remaining — tokens left for today
# budget.daily_limit — configured daily cap
# budget.reset_time — when the budget resets (midnight UTC)

Usage Controls

  • Daily token limit: Configured per provider
  • Request rejection: When budget exhausted, requests fail with clear error
  • Priority gating: Only HIGH and CRITICAL priority jobs can use external APIs
  • Evaluation budget: Separate allocation for agent evaluation tasks

CLI Commands

# Check current budget
uv run gaius-cli --cmd "/xai budget" --format json

# Reset budget (admin)
uv run gaius-cli --cmd "/xai reset" --format json

# Evaluate with external model
uv run gaius-cli --cmd "/xai evaluate" --format json

When External APIs Are Used

Use CaseProviderPurpose
Agent evaluationxAI GrokIndependent critique of agent output
Cross-validationCerebrasSecond opinion on critical decisions
Held-out evaluationxAI GrokMeasuring agent improvement