Is the Grok API Free? Credits, Pricing and Setup

On this page
  1. How the Data-Sharing Free Credits Worked
  2. Grok API Models and Pricing in 2026
  3. What Would $150/Month Buy, If Your Console Still Offers It?
  4. Get Your Grok API Key
  5. Your First Grok API Call (OpenAI-Compatible)
  6. Live Web and X Search: Grok's Real Differentiator
  7. OpenAI SDK Quick Reference
  8. Grok vs Other Free AI APIs
  9. The Privacy Trade-Off: When NOT to Use the Credits
  10. Frequently Asked Questions
  11. Final Thoughts
Quick answer: The Grok API has no permanent no-strings free tier — by default it's pay-as-you-go per token. xAI's data-sharing program has granted up to $150/month in free credits to teams that let xAI train on their prompts and completions — but as of 2026-09-01 it is no longer documented on docs.x.ai, so check your console before counting on it. If it is there, that's effectively unlimited for a prototype, but never enable it for sensitive data.

xAI's platform is OpenAI-compatible, so if your code already calls OpenAI you swap two lines and you're on Grok. The differentiators: a 1M-token context (the 2M "fast" models were retired in May 2026) and built-in search tools over the open web and X. This covers how the free-credit program worked, current pricing, your first call, and when to reach for a genuinely card-free API instead.

Everything below is sourced from xAI's docs at docs.x.ai and the console at console.x.ai. Pricing and credit programs change often — confirm current numbers in your own console before building a budget around them.

How the Data-Sharing Free Credits Worked

This section describes the program as it ran through 2025; see the caveat below before relying on any of it. The credit was tied to one toggle in team settings, usually labeled "Share API Inputs and Outputs for Model Training."

  • You opted in. xAI could use your prompts and completions to improve future Grok models.
  • You got credited. Up to $150 in free credits per month against your usage, refreshing monthly while active.
  • It was region-gated. Limited to eligible countries; if your billing region wasn't supported, the toggle didn't grant credits.
  • Promo credits. New accounts have at times received a small one-time signup credit (commonly reported ~$25). Promotional, comes and goes.

Checked against docs.x.ai on 2026-09-01 and again on 2026-10-11, and this is the important caveat: the data-sharing credit program is no longer documented anywhere on docs.x.ai. The pricing page has no free-credit section, and the Data & Privacy page describes only Zero Data Retention and a 30-day audit window — no training toggle, no credit grant. It may still exist in the console without being documented, so confirm the live figure at console.x.ai before planning around it. Treat the $150 below as historical until you have seen it on your own billing page.

Other caveats, because this program changes frequently:

  • xAI has at points required a small one-time deposit (reported as low as $5) before the $150 unlocks — a fraud/identity gate, not a recurring charge.
  • The ceiling, eligibility, and activation flow have all shifted across 2025–2026. Treat "$150/month" as historical until you have verified the live number in your console.
  • Credits do not roll over — unused allowance at month-end is gone.

The key point: this is a data-for-credits trade, not a charity free tier. The "free" costs privacy rather than dollars.

Grok API Models and Pricing in 2026

The lineup is built around the Grok 4.x family, with Grok 4.7 now the flagship docs.x.ai recommends for code and chat, and Grok 4.3 the cheaper 1M-context default. Per-token prices are USD per 1M tokens, from docs.x.ai:

ModelContextInput / 1MOutput / 1MBest for
grok-4.31M tokens$1.25$2.50Flagship reasoning, coding, agents
grok-4.7500K tokens$2.00$6.00Current flagship, code and chat
grok-4.6 / grok-4.5500K tokens$2.00$6.00Previous flagships, same price
grok-4.20 (reasoning)1M tokens$1.25$2.50Hard reasoning / math
grok-4.20 (multi-agent)1M tokens$1.25$2.50Parallel multi-agent tasks
grok-build-0.1256K tokens$1.00$2.00Agentic app/code building

Re-checked 2026-10-11 against docs.x.ai. The prices above are for prompts under 200K tokens; every text model doubles its per-token price once a prompt reaches 200K. Exact IDs for the 4.20 family are grok-4.20-0309-reasoning, grok-4.20-0309-non-reasoning and grok-4.20-multi-agent-0309. The "fast" models with a 2M window that this page used to mention (grok-4-fast, grok-4-1-fast) were retired on 15 May 2026 and now route to grok-4.3, so 1M is the largest context on the public API. Reasoning tokens bill as output, so reasoning models cost more per turn than the token counts in your prompt suggest. We hold no xAI key: the only calls we made were unauthenticated, and GET https://api.x.ai/v1/models and POST /v1/chat/completions both returned 401 {"code":"unauthenticated:no-credentials"} — the API is up, but nothing on this page is a measured Grok response.

xAI also exposes multimodal endpoints on the same platform: image generation (~$0.02–$0.05 per image), video generation (~$0.02–$0.08 per second, depending on the model), and voice modes. These count against the same balance — and against the data-sharing credit, if your console still shows one.

Two things make Grok distinctive: huge context windows (1M on grok-4.3 and the 4.20 family — Gemini-class, far beyond Groq's or Cerebras's ceilings), and live search tools that pull real-time data from the web and X (web_search at $5 per 1,000 calls, x_search at $5 per 1,000 posts). No other major free-credit API ships first-party real-time X data. Model IDs move — hit GET /v1/models before hardcoding one in production.

What Would $150/Month Buy, If Your Console Still Offers It?

The arithmetic below only matters if you can see the credit on your own billing page. Take a typical turn of 1,000 input + 500 output tokens. On grok-4.3 that's $0.0025 per turn, so $150 covers ~60,000 turns/month (~2,000/day). On grok-build-0.1 it's $0.0020 per turn — about 75,000 turns/month (~2,500/day).

ModelCost per 1K-in / 0.5K-out turnTurns per $150/month≈ Turns/day
grok-4.3$0.0025~60,000~2,000
grok-4.20 reasoning$0.0025~60,000~2,000
grok-build-0.1$0.0020~75,000~2,500
grok-4.6$0.005~30,000~1,000

For almost any side project, internal tool, or MVP, the credit — if your team still gets it — is effectively "unlimited." You'd need a real product with thousands of daily users to exhaust it — and at that scale you shouldn't be on a program that trains on your traffic anyway.

Get Your Grok API Key

  1. Sign in at console.x.ai (X account or email).
  2. Create or select a team — billing and credits are scoped to the team.
  3. If your team settings still show "Share API Inputs and Outputs for Model Training," check under billing whether enabling it grants any credit before you count on it; xAI's docs no longer describe one.
  4. Add a payment method if prompted (some regions require it, sometimes with a small one-time deposit).
  5. Under API Keys, click Create API Key, copy it — shown once. Store it in a secret manager or .env, never commit it.

Your First Grok API Call (OpenAI-Compatible)

The single most useful fact: the Grok API is OpenAI-compatible. Base URL https://api.x.ai/v1, request/response shapes match OpenAI Chat Completions. Change the base URL and model name and you're calling Grok.

cURL

curl https://api.x.ai/v1/chat/completions 
  -H "Authorization: Bearer $XAI_API_KEY" 
  -H "Content-Type: application/json" 
  -d '{
    "model": "grok-4.3",
    "messages": [
      {"role": "system", "content": "You are a concise technical assistant."},
      {"role": "user", "content": "Explain the CAP theorem in three sentences."}
    ]
  }'

Python (OpenAI SDK)

from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["XAI_API_KEY"],
    base_url="https://api.x.ai/v1",
)

response = client.chat.completions.create(
    model="grok-4.3",
    messages=[
        {"role": "system", "content": "You are a concise technical assistant."},
        {"role": "user", "content": "Write a Python function that returns the nth Fibonacci number iteratively."},
    ],
)

print(response.choices[0].message.content)

xAI also ships an official xai-sdk Python package, but the OpenAI SDK keeps your code provider-agnostic.

Node.js / TypeScript

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.XAI_API_KEY,
  baseURL: "https://api.x.ai/v1",
});

const response = await client.chat.completions.create({
  model: "grok-4.3",
  messages: [
    { role: "user", content: "Write a TypeScript type for a paginated API response." },
  ],
});

console.log(response.choices[0].message.content);

Streaming

stream = client.chat.completions.create(
    model="grok-4.3",
    messages=[{"role": "user", "content": "Explain async/await in JavaScript with one example."}],
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)

Structured JSON output

response = client.chat.completions.create(
    model="grok-4.3",
    messages=[
        {
            "role": "user",
            "content": (
                "Extract as JSON with keys title, company, remote (boolean), salary (string or null): "
                "'Backend Engineer at NorthByte, fully remote, $130k-$160k.'"
            ),
        }
    ],
    response_format={"type": "json_object"},
)
# {"title": "Backend Engineer", "company": "NorthByte", "remote": true, "salary": "$130k-$160k"}

Live Web and X Search: Grok's Real Differentiator

Most LLM APIs are frozen at their training cutoff. Grok can query the live web and X through server-side tools. As of 2026-10-11 the docs describe two: web_search ($5 per 1,000 calls) and x_search ($5 per 1,000 posts, $10 per 1,000 profiles), billed on top of tokens — so they draw down your balance (and any credit) faster than plain completions. The older search_parameters "Live Search" field below is no longer in xAI's guides or pricing page and survives only in the Chat Completions API reference, which xAI now labels a legacy endpoint in favour of its Responses API.

response = client.chat.completions.create(
    model="grok-4.3",
    messages=[{"role": "user", "content": "What are the latest changes to the xAI API pricing this week?"}],
    extra_body={
        "search_parameters": {
            "mode": "auto"
        }
    },
)

We have no xAI key and have not run this snippet; for new code, use the web_search / x_search tools from the current docs instead. First-party real-time access to X plus the open web is something neither Gemini's free tier, Groq, nor DeepSeek offers natively.

OpenAI SDK Quick Reference

Because Grok is OpenAI-compatible, it drops into LangChain, LlamaIndex, LiteLLM, OpenWebUI, and anything accepting a custom base URL.

FieldValue
Base URLhttps://api.x.ai/v1
Auth headerAuthorization: Bearer YOUR_XAI_API_KEY
Chat endpointPOST /v1/chat/completions
Models endpointGET /v1/models
Default modelgrok-4.3

With LiteLLM, switching a whole codebase to Grok is one model string:

from litellm import completion
import os

os.environ["XAI_API_KEY"] = "YOUR_XAI_API_KEY"

response = completion(
    model="xai/grok-4.3",
    messages=[{"role": "user", "content": "What are the SOLID principles?"}],
)

It also connects to OpenClaw, an open-source agent platform: run openclaw onboard, choose Custom OpenAI-compatible, enter https://api.x.ai/v1, paste your key, and select grok-4.3. If your console still offers the data-sharing credit, you get a frontier coding/reasoning agent at zero marginal cost — the 1M-token context holds a large codebase, and Live Search fetches current docs mid-task.

Grok vs Other Free AI APIs

FeatureGrok (xAI)Google GeminiGroqDeepSeek
Free path$150/mo via data sharing (undocumented as of 2026-09-01)True free tier, no cardTrue free tier, no cardLow-cost paid (promos)
Credit card to startSometimes (region/deposit)NoNoYes
Privacy cost of "free"Trains on your dataFree tier may be used for reviewNone on free tierStandard paid terms
Flagship context1M1M128K128K
Real-time web/X searchYes (web_search / x_search tools)Grounding (Search)NoNo
OpenAI-compatibleYesYes (compat endpoint)YesYes
Multimodal (image/video/voice)YesYesLimitedNo

The honest read: if you want "free" with no asterisks, Gemini and Groq are simpler — no payment method, no data-for-credits trade. Grok's pitch is different: a frontier model with a 1M-token window and real-time X/web access that may be free if your console still offers the data-sharing credit. You pick Grok for its capabilities and treat the credit as a bonus.

The Privacy Trade-Off: When NOT to Use the Credits

The $150/month was contingent on letting xAI train on your prompts and completions. That has real consequences:

  • Never enable data sharing for proprietary or confidential data — customer records, internal source code, unreleased product details, legal/medical text.
  • Be careful with user data. Forwarding end-user messages to Grok with sharing on may violate your privacy policy or regulations like GDPR.
  • Separate environments. Keep one team with sharing on for non-sensitive experimentation (covered by the credit, if you still get one), and a separate paid team with sharing off for anything touching real data.

Turn data sharing off and any such credit goes away — back to standard pay-as-you-go, which is the correct setup for production with sensitive data.

Frequently Asked Questions

Is the Grok API free forever?

No. There's no permanent zero-cost tier. The closest thing was the data-sharing program's up-to-$150/month credit, which refreshed monthly while you stayed opted in; as of 2026-09-01 it is no longer documented on docs.x.ai. Terms have changed repeatedly — confirm the current ceiling in console.x.ai.

Do I need a credit card to use the Grok API?

It depends on your region. Some regions start on the credit with little friction; others require a payment method and occasionally a small one-time deposit. Unlike Gemini or Groq, Grok is not guaranteed card-free.

Does enabling free credits mean xAI trains on my data?

Yes — that's the entire deal. The $150/month was granted in exchange for letting xAI use your inputs and outputs to improve its models. Turn data sharing off (and forgo the credit) for anything sensitive.

Is the Grok API OpenAI-compatible?

Yes. Point any OpenAI SDK at https://api.x.ai/v1, use your xAI key as the bearer token, and set the model to a Grok ID. No other code changes needed.

Final Thoughts

"Is the Grok API free?" has no one-word answer. By default it's paid. The data-sharing program made it effectively free up to $150/month, but it is no longer documented (checked 2026-09-01); if your console still offers it, that's enough for tens of thousands of daily completions on a frontier model with a 1M-token context and real-time X/web search no other major API offers natively. The catch you should never ignore: that free tier trains on your inputs. Use it freely for non-sensitive prototyping, keep it off for anything confidential. Get your key at console.x.ai, point your OpenAI SDK at https://api.x.ai/v1, and pair it with OpenClaw for an agent that is free while the credit applies.