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

TypeLooks likeUsed for
API keyxai-…Inference — chat completions against Grok models
Management keyCreated separately in the consoleBilling, 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:

  1. Resolve which team you're operating against.
  2. 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:

ProviderWhat billing access needs
OpenAIOrganisation admin key (sk-admin-…)
AnthropicAdmin key (sk-ant-admin…)
xAIManagement key, team-scoped
Google GeminiGoogle 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.

Sources