Quick Answer: What Free Credits Does xAI Actually Give You?
xAI gives every new account $25 in promotional API credits on signup at console.x.ai. No X Premium subscription is required — the API uses a separate xAI account. A second program offers $150/month in additional credits if you opt your team into data sharing, but that requires a minimum of $5 in prior API spend before you can enroll. The $25 starter credits expire 30 days after account creation and do not carry over.
Bottom line: the first $25 is genuinely free and requires no payment method. The $150/month data-sharing program is available but gated behind a small real spend. Together, they can cover serious prototyping and testing before you commit to a billing plan.
Do You Need X Premium to Use the Grok API?
No. This is the most common misconception about Grok access. X Premium ($8/month) and X Premium+ ($16/month) bundle Grok access into the X social platform — useful for chatting via grok.com or the X app, but entirely separate from the developer API. The Grok API at console.x.ai uses an independent xAI account and charges on a pay-as-you-go basis. You do not need a checkmark, an X subscription, or any social media account to call the API and build with Grok models.
Step-by-Step: How to Get Your Grok API Key
Step 1 — Create an xAI Account
Go to console.x.ai and click Sign Up. You can register with an email address or sign in with an existing X account. If you sign in with X, your social account and your API account remain separate billing entities — your X subscription does not affect API credits or vice versa.
Step 2 — Complete Developer Onboarding
On first login, xAI walks you through a brief setup: your intended use case, your team name, and acceptance of the API terms of service. This takes under two minutes. Your $25 promotional credits are applied automatically once onboarding is complete.
Step 3 — Navigate to API Keys
In the left sidebar of the console, click API Keys (sometimes labelled Manage API Keys depending on your account view). This is where all keys for your team are created and revoked.
Step 4 — Create Your Key
Click Create API Key. Give it a descriptive name — for example, "dev-test-key" or "production-app". Select the model permissions you need (you can leave this open for full access during testing). Click Create. Your key is displayed exactly once, prefixed with xai-. Copy it immediately and store it in a password manager or your environment variables. It cannot be retrieved again after you close the modal.
Step 5 — Make Your First Call
The Grok API base URL is https://api.x.ai/v1. It is fully compatible with the OpenAI SDK — you only need to change the base URL and swap in your xAI key. Here is a minimal working example in Python:
from openai import OpenAI
client = OpenAI(
api_key="xai-your-key-here",
base_url="https://api.x.ai/v1"
)
response = client.chat.completions.create(
model="grok-4.1-fast",
messages=[{"role": "user", "content": "Hello, Grok!"}]
)
print(response.choices[0].message.content)
No additional packages are required beyond the standard openai Python library. The same pattern works in Node.js using the openai npm package.
How Much Can You Build with $25 in Free Credits?
The $25 goes further than most developers expect because Grok 4.1 Fast is priced at $0.20 per million input tokens and $0.50 per million output tokens — among the cheapest rates of any frontier-class model available today. At those rates, $25 buys approximately 50 million input tokens on Grok 4.1 Fast. For a typical agentic coding session consuming around 10,000 tokens, that covers roughly 5,000 sessions. For a conversational chatbot sending short 200-token exchanges, it covers hundreds of thousands of queries.
Grok 4 (the full flagship) is priced at $3.00 per million input tokens and $15.00 per million output tokens, so $25 goes significantly less far if you are testing the highest-capability tier. For most prototyping, defaulting to Grok 4.1 Fast makes sense — it scores near-identically to Grok 4 on most coding and reasoning benchmarks while costing 15× less per token.
The one cost to watch: server-side tools are billed separately. Web search, X search, and code execution each cost $5 per 1,000 invocations. If your app calls web search frequently, those charges add up faster than token costs. Function calling with your own custom tools has no per-invocation fee — only token costs apply.
The Data-Sharing Program: How to Unlock $150/Month More
After spending your first $5 on the API, your team becomes eligible to enroll in xAI's data-sharing program. Opting in allows xAI to use your API request data for model training in exchange for $150/month in recurring credits. Credits appear within 24 hours of enrollment and refresh monthly. They do not carry over — unused credits reset each cycle.
Important details: only the team admin can enable data sharing, the setting is team-level (not per-user), and once a team opts in it cannot opt back out. The credit applies to eligible countries — check the xAI console for your region's status. This program is best suited for development teams running non-sensitive workloads who are comfortable with xAI using request data for training. For applications handling private or proprietary information, skip this program and use standard pay-as-you-go billing.
Grok Model Lineup: Which One to Use
xAI currently offers four main model tiers through the API. Grok 4.20 is the newest flagship model, featuring a 2 million token context window, agentic tool calling, the lowest hallucination rate xAI claims to date, and full reasoning capabilities. Grok 4.1 Fast sits below it at $0.20/$0.50 per million tokens with the same 2 million token context window — the recommended default for most development use cases given its cost-to-capability ratio. Grok 4.1 Fast is also available in a non-reasoning variant for latency-sensitive applications where you want the fastest possible response time. Grok 4 at $3/$15 per million tokens is the higher-accuracy option for complex multi-step tasks where accuracy matters more than cost.
All models share full compatibility with the OpenAI SDK, support function calling and structured JSON outputs, and include prompt caching by default — repeated identical prompt prefixes benefit from 50–75% token cost reductions without any configuration on your end.
Best Free Alternatives if You Need Unlimited Access
If $25 is not enough and you need genuinely unlimited free API access, three options are worth considering in 2026. Google AI Studio offers free access to Gemini 2.5 Pro and Gemini 2.5 Flash with no credit card required — it is the single most generous free AI API currently available by total token volume, though rate limits are strict. GitHub Models gives free playground and API access to GPT-4o, Grok 3, DeepSeek R1, and others for developers already in the GitHub ecosystem, capped at 10–15 requests per minute and 50–150 per day depending on model tier. NVIDIA NIM provides 1,000 free credits on signup with an option to request 4,000 more, focused on open-source models like Llama and Mistral rather than Grok.
For Grok specifically, there is no permanently free unlimited API option outside the credit programs above. Avoid sites promising "free unlimited Grok API keys" — these are either scams collecting your credentials or proxies that violate xAI's terms of service and risk account bans.
FAQ
Do I need X Premium to use the Grok API?
No. The Grok API at console.x.ai is a completely separate product from X Premium. You only need a free xAI account. X Premium and X Premium+ bundle Grok chat access within the X social platform — useful for using Grok.com or the X app, but unrelated to API keys and billing.
Do the $25 free credits expire?
Yes. Promotional credits expire 30 days after account creation. They do not carry over to the next month. Add a payment method before they expire if you want uninterrupted API access.
What is the cheapest Grok model to call?
Grok 4.1 Fast (non-reasoning variant) is the cheapest option at $0.20 per million input tokens and $0.50 per million output tokens. It supports a 2 million token context window. For most testing and prototyping, it is the right default choice.
What does the data-sharing program require?
Your team must have spent a minimum of $5 on API usage before enrolling. Only team admins can enable it. Once opted in, the team cannot opt out. It provides $150/month in recurring credits in exchange for xAI using your API request data for model training.
Is the Grok API compatible with the OpenAI SDK?
Yes. The Grok API uses the same request and response format as OpenAI's Chat Completions API. You only need to change two things: the base URL to https://api.x.ai/v1 and the api_key to your xAI key. No code restructuring is required beyond those two parameters.
What are the server-side tool costs I should know about?
Web search, X search, code execution, and file attachment search are charged per invocation on top of token costs. Web search and X search cost $5 per 1,000 calls. Code execution costs $5 per 1,000 calls. Collections search (RAG) costs $2.50 per 1,000 calls. Custom function calling with your own tools has no per-invocation fee — only the tokens used in the model's decision to call the function are billed.