AI model comparison

Gemma 4 31B vs Phi 4

Side by side comparison of Gemma 4 31B and Phi 4 on pricing, benchmark scores, context window, and more.

Gemma 4 31B Instruct is Google DeepMind's 30.7B dense multimodal model supporting text and image input with text output.

Input / 1M
$0.20
Output / 1M
$0.40
Context
262K

[Microsoft Research](/microsoft) Phi-4 is designed to perform well in complex reasoning tasks and can operate efficiently in situations with limited memory or where quick responses are needed.

Input / 1M
$0.07
Output / 1M
$0.14
Context
16K

Comparing image generators? Compare image models

At a glance

Quick verdict

How the two models stack up on the things people ask about most.

Lower price

microsoft logo

Phi 4

2.9x cheaper for a typical chat

Higher intelligence score

microsoft logo

Phi 4

5.9 vs 4.4 on Artificial Analysis

Larger context window

google logo

Gemma 4 31B

262K vs 16K tokens

Newer release

google logo

Gemma 4 31B

Released April 2, 2026

Benchmarks

Benchmark scores

Independent scores from Artificial Analysis. Higher is better.

Intelligence index

google logoGemma 4 31B4.4
microsoft logoPhi 45.9

Coding index

google logoGemma 4 31B43.4
microsoft logoPhi 4Not available

Agentic index

google logoGemma 4 31B4.2
microsoft logoPhi 4Not available

Pricing

Gemma 4 31B vs Phi 4 API pricing

Per-token API rates. Cheaper option highlighted.

Metricgoogle logoGemma 4 31Bmicrosoft logoPhi 4
Input tokensPer 1M tokens$0.20$0.07
Output tokensPer 1M tokens$0.40$0.14
Cached input (read)Per 1M tokensNot availableNot available
Cache writePer 1M tokensNot availableNot available

What it costs in practice

Estimated cost per 1,000 requests at standard rates. Coding and long-document figures also show the cost when the input is already cached.

Chat message

2K in, 500 out

google logoGemma 4 31B$0.60
microsoft logoPhi 4$0.21

Coding task

30K in, 4K out

google logoGemma 4 31B$7.60
microsoft logoPhi 4$2.66

Long document summary

150K in, 2K out

google logoGemma 4 31B$30.80
microsoft logoPhi 4$10.78

Specs

Context window and capabilities

How much each model can read, how much it can write, and what it accepts as input.

Metricgoogle logoGemma 4 31Bmicrosoft logoPhi 4
Context window262K tokens16K tokens
Max output16K tokens15K tokens
Input typesImage, Text, VideoText
Output typesTextText
Reasoning effort levelsNot availableNot available
Default reasoning effortNot availableNot available
Release dateApril 2, 2026January 10, 2025

Features

Supported features

API features available for each model.

Metricgoogle logoGemma 4 31Bmicrosoft logoPhi 4
Tool callingSupportedNot supported
Structured outputsSupportedSupported
JSON modeSupportedSupported
ReasoningSupportedNot supported
TemperatureSupportedSupported
Stop sequencesSupportedSupported
Deterministic seedSupportedSupported
Verbosity controlNot supportedNot supported

Our take

Phi 4 is 2.9x cheaper for a typical chat. Phi 4 scores higher on the Artificial Analysis Intelligence Index (5.9 vs 4.4). Gemma 4 31B has the larger context window (262K vs 16K tokens). The right pick depends on your workload, so the quickest way to settle it is to send the same prompt to both and compare.

FAQ

Frequently asked questions

Is Gemma 4 31B or Phi 4 cheaper?

Phi 4 is cheaper for a typical chat (2K input tokens and 500 output tokens). Phi 4 costs $0.07 per 1M input tokens and $0.14 per 1M output tokens, while Gemma 4 31B costs $0.20 per 1M input tokens and $0.40 per 1M output tokens.

Which has a bigger context window, Gemma 4 31B or Phi 4?

Gemma 4 31B supports up to 262K tokens of context, compared with 16K for Phi 4.

Is Gemma 4 31B smarter than Phi 4?

On the Artificial Analysis Intelligence Index, Gemma 4 31B scores 4.4 and Phi 4 scores 5.9, putting Phi 4 ahead. Benchmarks don't capture everything, so the best test is running your own prompts through both.

Can I use Gemma 4 31B and Phi 4 at the same time?

Yes. Shortcut Chat sends one prompt to multiple models at once, so you can see Gemma 4 31B and Phi 4 answer side by side and keep the better response.

google logomicrosoft logo

Why choose? Ask both.

Send one prompt to Gemma 4 31B and Phi 4 at the same time. Compare the answers side by side and keep the best one.