Read the xAI bill xAI already wrote
Most providers hand you tokens and leave the arithmetic to you. xAI is different — it reports the exact cost it billed for each line item. The catch is that the number lives behind a separate billing credential, in a console you have to remember to open. Here is how xAI billing works, and how to turn its reported cost into a running total and forecast next to everything else you run.

Most AI providers bill you in tokens and leave you to do the pricing. xAI takes the other path: it writes down what each line of your usage actually cost and hands you that figure directly. There is no rate sheet to apply and no estimate to second-guess — the money is stated, line by line.
The complication is where that ledger lives. It sits behind a billing credential that is not the key you use to call Grok, in a console you have to remember to open. What follows is how xAI prices and reports usage, why the exact number is easier to trust than a token count, and how to turn it into a running total and a forecast before month-end surprises you.
How does xAI bill for API usage?
xAI runs on prepaid credits. You buy a credit balance for your team, and every API call deducts from it as you go. When the balance reaches zero, xAI simply rejects further requests — a hard floor that keeps a runaway loop from billing you for more than you’ve funded. There’s an opt-in alternative, monthly invoiced billing, which is off by default and enabled through xAI: with it on, usage beyond your prepaid balance is charged to a payment method at the end of the month instead of being refused. Either way, xAI spends your prepaid credit first.
What draws that balance down is the usage itself, priced the way token APIs usually price it — the input you send and the output the model generates, at per-model rates that xAI publishes and revises over time. The exact figures live on xAI’s model and pricing pages, and specific model names come and go, so treat any rate or model you’ve memorized as a moving target.
Instead of leaving you to multiply token counts by rates, xAI reports the cost it billed. Its Management API exposes a usage feed in which each line item already carries the billed amount in money. The pricing has been done for you; what you read back is the settled cost, not the ingredients of an estimate. That single design choice is what makes xAI spend easier to track accurately than most.
Which credential shows billing, and why your inference key won’t
Before you can read any of that, you hit the one genuine snag in xAI cost tracking: the key you use to call Grok can’t see the bill.
xAI issues two different kinds of credential. The inference API key — the one
that starts with xai- — authorizes model calls and nothing else; it has no
billing access at all. Billing lives behind a separate Management Key, an
admin credential you create in the console under your team’s settings, reached
from the team switcher rather than the ordinary API Keys page. Only a Management
Key with billing-read permission can pull the usage-and-cost feed, and to query
it you also need your Team ID, the non-secret identifier for the team the
billing belongs to.
This split is deliberate, and it’s the right shape: a runtime key that leaks
should not expose your billing, and a cost tracker should hold the narrowest
credential that does the job. When you create the Management Key, grant it
billing read only and leave every other permission off — reading usage is all
a spend tracker ever needs to do. So if you’ve been handing tools your xai-
key and wondering why no spend shows up, that’s the wrong credential. You need a
Management Key and the Team ID.
Why the exact number is worth trusting — and why recent days still move

Because xAI reports settled cost rather than a token count, its figure needs no repricing on our side and no reconciling against a rate table. That’s a real accuracy advantage. It also comes with one honest caveat: a billing feed can still settle. A very recent line item might reverse, drop to zero, or firm up in the day or two after it first appears, as xAI closes out the period.
CostCompass handles that by treating xAI’s feed as authoritative and refetching the recent window on every refresh. If a line item settles to a different amount — or disappears — the stored figure is corrected to match, rather than frozen at whatever it read the first time. So expect the last day or two to shift slightly as they settle, while older days stay put. This is the opposite failure mode from a provider that only shows a balance: there, you never see the cost directly at all, only a number going down, and you’re left to infer spend from the drop. xAI states the cost outright, and the only thing that moves is the freshest edge of the window, in the direction of the truth.
One boundary to set expectations on: the feed groups usage by a line-item description, so what you get is an exact total broken out by those descriptions — not a per-request or per-API-key split. That granularity isn’t exposed to the billing feed, so no tracker can conjure it. What you do get is the real, reconciled total, attributed by line item.
What “Credits remaining” tells you
Separate from what you’ve spent is what you have left. Because xAI is prepaid, there’s a live credit balance behind your account, and it answers a different question than the usage feed: not “what did this cost” but “how much runway is left before calls start getting rejected.”
CostCompass reads that remaining-credit figure straight from xAI and shows it as the balance on your xAI card, so you don’t have to open the console to check it. It comes from xAI’s own invoice preview — the same live figure the console nets into Credits remaining — which reflects what you’ve consumed this billing period rather than lagging behind settled top-ups. It’s a best-effort extra: if xAI ever declines to hand it over, your spend tracking is untouched, because the running total is built from the billing feed, not the balance.
How does CostCompass track your xAI costs?
CostCompass tracks xAI by reading the one thing that matters most — the cost it reports. Each time you refresh, it queries xAI’s Management API for the usage feed over the current window, takes the billed amount on each line item, and rolls those into your month-to-date total, attributed by line-item description. Because the figures are xAI’s own settled numbers, the total is exact, not an estimate, and it reconciles itself as recent days settle. Tracking starts from the billing data xAI holds, so you’re reading the real bill from the first refresh rather than a number derived after the fact.

Two things make that practical for a solo developer. First, your Management Key is encrypted in your browser before anything is stored. The key you paste is sealed with your vault password on your own device, and only the sealed version is ever saved — a blob CostCompass can’t open, because the vault password stays with you. When it’s time to read your billing, your browser unseals the key and passes it to a relay that uses it for that single call to xAI and is built not to log or keep it. What we hold at rest is locked ciphertext that nobody can use against your account.
Second, xAI doesn’t sit alone. The same dashboard rolls its running total up with every other AI and compute provider you’ve connected — Claude, OpenAI, Google, DeepSeek, whatever you route through a gateway like OpenRouter or Atlas Cloud, and your hosting — into one figure with a forecast, instead of a console you check on its own. It becomes one line in your whole-stack spend rather than a number you go and read.
How do you forecast next month’s xAI bill?
Forecasting doesn’t need anything exotic, just a burn rate: take your spend over the last several days, average it per day, and project that across a full month.
CostCompass does exactly this. It scales your trailing seven-day burn rate to the number of days in next month and adds any fixed subscriptions you’ve entered, producing one forward number for what next month costs if the current pace holds. Seven days is a deliberate window — long enough that one heavy day doesn’t throw the average, short enough to catch a recent change like a new workload. Because xAI reports exact billed cost, that projection builds on a firm base rather than an estimate, so it sharpens quickly as clean days accumulate.
Getting started takes three steps:
- In the xAI console, under your team’s settings, create a Management Key with billing-read permission, and note your Team ID.
- Paste the Management Key into CostCompass and enter the Team ID. The key is encrypted in your browser before it’s stored, so the server only ever holds ciphertext.
- Refresh. CostCompass reads xAI’s reported billing and your remaining credit, and shows your running total and forecast — xAI included in the whole-stack number.
Frequently asked questions
- Why doesn't my xAI API key show my billing or spend?
- Because the key you use for inference — the one that starts with xai- — has no billing access. xAI keeps billing behind a separate credential called a Management Key, created in the console under team Settings, and only that credential can read the usage and cost figures. It's a deliberate split, the same least-privilege idea most platforms use for admin versus runtime access. So the key that runs your Grok calls is the wrong one to hand a cost tracker; you need a Management Key with billing-read permission, plus your Team ID, before any spend number is reachable.
- Where do I find my xAI Team ID and how do I create a Management Key?
- Both live in the xAI console under your team's settings, reached from the team switcher, not the ordinary API Keys page that mints xai- inference keys. The Team ID is the identifier shown on the team settings screen. The Management Key is created in the same settings area — grant it Billing read access and nothing else, since a cost tracker only ever needs to read the usage figures. When you connect xAI to CostCompass you paste the Management Key and enter the Team ID; the key is the secret, the Team ID is not.
- Does xAI give an exact cost, or do I have to work it out from tokens?
- xAI reports the cost it actually billed. Its Management API returns a usage feed grouped by line item, and each line carries the billed amount in money, not just a token count — so there's no rate table to apply and no estimate to reconcile. That's different from providers that hand you token counts and leave the pricing math to you. One limit worth setting expectations on — the feed groups by a line-item description, so what you get is an exact total broken out by those descriptions, not a per-request or per-API-key breakdown. CostCompass reports what xAI reports.
- How do I check how much xAI credit I have left?
- xAI runs on prepaid credits — you buy a balance and API calls draw it down — and it shows the remaining amount in the console under Billing. CostCompass reads that same remaining-credit figure straight from xAI and shows it as the balance on your xAI card, so you don't have to open the console to see it. It's read live from xAI's own invoice preview, which reflects what you've consumed this billing period rather than lagging behind settled top-ups, so it matches the console's Credits remaining.
- What's the difference between prepaid credits and monthly invoiced billing on xAI?
- Prepaid is the default — you pre-purchase a credit balance and every call deducts from it, and once it's gone xAI rejects further requests, which caps your exposure. Monthly invoiced billing is an opt-in alternative, off by default and enabled through xAI, where calls beyond your prepaid balance are charged to a payment method at month end instead of being refused. Either way xAI draws down prepaid credit first. CostCompass tracks the cost xAI reports regardless of which mode you're on; the mode only changes what happens after the prepaid balance hits zero.
- Why did a recent day's xAI spend change after I'd already seen it?
- Because xAI can still settle a recent line item — a charge can reverse, drop to zero, or firm up after it first appears. CostCompass treats xAI's billing feed as the source of truth and refetches the recent window each time you refresh, so a figure that settles is corrected rather than frozen at its first reading. In practice that means very recent days can move slightly as they settle, and older days hold steady. It's the price of an exact, reconciled number instead of a first-glance snapshot.
- Does CostCompass store my xAI Management Key?
- Not in any form we can read. Your Management Key is encrypted in your browser with your vault password before it's ever sent to us, and all CostCompass keeps is the resulting ciphertext — a blob it has no way to open, because your vault password never leaves your device. When it's time to read your xAI billing, the key is unsealed in your browser and forwarded to xAI through a relay that holds it for that one call and is built not to log it. The key does pass through our infrastructure for that request, but the plaintext is never written to our database or our logs. What sits at rest is locked ciphertext nobody can use against your account.
- Why use CostCompass instead of the xAI console?
- The xAI console shows your usage and remaining credit, after the fact, for xAI alone — and only once you go and open it with the right admin credential in hand. It won't tell you how fast the spend is climbing, where it lands by month-end, or how it sits next to the rest of your bill. CostCompass turns xAI's reported billing into a running total and a forecast, and rolls it up with Claude, OpenAI, Google, and your hosting spend into a single view — current the moment you click Refresh, instead of a number you have to hunt down provider by provider.
About the author
Joubert Berger builds CostCompass, a spend-intelligence dashboard that pulls usage from AI and compute providers into one month-to-date total, a forecast, and a per-provider breakdown. This guide reflects how CostCompass reads each provider's own usage API — see the security model for how your keys are handled.
Stop opening the xAI console to find one number
Connect xAI once and turn its reported billing into a running total and a next-month forecast — rolled up with every other provider, in one click.