Get an xAI API key
Who this is for: anyone who wants xAI's Grok and image models through SpiderGate, billed to their own xAI API account.
What this does: walks you through creating an xai- API key on console.x.ai, adding prepaid credit, and adding the key to your SpiderGate vault.
Before you begin
An xAI account at console.x.ai, loaded with credit. xAI's quickstart says: "Sign up for an account at console.x.ai, then load it with credits to start using the API."
About 5 minutes.
Limits and terms to know first
The xAI API is billed by prepaid credit, deducted as you use it. xAI says it cannot refund prepaid credit "unless in regions required by law".
Note: A Grok subscription (SuperGrok, X Premium+ or The X Subscription) is not API credit. xAI says the account is shared between Grok and the API but "the billing is separate". To use your Grok subscription instead, see Connect Grok.
Warning: xAI says: "Do not share keys between teammates to avoid unauthorized access." Keep this key to your own brand.
Steps
Step 1 — Add credit
In the xAI console, open Billing → API spend management and purchase credits.
Step 2 — Create the key
Open console.x.ai/team/default/api-keys and create a key. Keys start with xai-. Copy it.
Step 3 — Add the key in SpiderGate
Open Gate → Vault (/dashboard/gate/vault) and click Add Provider. Type xAI in Search providers... and pick it from the Pay-as-you-go group.
Fill in the dialog:
API Key — paste the
xai-keyLabel — a name you will recognise later, for example the account it came from.
Under Routing, the Share with SpiderIQ key pool toggle does not apply to a metered key: SpiderGate never pools a key that bills per call, whatever the toggle shows. Switch it off anyway so the dialog matches what happens.
Click Add key. The button reads Saving... while SpiderGate checks the key.
Verify it worked
When you click Add key, SpiderGate sends one request to xAI with the key before it stores anything: it lists your models at https://api.x.ai/v1/models.
If xAI accepts the key, the dialog closes and the key appears in your vault list.
If it does not, the dialog stays open and shows:
The x_ai key did not pass its check: <reason>. Nothing was saved.The reason is SpiderGate's own wording, never xAI's error text. The usual ones are Invalid API key (401 Unauthorized), Access denied (403 Forbidden) and The account behind this key has no credit left (402).
To see the key serve a request, give it a slot in one of your own routing aliases and send a request to that alias. The trace shows which provider answered.
SpiderGate's check proves the key is valid. It does not prove the account has credit: a key on an empty balance can pass the check and then fail on its first real request.
Troubleshoot
xAI disabled the key and emailed you. xAI scans GitHub for leaked keys and disables any it finds. Create a new key and replace it in your vault.
You want to stop a key. In the xAI console's API Keys table, open the three-dot menu next to the key and choose Disable key (reversible) or Delete key (permanent).
Too many keys checked for this workspace; try again in …s. SpiderGate runs at most 20 key checks per brand in any 10 minutes. Wait the number of seconds it gives, then click Add key again.
Request timed out (15s) or Could not reach … to check the key. Try again later. The provider did not answer in time. Nothing was saved. Try again in a minute.
The provider is rate-limiting us (429). Try again in a minute. The provider throttled the check itself. Wait a minute and retry.