xAI API spending limit
How do I limit spend on the xAI API?
You limit spend on the xAI API by keeping your monthly invoiced billing limit at its default $0 and paying strictly through prepaid credits. When your prepaid balance hits zero, xAI automatically rejects new API calls instead of running up an open-ended charge against your payment card. If you prefer continuous operation and turn on auto top-up, you can protect yourself by specifying a monthly cap on total top-ups alongside a minimum reload of $5.
Purchasing prepaid credits via bank transfer instead of credit card takes 2 to 3 business days to process before the credits are granted to your account. Keep in mind that changes made to billing settings in a team affect all users in that team, so any adjustment you make applies across your entire workspace.
Prepaid credits vs monthly invoiced billing
The xAI API provides two distinct billing methods: prepaid credits and monthly invoiced billing.
Prepaid credits are the standard route for most developers. You pre-purchase credits for your team in advance, and your API consumption is deducted directly from that prepaid balance as your applications make requests. Because you can only burn what you already bought, you can't run into runaway balance surprises. You can check your remaining balance, apply promo codes, and buy credits through Billing -> API spend management inside the xAI Console. You can track your day-to-day burn rate on the Usage explorer page. Due to regulatory requirements, prepaid credits can currently only be purchased via Guest Checkout.
Monthly invoiced billing works the other way around. You receive an invoice for your API consumption at the end of the month, and if you don't have sufficient prepaid credits on hand, your default payment method is charged.
Monthly invoiced billing is disabled by default. If you want it, you can't just flip a toggle; you have to contact sales@x.ai or submit a request through the contact link on the Billing page. You can add a card at Billing -> Billing details -> Add Payment Information. Don't expect to strip your card details later, though, because xAI doesn't allow users to remove the last payment method on file. You can inspect all finalized prepaid and monthly statements at Billing -> Invoices, but xAI cannot regenerate invoices once they're created.
How to configure auto top-up without open-ended risk
If you rely on prepaid credits, a sudden drop to zero cuts off your traffic. Auto top-up handles this by purchasing more credits whenever your team balance drops below a threshold you define.
Can you run auto top-up without giving xAI a blank check? Yes, because the console lets you constrain the reload behavior across three distinct inputs:
- Credit balance trigger: The balance number your team must fall to before xAI initiates a purchase.
- Top-up amount: The dollar amount of credits bought during each reload, which requires a minimum of $5.
- Maximum monthly top-up value: The upper ceiling on the combined value of all auto top-ups permitted within a single calendar month.
Auto top-up can be disabled at any time. When you establish a monthly ceiling, a warning displays on the API spend management card once you have used 80% of the total monthly limit you set. That visual flag gives you advance notice before your reload allowance shuts down for the remainder of the billing period.
Invoiced billing limits and request rejections
If you do request invoiced billing, your exposure comes down to your invoiced billing limit. By default, that limit is $0.
When your invoiced billing limit is set to the $0 default, SpaceXSI only uses your available prepaid credits. Your API requests will be automatically rejected once your prepaid credits are depleted. That hard stop is your safest configuration if you never want an unbudgeted invoice.
To use monthly billing, you can increase your invoiced billing limit on the Billing -> API Credits page. Once that limit is higher than zero, SpaceXSI attempts to use prepaid credits first, and the remaining amount will be charged to your default payment method at the end of the month.
What happens when your usage exceeds that higher threshold? Once your monthly invoiced billing amount reaches the invoiced billing limit, you won't be able to get a response until you have raised the invoiced billing limit. The API simply stops answering your queries until you go into the console and raise the ceiling. For context on pricing before setting higher limits, see our breakdown on What does the xAI Grok API cost?.
Rate limit tiers and token consumption
Your spend history also sets your throughput limits on the API. Every xAI team gets per-model rate limits on two metrics: requests per second (RPS) and tokens per minute (TPM). Your per-second request limit is derived directly from your per-minute request budget as RPM / 48, with a minimum of 2.
Tiers are calculated based on your cumulative spend since January 1, 2026. You unlock tiers automatically through revenue xAI receives from prepaid credit purchases or fulfilled monthly invoices. Once you qualify for a tier, you stay there permanently; tiers never downgrade.
| Tier | Cumulative spend threshold |
|---|---|
| Tier 0 | $0 (default) |
| Tier 1 | $50 |
| Tier 2 | $250 |
| Tier 3 | $1,000 |
| Tier 4 | $5,000 |
| Enterprise | Available on request |
Exceeding any per-model RPS or TPM cap returns an HTTP 429 Too Many Requests error. Keep in mind that TPM limits count all tokens processed by a model:
- Prompt tokens (text, audio, image)
- Completion tokens
- Reasoning tokens on reasoning models
- Cached prompt tokens
Even though cached prompt tokens are billed at a reduced rate, they still count toward your TPM limit. So, an aggressive workload that leverages prompt caching heavily can still run into a 429 error if it pushes total token volume past your tier cap.
Monitoring spend and setting brakes with Costbrake
Native console limits protect against post-paid surprises, but they won't tell you if an errant script burns through your $200 prepaid balance in two hours.
Costbrake watches what you spend across 23 providers, including xAI, OpenAI, Anthropic, AWS, Azure, Google Cloud, and Cloudflare. It sends budget alerts at 50%, 80%, and 100% of your targets, issues forecast alerts when your 72-hour burn rate projects an end-of-month overrun, and triggers spike alerts whenever an hour costs more than 3x your 7-day baseline and at least $5 more than usual. Free workspaces check hourly, while the Pro and Team plans poll every 5 minutes (and every 2 minutes during an active spike). If you manage multiple providers, you can read more in our guide on How do I monitor spend across OpenAI, Anthropic, Gemini and other AI APIs in one place?.
{
"managementKey": "YOUR_XAI_MANAGEMENT_KEY",
"teamId": "optional-team-id"
}To connect xAI, create a management key in the console at https://console.x.ai/team/default/management-keys with only the AnalyzeBillingItems permission. Management keys cannot call models, and one restricted to AnalyzeBillingItems cannot alter API keys, limits, or billing details. Costbrake reads your spend per hour, model, and key directly through the Management API.
On Pro ($12 a month) and Team plans, Costbrake also includes opt-in brakes. A brake only runs when an admin clicks it and confirms; Costbrake never brakes on its own. For xAI, brakes allow you to disable an API key or freeze invoiced billing at $0.01. Freezing invoiced billing only stops charges that would go on an invoice - your prepaid credits will keep being consumed until they run out, and auto top-up can buy more. If you run on prepaid credits alone, use the brake to disable the specific API key instead. You can configure this via agent setup or review plan options on Costbrake pricing.
Questions and answers
Can I set a hard monthly spending limit on the xAI API?
Yes, you can enforce a hard spend cap by keeping your monthly invoiced billing limit at the default $0 and relying entirely on prepaid credits. Requests are automatically rejected once your prepaid balance drops to zero.
What happens when my xAI API credits run out?
When your prepaid credits run out and your invoiced billing limit is $0, your API requests are automatically rejected. If you have an active invoiced billing limit above $0, xAI charges the excess to your default payment method at the end of the month until that limit is reached.
Does xAI support auto top-up for prepaid credits?
Yes, auto top-up automatically buys more credits when your balance falls below your chosen threshold. You can set the trigger threshold, a top-up amount of at least $5, and a monthly maximum limit on total top-ups.
Can I remove my credit card from the xAI console?
No, xAI does not currently allow users to remove the last payment method on file. You can add new payment methods under Billing details, but the final remaining method cannot be deleted.
How quickly do bank transfer payments reflect as API credits?
Purchasing prepaid credits via bank transfer takes 2 to 3 business days to process before the credits are granted to your account.
Sources
Updated