How to Use Grok 3 & Grok 3 Mini API for Free (2026)
Get started with xAI's Grok 3 API using the free tier
Start Building with Hypereal
Access Kling, Flux, Sora, Veo & more through a single API. Free credits to start, scale to millions.
No credit card required • 100k+ developers • Enterprise ready
How to Use Grok 3 & Grok 3 Mini API for Free in 2026
xAI's Grok 3 and Grok 3 Mini are among the most capable language models available, excelling at reasoning, coding, math, and general conversation. The best part: xAI offers a generous free API tier that lets developers build and test applications without spending anything.
This guide covers how to get free API access, the rate limits and capabilities of each model, code examples in Python and JavaScript, and how Grok 3 compares to GPT-4o, Claude, and Gemini.
Grok 3 Model Overview
xAI offers several Grok 3 variants through their API:
| Model | Context Window | Strengths | Best For |
|---|---|---|---|
| Grok 3 | 131,072 tokens | Top-tier reasoning, coding, analysis | Complex tasks requiring deep thinking |
| Grok 3 Mini | 131,072 tokens | Fast, efficient, strong reasoning | High-volume tasks, quick responses |
| Grok 3 Mini (Fast) | 131,072 tokens | Lowest latency | Real-time applications |
All models support function calling, structured output (JSON mode), system prompts, and streaming.
Step 1: Get Your Free API Key
- Go to console.x.ai.
- Sign up with your X (Twitter) account or email.
- Navigate to API Keys and click Create API Key.
- Copy your key (starts with
xai-). - New accounts receive $25 in free API credits per month.
Free Tier Limits
| Limit | Grok 3 | Grok 3 Mini |
|---|---|---|
| Free credits | $25/month | $25/month |
| Rate limit (RPM) | 30 requests/min | 60 requests/min |
| Rate limit (TPM) | 100K tokens/min | 200K tokens/min |
| Max output tokens | 16,384 | 16,384 |
| Context window | 131,072 | 131,072 |
The $25 monthly credit is generous. At Grok 3 Mini's pricing of $0.30/M input tokens and $0.50/M output tokens, that translates to millions of tokens per month for free.
Step 2: Make Your First API Call
Grok 3's API follows the OpenAI-compatible format, making it easy to integrate with existing code.
Python Example
import openai
client = openai.OpenAI(
api_key="xai-your-api-key-here",
base_url="https://api.x.ai/v1"
)
# Basic chat completion
response = client.chat.completions.create(
model="grok-3-mini",
messages=[
{
"role": "system",
"content": "You are a helpful coding assistant. Be concise and provide working code."
},
{
"role": "user",
"content": "Write a Python function that implements binary search on a sorted list."
}
],
temperature=0.7,
max_tokens=2048
)
print(response.choices[0].message.content)
JavaScript/Node.js Example
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "xai-your-api-key-here",
baseURL: "https://api.x.ai/v1",
});
const response = await client.chat.completions.create({
model: "grok-3-mini",
messages: [
{
role: "system",
content: "You are a helpful coding assistant.",
},
{
role: "user",
content: "Write a TypeScript function to debounce API calls.",
},
],
temperature: 0.7,
max_tokens: 2048,
});
console.log(response.choices[0].message.content);
cURL Example
curl https://api.x.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer xai-your-api-key-here" \
-d '{
"model": "grok-3-mini",
"messages": [
{"role": "user", "content": "Explain async/await in JavaScript in 3 sentences."}
],
"temperature": 0.7
}'
Step 3: Use Streaming for Real-Time Responses
For chat applications and interactive tools, streaming provides a better user experience:
import openai
client = openai.OpenAI(
api_key="xai-your-api-key-here",
base_url="https://api.x.ai/v1"
)
stream = client.chat.completions.create(
model="grok-3-mini",
messages=[
{"role": "user", "content": "Explain how DNS resolution works step by step."}
],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
Step 4: Use Function Calling
Grok 3 supports function calling for building AI agents and tool-using applications:
import openai
import json
client = openai.OpenAI(
api_key="xai-your-api-key-here",
base_url="https://api.x.ai/v1"
)
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City name, e.g., San Francisco"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "Temperature unit"
}
},
"required": ["location"]
}
}
}
]
response = client.chat.completions.create(
model="grok-3",
messages=[
{"role": "user", "content": "What's the weather like in Tokyo?"}
],
tools=tools,
tool_choice="auto"
)
# Handle the tool call
message = response.choices[0].message
if message.tool_calls:
tool_call = message.tool_calls[0]
function_args = json.loads(tool_call.function.arguments)
print(f"Function: {tool_call.function.name}")
print(f"Arguments: {function_args}")
Step 5: Use JSON Mode for Structured Output
Force Grok 3 to return valid JSON for reliable parsing:
response = client.chat.completions.create(
model="grok-3-mini",
messages=[
{
"role": "system",
"content": "You are a data extraction assistant. Always respond with valid JSON."
},
{
"role": "user",
"content": "Extract the key information from this text: 'Apple Inc. reported Q4 2025 revenue of $95.4 billion, up 8% year-over-year. Net income was $24.1 billion.'"
}
],
response_format={"type": "json_object"},
temperature=0
)
import json
data = json.loads(response.choices[0].message.content)
print(json.dumps(data, indent=2))
Grok 3 Pricing Breakdown
When your free credits run out, here is what the paid pricing looks like:
| Model | Input (per 1M tokens) | Output (per 1M tokens) |
|---|---|---|
| Grok 3 | $3.00 | $15.00 |
| Grok 3 Mini | $0.30 | $0.50 |
| Grok 3 Mini (Fast) | $0.10 | $0.25 |
Grok 3 Mini offers exceptional value -- at $0.30/M input tokens, it is one of the cheapest high-quality models available.
Grok 3 vs. Competitors
| Feature | Grok 3 | GPT-4o | Claude Sonnet | Gemini 2.5 Pro |
|---|---|---|---|---|
| Free API credits | $25/mo | $5 initial | $5 initial | $0 (AI Studio free) |
| Input price (per 1M) | $3.00 | $2.50 | $3.00 | $1.25 |
| Output price (per 1M) | $15.00 | $10.00 | $15.00 | $10.00 |
| Context window | 131K | 128K | 200K | 1M |
| Coding | Excellent | Excellent | Excellent | Excellent |
| Reasoning | Excellent | Excellent | Excellent | Excellent |
| Speed | Fast | Fast | Fast | Medium |
| OpenAI-compatible API | Yes | Yes (native) | No (different format) | No (different format) |
When to Choose Grok 3
- Best free tier: $25/month in free credits beats most competitors
- OpenAI compatibility: Drop-in replacement in existing OpenAI SDK code
- Grok 3 Mini value: Among the cheapest high-quality models for production use
- Reasoning tasks: Grok 3 excels at math, logic, and complex analysis
When to Choose Alternatives
- Longest context: Gemini 2.5 Pro offers 1M tokens
- Anthropic ecosystem: Claude integrates with MCP, Claude Code, and Artifacts
- Widest ecosystem: GPT-4o has the most third-party integrations
Tips for Maximizing Free Credits
Use Grok 3 Mini for most tasks. It is 10x cheaper than Grok 3 and performs well for the majority of use cases. Reserve Grok 3 for tasks that specifically need deeper reasoning.
Set max_tokens appropriately. Do not default to the maximum. If you expect a 200-token response, set
max_tokens: 500to avoid wasted output tokens.Cache repeated prompts. If you send the same system prompt frequently, xAI may offer prompt caching discounts (check the latest docs).
Use temperature 0 for deterministic tasks. For code generation and data extraction, lower temperatures reduce unnecessary token usage from verbose responses.
Monitor usage in the dashboard. Track your credit consumption at console.x.ai to avoid unexpected charges.
Frequently Asked Questions
Is the Grok 3 API really free? Yes, you get $25 in free credits every month. This resets monthly and covers millions of tokens with Grok 3 Mini.
Do I need a paid X (Twitter) account? No. You can sign up for the xAI API with just an email address.
Can I use Grok 3 with the OpenAI Python library?
Yes. Just change the base_url to https://api.x.ai/v1 and use your xAI API key. All other code stays the same.
What happens when free credits run out? API calls will return an error. You can add a payment method for pay-as-you-go usage or wait for the monthly reset.
Does Grok 3 have content restrictions? Grok 3 has fewer content restrictions than some competitors, but it still has safety guidelines. It is generally more permissive for creative and research use cases.
Wrapping Up
Grok 3 and Grok 3 Mini offer one of the best free API tiers in the AI space. The $25 monthly credit, combined with Grok 3 Mini's low pricing, gives developers millions of free tokens to build with. The OpenAI-compatible API format makes it trivial to integrate into existing projects.
If you are building applications that need AI-generated media like images, video, or talking avatars, try Hypereal AI free -- 35 credits, no credit card required. Pair Grok 3 for the intelligence layer with Hypereal for visual content generation.
Related Articles
Start Building Today
Get 35 free credits on signup. No credit card required. Generate your first image in under 5 minutes.
