Compare

Grok 4 vs Gemini 3.1 Pro

Pricing per million tokens, context window, capabilities — pulled from each provider's public docs. All 2 are available via the same AIgateway OpenAI-compatible endpoint; flip the model string to switch.

Search2/4
Grok 4
xai/grok-4
Gemini 3.1 Pro
google/gemini-3.1-pro
Provider
xAI
Google
Family
Grok 4
Gemini 3
Modality
text
text
Context window
256,000 tok
1,000,000 tok
Max output
16,384 tok
65,536 tok
Released
2025-07-09
2026-04-13
License
Proprietary
Proprietary
Input price
$5.00 /1M
$2.00 /1M
Output price
$15.00 /1M
$12.00 /1M
Cache read
$0.200 /1M
Tools
yes
yes
Streaming
yes
yes
Vision
yes
yes
JSON mode
yes
yes
Reasoning
yes
yes
Prompt caching
yes
Batch API
Try it
Open in playground →
Open in playground →
Grok 4
xai/grok-4
Full spec →

xAI Grok 4 — frontier reasoning, tool use, long context.

Strengths
  • Real-time search awareness
  • Irreverent tone
  • Competitive math + code
Use cases
News-aware chatResearch with fresh dataCreative writing
Gemini 3.1 Pro
google/gemini-3.1-pro
Full spec →

Google's most intelligent Gemini model with improved reasoning, a medium thinking level, and a 1M token context window.

Strengths
  • 2M-token context
  • Native video + audio input
  • Cheapest long-context reasoning
Use cases
Video understandingVery long-document RAGCodebase-scale reasoning

Benchmarks

Grok 4
Gemini 3.1 Pro
Long-Context
94.2
MMLU
89.6

Source: each provider's published benchmarks. Higher is better. Run an eval to compare on your own data.

Compare with another

Claude Opus 4.7 vs Gemini 3.1 Pro
anthropic/claude-opus-4.7 · google/gemini-3.1-pro
Gemini 3.1 Pro vs GPT-5.4
google/gemini-3.1-pro · openai/gpt-5.4
Claude Sonnet 4.6 vs Gemini 3.1 Pro
anthropic/claude-sonnet-4.6 · google/gemini-3.1-pro
Gemini 3.1 Pro vs Kimi-K2.6
google/gemini-3.1-pro · moonshot/kimi-k2.6
Claude Opus 4.7 vs Grok 4
anthropic/claude-opus-4.7 · xai/grok-4
Grok 4 vs GPT-5.4
xai/grok-4 · openai/gpt-5.4
GPT-5.5 Pro vs Grok 4
openai/gpt-5.5-pro · xai/grok-4
GPT-5.5 Pro vs Gemini 3.1 Pro
openai/gpt-5.5-pro · google/gemini-3.1-pro
GPT-5.5 vs Grok 4
openai/gpt-5.5 · xai/grok-4
SWITCH BETWEEN THEM

One key, all 2, one line different.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.aigateway.sh/v1",
    api_key="sk-aig-...",
)

# Grok 4
client.chat.completions.create(
    model="xai/grok-4",
    messages=[{"role":"user","content":"hello"}],
)

# Gemini 3.1 Pro
client.chat.completions.create(
    model="google/gemini-3.1-pro",
    messages=[{"role":"user","content":"hello"}],
)
Get an AIgateway keyRun an eval on these →