Skip to main content
xAI bills Grok usage per team, broken down by model and modality, so a chat model and an image model are attributed separately rather than as one bill total. CostGraph reads xAI as FOCUS 1.2 records at a grain of one record per day per Grok model and modality.

Choose how the data reaches us

CostGraph pulls it

You supply read-only credentials and we call xAI once a day. Nothing to run.

You push it

You send us FOCUS records over the API. Credentials never leave your infrastructure.

Before you begin

  • In the xAI Console, go to Settings > Management Keys and create a management key. The billing usage endpoint rejects an inference API key.
  • Note the team id. It scopes the billing call and becomes the billing account.

Let CostGraph pull

  1. Open Settings > Integrations and pick xAI.
  2. Name the connection and pick the tenant these charges belong to.
  3. Enter the values you copied. The form lists what xAI needs and marks the optional ones.
  4. Select Connect.
CostGraph verifies the credentials with a short fetch before saving, so a wrong value or a missing permission fails while you are still on the form.
Use an xAI Management key, not the inference API key used to call Grok; only a Management key can read billing. Credentials are encrypted at rest and used only to read billing data. Revoke them in xAI at any time and the connection stops; nothing else is affected.

Push it yourself

Send the charges to CostGraph as FOCUS records instead. Push FOCUS data covers the connection id, the focus:write key, and the request shape.

Run the exporter

Rather than build that request yourself, run our exporter. It reads xAI on a schedule and pushes the records for you, wherever you want to run it: a container, a Kubernetes CronJob, or a binary on a machine you already have.
Your xAI credential stays where you put it, and only the finished FOCUS records reach CostGraph. Run the exporter covers the three ways to run it and the variables it reads.

What CostGraph does with it

Records land as raw billing rows, are normalised into line items, and roll up into daily cost. From there xAI spend appears in Cost Overview and in anomaly detection alongside every other provider, with spend attributed per Grok model so cost concentration and spikes are visible.