โ† All guides
xAI (Grok)

Getting your xAI Management API key

xAI uses a separate Management API for billing and account data. This is different from the regular API you use to call Grok models. TokenMeter needs a Management-scoped key to read your balance and usage.

How xAI is different

๐Ÿ’ก

Two separate APIs. xAI has a regular API at api.x.ai for model calls, and a Management API at management-api.x.ai for account/billing data. TokenMeter uses the management one.

xAI organizes accounts into Teams. Even if you're a solo user, you'll have a "default" team. The Management key is scoped to your team.

Step by step

1

Log into the xAI Console

Go to console.x.ai and sign in.

2

Select your team

If you have multiple teams, select the one you want to track. Most users just have "default".

3

Go to Settings โ†’ Management keys

Click Settings in the bottom of the left sidebar, then click the "Management keys" card.

xAI Console โ€” Settings page showing Management keys card

Click "Management keys" on the Settings page.

4

Create a management key

Click "Create management key". Give it a name like "TokenMeter". You need to enable Billing access โ€” change it from "No access" to "Read" or "Full access".

xAI Console โ€” Management keys list with Create button

The Management keys page. Click "Create management key".

xAI Console โ€” Create management key form with Billing permissions

Set "Billing" to Read or Full access. This is what TokenMeter needs to read your spend data.

5

Copy the key

Copy immediately โ€” shown once only.

6

Paste into TokenMeter

Open TokenMeter โ†’ Settings โ†’ Accounts โ†’ paste in the xAI field โ†’ Save Keys.

Key format

xai-XXXXXXXXXXXXXXXXXXXXXXXX

xAI keys start with xai-. Management keys look the same as regular API keys โ€” the difference is they're created under Settings โ†’ Management keys, not the regular API Keys page.

โš ๏ธ

A regular xAI API key won't work. Keys created from the "API Keys" page in the sidebar can only make Grok API calls. To read billing data, you need a Management key from Settings โ†’ Management keys, with Billing access enabled.

What the key can access

Troubleshooting

"Shows unauthorized or 403"

Your key doesn't have Management scope. Create a new key and make sure to tick the Management permission during creation.

"Balance shows but no daily spend"

xAI's management API shows your account balance but doesn't break down spend by day the way Anthropic and OpenAI do. TokenMeter tracks your balance at the start of each day and calculates spend as the difference. If you just added the key, today's starting balance was just recorded โ€” spend tracking starts from tomorrow (or from the next app launch today).

"I'm on Grok Premium+ โ€” do I need this?"

If you only use Grok through x.com and don't make API calls, toggle on the Grok Premium+ subscription in TokenMeter settings instead. The Management key is only needed for API billing data.

Open xAI Console โ†’