xAI management keys vs inference keys
Last verified
The one thing to know: the xai-… key you use to call Grok cannot read your billing data. Management operations need a separate _management key_, created in the xAI console.
This trips up almost everyone connecting Grok to a cost tracker for the first time, because the failure looks like an authorisation problem rather than a wrong-key-type problem.
The two credential types
| Type | Looks like | Used for |
|---|---|---|
| API key | xai-… | Inference — chat completions against Grok models |
| Management key | Created separately in the console | Billing, usage, key and team management |
You will usually hold both. They are not interchangeable in either direction.
Creating a management key
In the xAI console, under your account or team settings, find the management keys section and create one. As always: name it after where it will live, copy it once, put it in a secret manager.
Team scope
xAI's billing is team-scoped, not account-scoped. In practice that means reading usage is usually a two-step job:
- Resolve which team you're operating against.
- Query usage or billing for that team.
If you're used to OpenAI — where organisation is mostly implicit in the key — this extra hop is the second thing that catches people. An empty result frequently means "right key, wrong team" rather than "no usage".
Where this fits in a multi-provider setup
Each provider takes a different shape, which is most of the work in tracking spend across all of them:
| Provider | What billing access needs |
|---|---|
| OpenAI | Organisation admin key (sk-admin-…) |
| Anthropic | Admin key (sk-ant-admin…) |
| xAI | Management key, team-scoped |
| Google Gemini | Google Cloud Billing — no simple API key path |
Tracking costs across OpenAI, Anthropic, Grok and Gemini covers the whole picture, and Gemini billing access covers the one that is genuinely different.
Verify before you build on it
xAI's billing surface has moved more than the others', and response shapes have changed between revisions. Before you build a dashboard on it:
- Confirm the current endpoints against xAI's own documentation
- Make one call by hand with your management key and read the actual response
- Do not assume the shape matches OpenAI's, because it does not
This is the provider we would most encourage you to verify directly rather than trusting any third-party write-up, including this one. Check the response you actually get.