DEV Community

Cover image for Is the Grok API Free? $150/Month in Credits
toolfreebie
toolfreebie

Posted on Originally published at toolfreebie.com

Is the Grok API Free? $150/Month in Credits

Is the Grok API Free? $150/Month in Credits

Quick answer: The Grok API has no permanent no-strings free tier — by default it’s pay-as-you-go per token. But xAI’s data-sharing program grants up to $150/month in free credits if you opt into letting xAI train on your prompts and completions. 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: 1M-token context (2M on the fast model) and Live Search over the open web and X. This covers the free-credit mechanics, 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 Work

The credit is tied to one toggle in team settings, usually labeled “Share API Inputs and Outputs for Model Training.”

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

Honest 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 the headline, then verify 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.3 as the recommended general-purpose and coding model. Per-token prices are USD per 1M tokens, from docs.x.ai:

Model Context Input / 1M Output / 1M Best for
grok-4.3 1M tokens $1.25 $2.50 Flagship reasoning, coding, agents
grok-4.1-fast 2M tokens $0.20 $0.50 High-volume, cheap, low-latency
grok-4.20 (reasoning) 1M tokens $1.25 $2.50 Hard reasoning / math
grok-4.20 (multi-agent) 2M tokens $1.25 $2.50 Parallel multi-agent tasks
grok-build-0.1 256K tokens $1.00 $2.00 Agentic app/code building

xAI also exposes multimodal endpoints on the same platform: image generation (~$0.02–$0.05 per image), video generation (~$0.05–$0.08 per second), and voice modes. These count against the same balance — and the same $150 credit on the data-sharing program.

Two things make Grok distinctive: huge context windows (1M on the flagship, 2M on fast — Gemini-class, far beyond Groq’s or Cerebras’s ceilings), and Live Search, which pulls real-time data from the web and X via a search parameter (billed separately, per-source). 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 Can $150/Month Actually Buy?

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-4.1-fast it’s $0.00045 per turn — over 330,000 turns/month (~11,000/day).

Model Cost per 1K-in / 0.5K-out turn Turns 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.1-fast $0.00045 ~330,000 ~11,000

For almost any side project, internal tool, or MVP, the credit 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. For free credits, open team settings and enable “Share API Inputs and Outputs for Model Training.” Confirm the $150 credit shows under billing.
  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."}
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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);
Enter fullscreen mode Exit fullscreen mode

Streaming

stream = client.chat.completions.create(
    model="grok-4.1-fast",
    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)
Enter fullscreen mode Exit fullscreen mode

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"}
Enter fullscreen mode Exit fullscreen mode

Live Search: Grok’s Real Differentiator

Most LLM APIs are frozen at their training cutoff. Grok can query the live web and X by adding a search parameter to the request. Live Search is billed per source returned, separate from token costs — so it draws down your balance (and $150 credit) faster than plain completions.

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"
        }
    },
)
Enter fullscreen mode Exit fullscreen mode

Field names for non-standard features evolve — treat this as a pattern and confirm the current schema in the docs. 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.

Field Value
Base URL https://api.x.ai/v1
Auth header Authorization: Bearer YOUR_XAI_API_KEY
Chat endpoint POST /v1/chat/completions
Models endpoint GET /v1/models
Default model grok-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?"}],
)
Enter fullscreen mode Exit fullscreen mode

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. Paired with 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

Feature Grok (xAI) Google Gemini Groq DeepSeek
Free path $150/mo via data sharing True free tier, no card True free tier, no card Low-cost paid (promos)
Credit card to start Sometimes (region/deposit) No No Yes
Privacy cost of “free” Trains on your data Free tier may be used for review None on free tier Standard paid terms
Flagship context 1M (2M on fast) 1M 128K 128K
Real-time web/X search Yes (Live Search) Grounding (Search) No No
OpenAI-compatible Yes Yes (compat endpoint) Yes Yes
Multimodal (image/video/voice) Yes Yes Limited No

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 happens to be free if you accept the data-sharing terms. 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 is 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), and a separate paid team with sharing off for anything touching real data.

Turn data sharing off and the $150 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 is the data-sharing program’s up-to-$150/month credit, which refreshes monthly while you remain opted in. 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 is 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, but the data-sharing program makes it effectively free up to $150/month — 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 a fully free agent.

Related Reads


Originally published at toolfreebie.com.

Top comments (0)