Stack SpendDocs

Grok (xAI)

Connect your xAI account to track Grok API costs and model-level token usage in StackSpend.

Grok (xAI) logo

Grok (xAI)

xAI Management API — real-time billing data

The Grok provider connects StackSpend to your xAI account via the xAI Management API. Once connected, StackSpend loads your full billing history on the first sync and then tracks new usage in real time.

What StackSpend tracks

  • API costs broken down by model (Grok-2, Grok-1.5, and others)
  • Input and output token usage per model
  • Full historical data loaded on first connection

Prerequisites

  • An xAI account with Grok API access

Setup

1

Get your Management API key

Go to console.x.ai and navigate to API Keys → Create key. Give it a name such as “StackSpend”. Copy the key after creation.

2

Add to StackSpend

In StackSpend, go to Providers → Grok (xAI). Paste your API key into the key field and click Save.

3

Verify

Data appears within minutes of saving. Your full billing history is loaded on the first sync.

Data summary

AttributeValue
Data latencyReal-time
Historical dataFull history
Setup time2 min

Frequently asked questions

What credential does StackSpend need to connect Grok?

StackSpend needs an xAI Management API key, created at console.x.ai under API Keys → Create key. This lets StackSpend read team-level usage and billing from the xAI Management API.

Is the connection read-only?

Yes. StackSpend only reads usage and billing data through the xAI Management API and never writes to your xAI account. It breaks spend down by model (such as Grok-2 and Grok-1.5) and by input and output token usage.

How long does setup take and how much history loads?

Setup takes about 2 minutes. Your full billing history is loaded on the first sync, then StackSpend tracks new usage in real time.

Why don't I see any cost data yet?

Data appears within minutes of saving as the first sync loads your billing history. If nothing shows, confirm the Management API key was copied correctly and has not been revoked in the xAI console.

StackSpend Docs