Enter opens the highlighted result. Esc closes.

Gemma 4 31B vs Llama 3.1 8B Instruct

Gemma 4 31B leads Llama 3.1 8B Instruct on the Artificial Analysis Intelligence Index, 14.7 to 6.9, and Llama 3.1 8B Instruct costs 5.0x less per output token ($0.08 vs $0.40 per million). Updated October 21, 2026; 38 benchmarks have a result for both.

Gemma 4 31BGoogle
Coding
39.0
Overall
42.1
Output $/M
$0.40
38
Llama 3.1 8B InstructMeta Llama
Coding
No data
Overall
17.9
Output $/M
$0.08
0
vs boards won of 38 shared

Gemma 4 31B or Llama 3.1 8B Instruct: which to pick

Only Gemma 4 31B has a coding score, 39.0 on the Vibe Coding Index; Llama 3.1 8B Instruct has none, so the two cannot be ranked on coding.

Pick Llama 3.1 8B Instruct for output tokens 5.0x cheaper ($0.08 vs $0.40 per million).

Shared results
38
Gemma 4 31B only
33
Llama 3.1 8B Instruct only
13
Like-for-like categories
7 of 9

Only benchmarks that tested both models count toward a pick; a result only one model has is shown but not compared.

Which one for your work

Each card is decided by one number both models carry. Where only one has it, the card says so and makes no call.

At a glance

Coding index
Gemma 4 31B 39.0 from 2 benchmarks, Llama 3.1 8B Instruct not benchmarked.
Widest category
Math, 55.5 points apart on average over 3 shared benchmarks.
Widest single gap
OTIS Mock AIME: Gemma 4 31B 73.3% against Llama 3.1 8B Instruct 1.7%, 71.7 points apart on a 0 to 100 scale.
Output price
Gemma 4 31B $0.40 against Llama 3.1 8B Instruct $0.08 per million output tokens, 5.0x apart.
Context window
Gemma 4 31B takes 262K tokens, Llama 3.1 8B Instruct 131K.

Benchmark by benchmark

First the score: boards each model leads, per category, where both have a result. Then every board, a category to a fold; bars are each result on a 0 to 100 scale, so compare the two in a row, not one row with another.

Boards won, where both have a result
CategoryGemma 4 31BBarsLlama 3.1 8B InstructTies
Coding50
Intelligence20
Agentic work10
Reasoning60
Math30
Knowledge40
General170
All shared boards380
CodingLike-for-likeSix of these boards feed the Vibe Coding Index50
Coding benchmarks for Gemma 4 31B and Llama 3.1 8B Instruct
BenchmarkGemma 4 31BLlama 3.1 8B InstructLeader
LiveBench coding49.0%Not measuredOnly Gemma 4 31B measured
LMArena WebDev1367Not measuredOnly Gemma 4 31B measured
AA Coding Index43.45.4Gemma 4 31B
LiveCodeBench (Artificial Analysis run)Not measured11.6%Only Llama 3.1 8B Instruct measured
SciCode45.5%Not measuredOnly Gemma 4 31B measured
Terminal-Bench Hard (Artificial Analysis run)36.4%0.8%Gemma 4 31B
WeirdML52.3%1.7%Gemma 4 31B
ALE-Bench925.5Not measuredOnly Gemma 4 31B measured
LMArena Text: coding14591195Gemma 4 31B
LMArena Text: software and IT14631195Gemma 4 31B
LMArena WebDev: React1359Not measuredOnly Gemma 4 31B measured
LMArena WebDev: HTML1380Not measuredOnly Gemma 4 31B measured
SciCode8.9%Not measuredOnly Gemma 4 31B measured
Neither model has a result on the other 26 boards here
IntelligenceLike-for-likePublic boards, shown as published, kept out of the index20
Intelligence benchmarks for Gemma 4 31B and Llama 3.1 8B Instruct
BenchmarkGemma 4 31BLlama 3.1 8B InstructLeader
AA Intelligence Index14.76.9Gemma 4 31B
Epoch Capabilities Index143.0116.5Gemma 4 31B
Agentic workLike-for-likePublic boards, shown as published, kept out of the index10
Agentic work benchmarks for Gemma 4 31B and Llama 3.1 8B Instruct
BenchmarkGemma 4 31BLlama 3.1 8B InstructLeader
AA Agentic Index4.2Not measuredOnly Gemma 4 31B measured
LiveBench research44.4%Not measuredOnly Gemma 4 31B measured
LiveBench browser4.0%Not measuredOnly Gemma 4 31B measured
LiveBench long agentic13.3%Not measuredOnly Gemma 4 31B measured
τ²-Bench Telecom65.5%16.4%Gemma 4 31B
BALROGNot measured15.1%Only Llama 3.1 8B Instruct measured
Berkeley Function Calling Leaderboard (BFCL)Not measured25.8%Only Llama 3.1 8B Instruct measured
Neither model has a result on the other 34 boards here
ReasoningLike-for-likePublic boards, shown as published, kept out of the index60
Reasoning benchmarks for Gemma 4 31B and Llama 3.1 8B Instruct
BenchmarkGemma 4 31BLlama 3.1 8B InstructLeader
LiveBench reasoning68.3%Not measuredOnly Gemma 4 31B measured
GPQA Diamond (Artificial Analysis run)85.7%25.9%Gemma 4 31B
Humanity's Last Exam (Artificial Analysis run)23.6%5.3%Gemma 4 31B
GPQA Diamond (Epoch AI run)75.8%27.0%Gemma 4 31B
LMArena Text: hard prompts14481175Gemma 4 31B
LMArena Text: expert14641144Gemma 4 31B
LMArena Text: hard prompts in English14561196Gemma 4 31B
LMArena Vision: diagrams1283Not measuredOnly Gemma 4 31B measured
LMArena Vision: homework1310Not measuredOnly Gemma 4 31B measured
Kagi LLM Benchmark63.5%Not measuredOnly Gemma 4 31B measured
Neither model has a result on the other 12 boards here
MathLike-for-likePublic boards, shown as published, kept out of the index30
Math benchmarks for Gemma 4 31B and Llama 3.1 8B Instruct
BenchmarkGemma 4 31BLlama 3.1 8B InstructLeader
AA Math IndexNot measured4.3Only Llama 3.1 8B Instruct measured
AIME 2025 (Artificial Analysis run)Not measured4.3%Only Llama 3.1 8B Instruct measured
OTIS Mock AIME73.3%1.7%Gemma 4 31B
MATH level 5Not measured22.9%Only Llama 3.1 8B Instruct measured
GSM8KNot measured82.4%Only Llama 3.1 8B Instruct measured
LMArena Text: math14631179Gemma 4 31B
LMArena Text: mathematical work14651180Gemma 4 31B
Neither model has a result on the other 6 boards here
KnowledgeLike-for-likePublic boards, shown as published, kept out of the index40
Knowledge benchmarks for Gemma 4 31B and Llama 3.1 8B Instruct
BenchmarkGemma 4 31BLlama 3.1 8B InstructLeader
CaseLaw (Vals AI)52.6%Not measuredOnly Gemma 4 31B measured
MortgageTax (Vals AI)61.4%Not measuredOnly Gemma 4 31B measured
MMLU Pro (Artificial Analysis run)Not measured47.6%Only Llama 3.1 8B Instruct measured
SimpleQA Verified10.4%Not measuredOnly Gemma 4 31B measured
MMLUNot measured56.1%Only Llama 3.1 8B Instruct measured
LMArena Text: science14571193Gemma 4 31B
LMArena Text: medicine and healthcare14511182Gemma 4 31B
LMArena Text: legal and government14381206Gemma 4 31B
LMArena Text: business and finance14301166Gemma 4 31B
FACTS Benchmark Suite45.3%Not measuredOnly Gemma 4 31B measured
Neither model has a result on the other 8 boards here
Web designDirectional onlyPublic boards, shown as published, kept out of the index1 board, none shared
Web design benchmarks for Gemma 4 31B and Llama 3.1 8B Instruct
BenchmarkGemma 4 31BLlama 3.1 8B InstructLeader
LiveBench design58.4%Not measuredOnly Gemma 4 31B measured
Neither model has a result on the other 8 boards here
GeneralLike-for-likePublic boards, shown as published, kept out of the index170
General benchmarks for Gemma 4 31B and Llama 3.1 8B Instruct
BenchmarkGemma 4 31BLlama 3.1 8B InstructLeader
LiveBench data analysis53.3%Not measuredOnly Gemma 4 31B measured
SAGE (Vals AI)55.0%Not measuredOnly Gemma 4 31B measured
IFBench75.6%28.6%Gemma 4 31B
Long context reasoning (AA-LCR)69.7%18.0%Gemma 4 31B
DTBench82.7%50.9%Gemma 4 31B
LMCA39.3%5.4%Gemma 4 31B
Surface Evolver Bench30.6%Not measuredOnly Gemma 4 31B measured
PIQANot measured81.2%Only Llama 3.1 8B Instruct measured
LMArena Text14431187Gemma 4 31B
LMArena Text: instruction following14331159Gemma 4 31B
LMArena Text: creative writing14171154Gemma 4 31B
LMArena Vision1276Not measuredOnly Gemma 4 31B measured
LMArena Text: English14511218Gemma 4 31B
LMArena Text: non-English14301148Gemma 4 31B
LMArena Text: Chinese14751151Gemma 4 31B
LMArena Text: GermanNot measured1144Only Llama 3.1 8B Instruct measured
LMArena Text: JapaneseNot measured1061Only Llama 3.1 8B Instruct measured
LMArena Text: KoreanNot measured1053Only Llama 3.1 8B Instruct measured
LMArena Text: French14361178Gemma 4 31B
LMArena Text: Spanish14421169Gemma 4 31B
LMArena Text: Russian14601158Gemma 4 31B
LMArena Text: Polish1433Not measuredOnly Gemma 4 31B measured
LMArena Text: multi-turn14521172Gemma 4 31B
LMArena Text: longer queries14461181Gemma 4 31B
LMArena Text: writing and language14321162Gemma 4 31B
LMArena Text: entertainment and media14051145Gemma 4 31B
LMArena Vision: English1271Not measuredOnly Gemma 4 31B measured
LMArena Vision: Chinese1326Not measuredOnly Gemma 4 31B measured
LMArena Vision: reading text1282Not measuredOnly Gemma 4 31B measured
LMArena Vision: humor1280Not measuredOnly Gemma 4 31B measured
LMArena Vision: captioning1218Not measuredOnly Gemma 4 31B measured
LMArena Vision: recognizing things1226Not measuredOnly Gemma 4 31B measured
LMArena Vision: creative writing1285Not measuredOnly Gemma 4 31B measured
LMArena Document1425Not measuredOnly Gemma 4 31B measured
Neither model has a result on the other 12 boards here
Image generationNot comparablePublic boards, shown as published, kept out of the index0 boards, none shared
Image generation benchmarks for Gemma 4 31B and Llama 3.1 8B Instruct
BenchmarkGemma 4 31BLlama 3.1 8B InstructLeader
Neither model has a result on 5 boards here

What each workload costs

Three fixed token mixes at each model's listed price, so per-token rates become a bill.

Chat turn

1K input + 500 output tokens

Gemma 4 31B$0.0003Fits in one request
Llama 3.1 8B Instruct$0.0001Fits in one request

Llama 3.1 8B Instruct costs less

Repository review

50K input + 3K output tokens

Gemma 4 31B$0.0082Fits in one request
Llama 3.1 8B Instruct$0.0027Fits in one request

Llama 3.1 8B Instruct costs less

Agent loop

200K input + 10K output tokens

Gemma 4 31B$0.032Fits in one request
Llama 3.1 8B Instruct$0.011Exceeds the context window

Llama 3.1 8B Instruct costs less

Listed OpenRouter rates, without cache or batch discounts. A workload that does not fit a model's context window would need splitting.

Specification differences

The leading value in a row is marked; a row with a missing value names no leader. Our two rows are marked in red.

Specifications of Gemma 4 31B and Llama 3.1 8B Instruct
SpecificationGoogle Gemma 4 31BMeta Llama 3.1 8B Instruct
MakerGoogleMeta Llama
WeightsOpen weightsOpen weights
ReleasedApril 2, 2026July 23, 2024
Context window262K131K
Input $/Mtok$0.14$0.05
Output $/Mtok$0.40$0.08
Coding index39.0Not benchmarked
Independent measurements behind it20
Cost per solved taskNot computableNot computable
SourceOpenRouter listingOpenRouter listing

Questions

Is Gemma 4 31B better than Llama 3.1 8B Instruct for coding?

Only Gemma 4 31B has a coding score, 39.0 on the Vibe Coding Index; Llama 3.1 8B Instruct has none, so the two cannot be ranked on coding. Pick Llama 3.1 8B Instruct for output tokens 5.0x cheaper ($0.08 vs $0.40 per million).

Which is cheaper, Gemma 4 31B or Llama 3.1 8B Instruct?

Gemma 4 31B costs $0.14 per million input tokens and $0.40 per million output tokens; Llama 3.1 8B Instruct costs $0.05 and $0.08. Cost per solved task is known for neither of them.

Which has the bigger context window, Gemma 4 31B or Llama 3.1 8B Instruct?

Gemma 4 31B, with 262K tokens against 131K.

How many benchmarks is the Gemma 4 31B vs Llama 3.1 8B Instruct comparison based on?

38 benchmarks have a result for both models as of October 21, 2026. Gemma 4 31B's coding index rests on 2 independent benchmarks and Llama 3.1 8B Instruct's on 0. Where only one model has a result, the page says so instead of naming a winner.

Compare next