Connect Grok (xAI) to StackSpend
Track Grok API costs including Grok 3, Grok 4, and other models. Uses the xAI Management API for billing and usage monitoring.
StackSpend tracks Grok (xAI) API costs via the Management API. Get daily cost visibility and anomaly alerts. xAI costs grow with usage—we help you see them before the invoice.
Management API Key Required
Cost tracking uses the xAI Management API, which is separate from the inference API. You must create a Management API key in xAI Console → Settings → Management Keys. Your standard API key used for chat completions will not work for cost data.
Prerequisites
- An xAI account with API access
- Access to xAI Console
- Management API key (not the inference API key)
- Team ID from your xAI Console URL
Create a Management API Key and Find Team ID
Create a Management API key in the xAI Console. This key is different from the API key you use for chat completions.
- 1Go to xAI Console
- 2Navigate to Settings → Management Keys
- 3Click to create a new Management API key
- 4Important: Copy the key immediately. You won't be able to see it again.
- 5Find your Team ID in the console URL. For example, if the URL is
console.x.ai/team/default, your Team ID isdefault.
Note: Management API keys have full access to your team billing data. Store them securely and never share them publicly.
Connect in StackSpend
- 1Go to Settings → Providers in your StackSpend dashboard
- 2Click Add Provider → Select Grok (xAI)
- 3Paste your Management API key
- 4Enter your Team ID (e.g.
default) - 5Click Test Connection to verify
- 6Once the test succeeds, click Connect
After Connecting
Once Grok is connected, StackSpend fetches cost data from the xAI Management API. Costs are synced on your regular schedule.
- Costs sync automatically every 6 hours
- Model-level usage tracking (Grok 3, Grok 4, etc.)
- Token and tool usage costs when available