Gemma 4 31B vs Phi 4

    Comparison

    As of August 25, 2026, Phi 4 is 61% cheaper per million tokens than Gemma 4 31B. Gemma 4 31B is $0.14 / $0.40 per million input/output tokens versus Phi 4 at $0.07 / $0.14. Sources: https://ai.google.dev/gemini-api/docs/pricing and https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/

    Sources: Gemini API pricing (https://ai.google.dev/gemini-api/docs/pricing); Microsoft pricing (https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/)

    Gemma 4 31B

    Google

    $0.54blended / 1M

    Input

    $0.14

    Output

    $0.40

    262.1K ctx|Open Source
    61%
    cheaper
    Better value

    Phi 4

    Microsoft

    $0.21blended / 1M

    Input

    $0.07

    Output

    $0.14

    16K ctx|Open Source
    Save $0.33 per million tokens by choosing Phi 4 over Gemma 4 31B.

    Gemma 4 31B vs Phi 4 comparison

    Token pricing, specs, and benchmarks side by side

    Shared benchmarks

    Each bar is share of the current leader on that eval. Click a row to open the board.

    Score vs price

    GPQA. Left is cheaper. Up is a higher score. The line is the best score you can buy at each price.

    Best score at each priceGemma 4 31BPhi 4
    Metric
    Gemma 4 31B
    Phi 4
    Provider
    Provider
    Google
    Microsoft
    License
    Open Source
    Open Source
    Release Date
    2026-04-02
    2024-12-12
    Pricing (per 1M tokens)
    Input Price+100%
    $0.14
    $0.07
    Output Price+186%
    $0.40
    $0.14
    Blended (1M + 1M)
    $0.54
    $0.21
    Model Details
    Context Window
    262.1K
    16K
    Max Output Tokens
    131.1K
    16K
    Knowledge Cutoff
    2025-01-01
    2024-06-01
    Throughput
    1.2 tok/s
    33 tok/s
    Benchmarks
    26.5%
    84.3%
    56.1%
    56.1%
    43.4%
    9.6%
    3%
    63%
    76.9%
    88.4%
    13.8%
    28.8%
    84.8%
    82.6%
    80.4%
    89.2%
    75.4%
    1.4%
    75.5%
    47.6%
    85.6%
    61.3%
    80.6%
    85.2%
    70.4%
    66.4%
    56.2%
    55.0%
    86.4%
    Benchmark Wins
    Gemma 4 31B 3|0 Phi 4

    Verdict

    Gemma 4 31B vs Phi 4: the bottom line

    Phi 4 offers significantly lower pricing, while Gemma 4 31B leads on benchmark performance. Your choice depends on whether cost efficiency or raw capability matters more for your use case.

    Gemma 4 31B vs Phi 4 FAQ

    Which is cheaper, Gemma 4 31B or Phi 4?

    As of August 25, 2026, Phi 4 is 61% cheaper on blended LLM API pricing. Phi 4 costs $0.07 per million input tokens and $0.14 per million output tokens ($0.21 blended 1M-in + 1M-out). Gemma 4 31B costs $0.14 / $0.40 per million tokens ($0.54 blended). Sources: https://ai.google.dev/gemini-api/docs/pricing and https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/. The cheapest LLM for your app still depends on how many output tokens you generate.

    How much does Gemma 4 31B vs Phi 4 cost per million tokens?

    Gemma 4 31B Gemini API pricing is $0.14 input and $0.40 output per million tokens via Google. Phi 4 Microsoft API pricing is $0.07 input and $0.14 output per million tokens via Microsoft. Use those four numbers, not ChatGPT Plus or Claude Pro subscription prices, when you are comparing APIs.

    Which is better for coding, Gemma 4 31B or Phi 4?

    Phi 4 has a published HumanEval score of 82.6%. Gemma 4 31B does not have that eval on this page yet.

    What is the context window for Gemma 4 31B vs Phi 4?

    Gemma 4 31B supports a 262K token context window, while Phi 4 supports 16K tokens. Gemma 4 31B offers a larger context window. Filling a larger window bills more input tokens, so the cheaper-per-million model can still cost more on long documents.

    Which model performs better on benchmarks, Gemma 4 31B or Phi 4?

    Gemma 4 31B leads on 3 of 3 shared benchmarks versus Phi 4's 0 wins. Check the comparison table for GPQA Diamond, SWE-bench, MMLU, HLE, and the other evals we track. Token price and benchmark score together are the usual LLM comparison, not either number alone.

    Is Gemma 4 31B or Phi 4 better for production use?

    Both Gemma 4 31B and Phi 4 are production API models. For cost-sensitive production traffic, Phi 4 has better economics on the blended 1M-in + 1M-out scale. For maximum capability, weight the benchmark table for your domain. Many production stacks route cheap models for drafts and a frontier model for the hard turn, which is usually cheaper than sending everything to the expensive API.

    Can I switch between Gemma 4 31B and Phi 4 in my app?

    Yes. Call Gemma 4 31B through Google and Phi 4 through Microsoft with separate API keys, or through a gateway that already wraps both. Keep prompts in tokens, not characters, when you estimate the invoice. AnotherWrapper templates can swap providers without rewriting auth and billing.

    How accurate is this Gemma 4 31B vs Phi 4 pricing data?

    List rates are the latest published Gemini API pricing and Microsoft API pricing, quoted per million tokens. Official rate sheets: https://ai.google.dev/gemini-api/docs/pricing and https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/. Prompt caching, batch APIs, and committed-use discounts can change the invoice. Benchmark scores are from official publications and independent evals, updated as new numbers land.

    What is the output token limit for Gemma 4 31B and Phi 4?

    Gemma 4 31B supports up to 131K output tokens per request, while Phi 4 supports up to 16K output tokens. Output tokens are usually the expensive half of API pricing, so a higher max output cap is a capability, not a discount.

    Which model has better throughput, Gemma 4 31B or Phi 4?

    Gemma 4 31B runs at approximately 1.2 tokens/second while Phi 4 runs at 33 tokens/second. Phi 4 is faster in raw throughput. Throughput (tokens per second) and time-to-first-token are why two models with the same per-million-token price can still feel different in chat and agents.

    How do I switch the models in this Gemma 4 31B vs Phi 4 comparison?

    Use the model pickers at the top of this LLM comparison. Search any model in the index and the URL updates. Open Gemma 4 31B or Phi 4 from the sidebar for the single-model API pricing page, or go back to the LLM pricing table to sort by cheapest blended cost.

    Gemma 4 31B vs Phi 4 pricing

    This comparison covers API pricing, context window, throughput, and benchmark scores. Gemma 4 31B costs $0.14/M input and $0.40/M output. Phi 4 costs $0.07/M input and $0.14/M output.

    Rank both on the LLM leaderboard, SWE-bench, and Humanity's Last Exam.

    The index

    All Large Language Models

    280 models across 33 providers. Search or jump to a lab — every model page stays linked here.

    Baidu

    1 models

    Inception

    1 models

    inclusionAI

    1 models

    LG AI Research

    1 models

    Nous Research

    1 models

    Sakana AI

    1 models

    StepFun

    1 models

    Tencent

    1 models

    Thinking Machines

    1 models

    Unisound

    1 models

    Upstage

    1 models

    Next step

    You found the model. Now ship the product.

    Auth, billing, and the API layer are already decided. Fork 8 finished AI apps, or have us build the first version with you.