How to get a Grok (xAI) API key

Updated · 3 min read

A Grok API key lets apps use xAI's Grok models on your own xAI account, billed per token from credits you buy. It comes from the xAI console at console.x.ai. (xAI's developer docs now appear under the SpaceXSI name; the console and API addresses are unchanged.) Searching for a free Groq key instead? That's a different company with a free plan: see the Groq API key guide.

Step by step

  1. Create an account at console.x.ai. Keys and credits belong to a team; make sure you are in the team you want to pay from.
  2. Buy credits. Open Billing → API spend management and buy prepaid credits by card (bank transfers take 2-3 business days). The same page shows your balance and has a field for promo codes.
  3. Create a key on the API Keys page and copy it.
  4. Add it to your app. Pick xAI or Grok in the app's provider list. If there is none, add a custom OpenAI-compatible provider with base URL https://api.x.ai/v1.

Is there a free Grok API?

Not today. On 2026-10-29 xAI's docs described two ways to pay, prepaid credits and monthly invoiced billing (on request through sales), and no free tier, free models or free monthly credits. Sites that promise "free Grok API keys" are sharing someone else's key or running a scam; a leaked key can be revoked at any moment, and it hands your prompts to a stranger's account.

If you want to try BYOK apps without paying, use a key that really is free, such as the Gemini free tier, Groq's free plan or OpenRouter's free models. See free AI API keys for the full list.

What it costs

Prices per million tokens on xAI's pricing page, 2026-10-29:

Model Context Input Cached input Output
grok-4.7 (flagship) 500K $2.00 $0.50 $6.00
grok-4.3 1M $1.25 $0.20 $2.50
grok-4.20 (reasoning and non-reasoning) 1M $1.25 $0.20 $2.50
grok-build-0.1 (coding) 256K $1.00 $0.20 $2.00

Once a prompt reaches 200K tokens, the whole request is billed at double these rates. Requests to xAI's US regional endpoint cost 10% more.

For a chat turn of about 2,000 tokens in and 500 out, grok-4.3 costs around $0.004 (more than 1,000 turns for $5) and grok-4.7 about $0.007. Repeated context that hits the cache is billed at the cheaper cached rate.

Keep the bill under control

  • Prepaid credits are a natural cap. With the default $0 invoiced billing limit, xAI rejects requests once your credits run out instead of charging your card.
  • Auto top-up buys more credits when your balance drops below a threshold (minimum $5 per top-up). If you turn it on, also set the maximum total of top-ups per month.
  • One key per app, so you can revoke a single key without breaking the others.
  • Keep keys out of shared documents and public code, and delete keys you no longer use.
  • Watch the Usage explorer in the console to see which app spends what.

Apps that work with your Grok (xAI) API key

  • Infinity

    Free · macOS

    Visit

    Free Mac AI chat app with git-style branching: fork any part of an answer into its own thread, ask up to four models at once, and use your own keys or local models.

    Works with:OpenAIAnthropicGoogle GeminixAI+7 more

  • Caotang

    Free · Web · Open source

    Visit

    Free, local-first browser writing studio for novels and scripts, with an AI agent that runs on your own Anthropic, OpenAI, Google, OpenRouter or local model key.

    Works with:AnthropicOpenAIGoogle GeminixAI+5 more

  • Exody

    Free · macOS, iOS

    Visit

    Free autonomous coding agent for Mac that routes each step to Claude, GPT, Gemini, Grok or a local model using your own API keys, with no seat fee or markup.

    Works with:AnthropicOpenAIGoogle GeminixAI

  • Conduit

    Free · Windows, macOS, Linux · Open source

    Visit

    Open-source desktop AI app for agents, research, writing and slides that runs on your own keys from 23 providers or local models.

    Works with:AnthropicOpenAIGoogle GeminixAI+12 more

  • SoloMD

    Free · macOS, Windows, Linux · Open source

    Visit

    Free, open-source Markdown editor for desktop and mobile with built-in AI tools that run on your own key from 14 providers.

    Works with:OpenAIAnthropicGoogle GeminixAI+7 more

  • Witsy

    Free, open source · macOS, Windows, Linux · Open source

    Visit

    Open-source desktop AI assistant and universal MCP client for macOS, Windows, and Linux. BYOK app supporting 15+ AI providers including local models via Ollama.

    Works with:OpenAIAnthropicGoogle GeminixAI+8 more

  • Refact

    Free, open source (Refact Cloud discontinued) · VS Code, JetBrains · Open source

    Visit

    Open-source AI coding agent for VS Code and JetBrains that runs a local engine with your own provider keys or local models.

    Works with:OpenAIAnthropicGoogle GeminiDeepSeek+5 more

  • Phở Chat

    Free with BYOK, Pro $10/month, Founder lifetime $59 (limited seats) · Web

    Visit

    AI research workspace for clinicians and researchers that cites real PubMed and DOI sources and labels unsourced claims, with BYOK support for zero markup.

    Works with:OpenAIAnthropicGoogle GeminiDeepSeek+1 more

See all 26 apps that work with xAI

Direct key or a gateway?

A direct xAI key gives you xAI's own prices, billing controls and xAI-only tools such as X Search. If you use Grok next to GPT, Claude and Gemini, an OpenRouter key covers all of them from one balance.

Questions

Is the Grok API free?

No. On 2026-10-29 xAI's docs described only paid use: prepaid credits (the usual way) or monthly invoicing. There is no free tier or free monthly allowance in the docs. If you have a promo code, you can redeem it on the console's Billing page.

Does a SuperGrok or X Premium subscription include API access?

xAI's API docs don't list app subscriptions as a way to pay for the API. API usage is paid from your console team's credits or invoice.

Is Grok the same as Groq?

No. Grok (with a k) is xAI's model family. Groq (with a q) is a different company that runs open models fast and has a free plan; see our Groq API key guide.

What base URL do apps need for Grok?

https://api.x.ai/v1. The API works with OpenAI's SDKs, so apps that accept a custom OpenAI-compatible endpoint can use Grok with that URL and your xAI key.

Which Grok model should I pick?

grok-4.7 is xAI's flagship for code and chat ($2 input / $6 output per million tokens). grok-4.3 costs less ($1.25 / $2.50) and has a 1M-token context window.

Sources

Checked against the providers' own documentation on 2026-10-29. Prices and limits change; the links below have the current figures.

Related guides