Grok API (December 2026): key, pricing and free xAI credits
Grok 4.7 costs $2 per million input tokens and $6 output on the xAI API. How to get a key, every model price, rate limits, and how to get free Grok API credits.
The Grok API is xAI's pay-as-you-go API at api.x.ai. Grok 4.7, the current flagship, costs $2.00 per million input tokens and $6.00 per million output tokens. There is no free API tier: you create a key at console.x.ai and load prepaid credits before your first request. The main way to get free Grok API credits is the Grok for Startups program.
xAI now operates as SpaceX Super Intelligence (SpaceXSI), and its docs have moved to docs.grok.com, but the API, console and XAI_API_KEY naming are unchanged. Prices below are from xAI's pricing docs on December 4, 2026.
How to get an xAI API key
- Sign up at console.x.ai. You can sign up with an X account to link it. If you already use Grok, the same account works, but billing for the API is separate from any Grok subscription.
- Buy credits. In the console go to Billing, then API spend management. If you pay by bank transfer, credits arrive after 2 to 3 business days. You can also enter a promo code here if you have one.
- Create a key on the API Keys page. The full key is shown once, so copy it straight into your secret store.
- Set it as an environment variable:
export XAI_API_KEY="your_api_key". - Send a test request. The API is OpenAI-compatible:
from openai import OpenAI
import os
client = OpenAI(
api_key=os.getenv("XAI_API_KEY"),
base_url="https://api.x.ai/v1",
)
response = client.responses.create(
model="grok-4.7",
input="Explain quantum computing",
)
print(response.output_text)
Or with curl:
curl https://api.x.ai/v1/responses \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "grok-4.7", "input": "Explain quantum computing"}'
xAI also ships its own Python SDK (pip install xai-sdk) and a Vercel AI SDK provider (npm install ai @ai-sdk/xai).
Lock your key down
Keys belong to a team and can be scoped. Through xAI's management API you can limit a key to specific models and endpoints, cap its queries per second, queries per minute and tokens per minute, and set an expiry time. Set a monthly maximum on auto top-ups so a leaked key cannot drain your card, and never ship the key in browser or mobile code.
Grok API pricing per model
| Model | Context | Input | Cached input | Output |
|---|---|---|---|---|
grok-4.7 | 500K | $2.00 | $0.50 | $6.00 |
grok-4.6 | 500K | $2.00 | $0.50 | $6.00 |
grok-4.5 | 500K | $2.00 | $0.30 | $6.00 |
grok-4.3 | 1M | $1.25 | $0.20 | $2.50 |
grok-4.20-0309-reasoning | 1M | $1.25 | $0.20 | $2.50 |
grok-4.20-0309-non-reasoning | 1M | $1.25 | $0.20 | $2.50 |
grok-4.20-multi-agent-0309 | 1M | $1.25 | $0.20 | $2.50 |
Prices are per million tokens for prompts under 200K tokens. Once a prompt reaches 200K tokens, every price doubles, and the higher rate applies to all tokens in that request, not just the part over 200K. For grok-4.7 that means $4.00 input, $1.00 cached and $12.00 output.
xAI recommends Grok 4.7 for code and chat and calls it the most capable model it has built. Its knowledge cut-off is May 2026, so turn on the Web Search or X Search tools if you need current information.
Batch, priority and regional pricing
- Batch API: 20% off every text model above, on input, output, cached and reasoning tokens. Most batch jobs finish within 24 hours, and batch requests do not count toward rate limits.
- Priority processing: 2x standard rates for lower latency, billed only when the response confirms
"service_tier": "priority". - US regional endpoint (
https://us.api.x.ai/v1): 1.1x standard rates, currentlygrok-4.7andgrok-4.6only. Forgrok-4.7that is $2.20 input, $0.55 cached and $6.60 output under 200K tokens. - Grok 4.7 Fast is only available in Cursor and Grok Build, not on the public API.
Image, video and voice prices
| Model or mode | Price |
|---|---|
grok-imagine-image | $0.02 per image |
grok-imagine-image-2.0 | $0.04 per image |
grok-imagine-video | $0.05 per second |
grok-imagine-video-1.5 | $0.08 per second |
grok-imagine-video-1.5-lite | $0.02 per second |
Speech to speech (grok-voice-3.0) | $0.08 per minute ($4.80 per hour), plus $0.004 per text input |
| Speech to text | $0.10 per hour (REST), $0.20 per hour (streaming) |
| Text to speech | $15.00 per million characters |
Tool prices
Server-side tools add a per-call fee on top of tokens:
| Tool | Price per 1,000 |
|---|---|
| Web Search | $5 calls |
| X Search | $5 per 1,000 posts, $10 per 1,000 profiles returned |
| Code Execution | $5 calls |
| File attachment search | $5 calls |
| Collections search (RAG) | $2.50 calls |
File storage costs $0.025 per GiB per day and collection storage $0.10 per GiB per day. If xAI's system flags a Responses API request as violating its usage guidelines before generation, it charges a $0.05 fee for that request.
Grok API cost calculator
Enter your expected traffic to see what Grok costs per month. Tick the comparison box to see Claude, GPT and Gemini models at the same volume.
| Model | Per 1,000 requests | Per month |
|---|---|---|
| Grok 4.3 | $3.75 | $375 |
| Grok 4.7 | $7.00 | $700 |
Standard API list prices checked 2026-12-04. Excludes tax, tool calls and Anthropic’s cache-write surcharge. Startup credits can bring this to $0.
Worked example: what Grok 4.7 costs a month
Say you run 10,000 requests a month, each with 3,000 input tokens and 500 output tokens: 30M input tokens and 5M output tokens.
- Standard: 30 × $2.00 + 5 × $6.00 = $60 + $30 = $90.00
- With caching: if 2,000 tokens of each prompt are a repeated system prompt served from cache, input becomes 10 × $2.00 + 20 × $0.50 = $30, so the total is $30 + $30 = $60.00
- Batch (20% off standard): $90 × 0.8 = $72.00
- On
grok-4.3instead: 30 × $1.25 + 5 × $2.50 = $37.50 + $12.50 = $50.00
Grok API rate limits
Every team has per-model limits in requests per second and tokens per minute. Your tier rises automatically with cumulative API spend since January 1, 2026, and tiers never go down:
| Tier | Spend needed | grok-4.7 limits |
|---|---|---|
| Tier 0 | $0 | 150 requests per second, 50M tokens per minute |
| Tier 1 | $50 | 172 requests per second, 53M tokens per minute |
| Tier 2 | $250 | 208 requests per second, 60M tokens per minute |
| Tier 3 | $1,000 | 312 requests per second, 74M tokens per minute |
| Tier 4 | $5,000 | 500 requests per second, 100M tokens per minute |
Cached tokens count toward tokens per minute even though they bill at the lower rate. You can see your team's exact limits on the Models page in the console and request more there.
Is the Grok API free?
No. xAI's quickstart says to load your account with credits before using the API, and its docs, pricing page and billing guide list no free tier. Older guides mention $25 a month in beta credits or $150 a month for sharing data with xAI. Neither appears in xAI's current docs, so do not plan around them.
A Grok subscription does not help either. xAI's pricing FAQ says paid plans include Grok API access, but API usage is billed separately at standard model rates and does not draw from the plan's usage pool. The Free plan does not include API access at all.
What you can do:
- Use a promo code if you have one. The Billing page has a field for it.
- Apply to Grok for Startups (below).
- Turn off auto top-up or set a monthly maximum, and keep the invoiced billing limit at $0. xAI then rejects requests once your prepaid credits run out, instead of billing you more.
If you just want free inference from any provider, see our free LLM API guide.
Grok for Startups: free xAI API credits
Grok for Startups is xAI's credit program, and it is the closest thing to free Grok API access. Credits come in one balance you can spend on the Grok API, Grok, Grok Build and Grok Bot.
- Who qualifies: xAI evaluates each application on your live product, traction, revenue, current AI spend, team size and funding. Venture backing is not required. If your investor is a partner (xAI names Sequoia, Thrive, a16z and Kleiner Perkins, among others), you can get additional credits.
- How much: xAI does not publish an amount. You get initial credits on approval and can unlock more after onboarding with xAI's team.
- Expiry: 6 months after the credits are applied, unless your approval email says otherwise.
- Limits: one grant per company group. Credits cannot pay for taxes, third-party products or X Premium. If you got credits from an earlier xAI program, you can still apply but must disclose them.
What you need to apply (the form takes about five minutes): your name, job title, work email and LinkedIn; company name, website, city, country, industry and team size; your team ID; the Grok products you plan to use; current monthly AI spend, annual revenue, the month of your last raise and your investors if you have raised. Optional: your X handle, traction, amount raised, and a partner code from your investor.
Two things trip people up:
- The work email must match your company website domain. xAI says applications from a personal email cannot be approved.
- The team ID is the 4 to 10 digit number at grok.com/dashboard/workspace-settings, not the longer team ID in console.x.ai. The email you apply with must belong to that team.
Apply at x.ai/startups. Questions about missing credits go to [email protected].
Other credits for AI APIs
If you use more than one model provider, these AI programs also accept startups without an investor referral:
DaytonaDaytona for Startups"$10K straight away on their account and easily up to $100K" in Daytona creditsApply directly$100KDeepgramDeepgram for StartupsUp to $100,000 in Deepgram credits over 12 months; direct applicants start at $1,000Apply directly$100K
PyAIPyAI for StartupsUp to $100,000 in voice AI product credits for 12 monthsApply directly$100K
SpeechmaticsSpeechmatics Startup ProgramUp to $50,000 in Speechmatics usage creditsApply directly$50K
Together AITogether AI Startup AcceleratorUp to $15K / $30K / $50K in free platform credits plus 3–10 hours of forward-deployed engineering, by amount raisedApply directly$50K
FirecrawlFirecrawl for Startups2x your annual plan's monthly credits for 12 months, extra credits capped at $2,500 a month or $30,000 a year, plus a Slack Connect channelApply directly$30K
Resemble AIBuilder's Grant Startup Program$500 to $30,000 in credits for up to 12 monthsApply directly$30KRunwareRunware Startup ProgramUp to $30,000 in bonus credits on top of a deposit, or up to $1,000 in free credits with no depositApply directly$30K
Our AI startup credits guide compares them all, including the larger programs that need a VC.
Questions
Is the Grok API free?
No. xAI's quickstart tells you to load credits before your first request, and its docs list no free API tier. The ways to use it without paying are promotional credits, such as a promo code or the Grok for Startups program.
Does a Grok subscription include API credits?
No. xAI's pricing FAQ says paid plans include Grok API access, but API usage is billed separately at standard model rates and does not draw from the plan's usage pool. The Free plan does not include API access.
Is the Grok API compatible with the OpenAI SDK?
Yes. Set the base URL to https://api.x.ai/v1 and use your xAI key with the OpenAI SDK. xAI also has its own Python SDK (xai-sdk) and a Vercel AI SDK provider (@ai-sdk/xai).
Does xAI train on my API data?
xAI says it never trains on API inputs or outputs without your explicit permission. Requests and responses are stored encrypted for 30 days for abuse auditing, then deleted, and teams can turn on Zero Data Retention.
How long do Grok for Startups credits last?
Unless your approval email says otherwise, credits expire 6 months after they are applied to your team account. Unused credits are forfeited and have no cash value.
Programs in this guide
xAI (SpaceX Super Intelligence)Grok for StartupsCredits across Grok, Grok Build, Grok Bot and the Grok API from one balance; initial credits on approval with more unlocked after onboarding (amount not published)Apply directlyUnpublished
Together AITogether AI Startup AcceleratorUp to $15K / $30K / $50K in free platform credits plus 3–10 hours of forward-deployed engineering, by amount raisedApply directly$50K
OpenRouterOpenRouter for StartupsUp to $3,000 in universal inference credits plus 0% processing fees (platform and BYOK) for 12 monthsNeeds an investor$3K
Sources
- docs.x.ai/docs/models
- docs.x.ai/docs/tutorial
- docs.grok.com/developers/pricing
- docs.grok.com/developers/rate-limits
- docs.grok.com/console/billing
- docs.grok.com/developers/faq/accounts
- docs.grok.com/developers/faq/security
- docs.grok.com/developers/rest-api-reference/management/auth
- x.ai/api
- grok.com/pricing
- x.ai/startups
- grok.com/startups
- spacexsi.com/legal/startup-program-terms
Related guides
- Free LLM APIs in December 2026: every real free tier and its limits
The free LLM APIs that still work in December 2026: Gemini, OpenRouter free models, Groq and Cloudflare Workers AI, with published limits and the catch on each.
- AI credits for startups: every free AI credit program (2026)
Free AI credits for startups from OpenAI, Anthropic, xAI, Google, GPU clouds, voice APIs and vector DBs. Which need a VC and which you can apply for directly.
- How to get a Gemini API key: free tier, limits and billing
Get a free Gemini API key in Google AI Studio in a few minutes. Which models are free, rate limits, data use, paid tier setup ($5 minimum) and key security.
- Cursor for students (2026): the free Pro year has ended
Cursor's free year of Pro for students closed to new sign-ups on June 25, 2026. What students can still get: event credits, research credits and free plans.