Gemma 4 31B
By Google. 31.3 billion parameters, a context window of 262,144 tokens and the licence apache-2.0.
Facts
- Released
- 2026-03-11 the day the repository was first published on Hugging Face Hugging Face, read
- Licence
- apache-2.0 the licence the model card declares Hugging Face, read
- Open weights
- Yes the weights are published in this Hugging Face repository Hugging Face, read
- Parameters
- 31.3 billion counted from the safetensors weight files Hugging Face, read
- Active parameters
- Unknown
- Knowledge cutoff
- Unknown
- Context window
- 262,144 tokens the maximum position embeddings in the model configuration model configuration, read
- 262,144 tokens the context length OpenRouter lists OpenRouter, read
- Longest output
- 16,384 tokens the largest output OpenRouter's first provider allows OpenRouter, read
- Tool calling
- Yes OpenRouter lists tools among the supported parameters OpenRouter, read
- Structured output
- Yes OpenRouter lists structured outputs among the supported parameters OpenRouter, read
- Reasoning controls
- Yes OpenRouter lists reasoning controls OpenRouter, read
- Inputs and outputs
- text, image in, text out Hugging Face, read
- Good for
- Vision: Hugging Face files it under image-text-to-text Hugging Face, read
- Reasoning: OpenRouter lists reasoning controls for it OpenRouter, read
Prices
| Provider | Input | Output | Context | As of | Source |
|---|---|---|---|---|---|
| Nvidia direct | 0 USD | 0 USD | 256,000 | older than 30 days; check the provider | models.dev, read |
| DeepInfra through OpenRouter | 0.090 USD | 0.340 USD | 262,144 | OpenRouter endpoints, read | |
| DeepInfra through OpenRouter | 0.090 USD | 0.340 USD | 262,144 | OpenRouter endpoints, read | |
| Kilo Gateway direct | 0.090 USD | 0.340 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| OpenRouter direct | 0.090 USD | 0.340 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| CoreWeave direct | 0.100 USD | 0.340 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| CoreWeave through OpenRouter | 0.100 USD | 0.340 USD | 262,144 | OpenRouter endpoints, read | |
| CoreWeave through OpenRouter | 0.100 USD | 0.340 USD | 262,144 | OpenRouter endpoints, read | |
| NanoGPT direct | 0.100 USD | 0.450 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| Lilac direct | 0.110 USD | 0.350 USD | 262,100 | older than 30 days; check the provider | models.dev, read |
| Venice through OpenRouter | 0.120 USD | 0.360 USD | 256,000 | OpenRouter endpoints, read | |
| Venice through OpenRouter | 0.120 USD | 0.360 USD | 256,000 | OpenRouter endpoints, read | |
| Chutes through OpenRouter | 0.120 USD | 0.370 USD | 131,072 | OpenRouter endpoints, read | |
| Chutes through OpenRouter | 0.120 USD | 0.370 USD | 131,072 | OpenRouter endpoints, read | |
| Deep Infra direct | 0.130 USD | 0.380 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| DeepInfra through OpenRouter | 0.130 USD | 0.380 USD | 262,144 | OpenRouter endpoints, read | |
| DeepInfra through OpenRouter | 0.130 USD | 0.380 USD | 262,144 | OpenRouter endpoints, read | |
| FastRouter direct | 0.130 USD | 0.380 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| OrcaRouter direct | 0.130 USD | 0.380 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| SiliconFlow direct | 0.130 USD | 0.400 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| Abacus direct | 0.140 USD | 0.400 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| Crusoe direct | 0.140 USD | 0.400 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| Crusoe through OpenRouter | 0.140 USD | 0.400 USD | 262,144 | OpenRouter endpoints, read | |
| Crusoe through OpenRouter | 0.140 USD | 0.400 USD | 262,144 | OpenRouter endpoints, read | |
| Friendli direct | 0.140 USD | 0.400 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| Friendli through OpenRouter | 0.140 USD | 0.400 USD | 262,144 | OpenRouter endpoints, read | |
| Friendli through OpenRouter | 0.140 USD | 0.400 USD | 262,144 | OpenRouter endpoints, read | |
| Hugging Face direct | 0.140 USD | 0.400 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| Merge Gateway direct | 0.140 USD | 0.400 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| Novita through OpenRouter | 0.140 USD | 0.400 USD | 262,144 | OpenRouter endpoints, read | |
| Novita through OpenRouter | 0.140 USD | 0.400 USD | 262,144 | OpenRouter endpoints, read | |
| NovitaAI direct | 0.140 USD | 0.400 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| Vercel AI Gateway direct | 0.140 USD | 0.400 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| Parasail through OpenRouter | 0.150 USD | 0.400 USD | 262,144 | OpenRouter endpoints, read | |
| Parasail through OpenRouter | 0.150 USD | 0.400 USD | 262,144 | OpenRouter endpoints, read | |
| ai& direct | 0.200 USD | 0.500 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| Infomaniak direct | 0.250 USD | 0.500 USD | 100,000 | older than 30 days; check the provider | models.dev, read |
| DeepInfra through OpenRouter | 0.270 USD | 0.760 USD | 131,072 | OpenRouter endpoints, read | |
| DeepInfra through OpenRouter | 0.270 USD | 0.760 USD | 131,072 | OpenRouter endpoints, read | |
| Berget.AI direct | 0.275 USD | 0.550 USD | 128,000 | older than 30 days; check the provider | models.dev, read |
| SambaNova through OpenRouter | 0.380 USD | 1.15 USD | 262,144 | OpenRouter endpoints, read | |
| SambaNova through OpenRouter | 0.380 USD | 1.15 USD | 262,144 | OpenRouter endpoints, read | |
| Together AI direct | 0.390 USD | 0.970 USD | 262,144 | older than 30 days; check the provider | models.dev, read |
| Pioneer direct | 0.500 USD | 0.500 USD | 32,768 | older than 30 days; check the provider | models.dev, read |
| ModelRun through OpenRouter | 0.750 USD | 1.00 USD | 262,144 | OpenRouter endpoints, read | |
| ModelRun through OpenRouter | 0.750 USD | 1.00 USD | 262,144 | OpenRouter endpoints, read | |
| SiliconFlow through OpenRouter | 0.750 USD | 1.00 USD | 262,144 | OpenRouter endpoints, read | |
| SiliconFlow through OpenRouter | 0.750 USD | 1.00 USD | 262,144 | OpenRouter endpoints, read |
Run it on your own hardware
Weights are the sizes of the files a source lists, or an estimate from the parameter count where none does. Memory is an estimate: weights plus KV cache plus 512 MiB and 5 percent of the weights for runtime buffers. Check it against your hardware.
| Quantization | Weights | Memory at 8,192 tokens | Memory at 32,768 tokens |
|---|---|---|---|
| UD-IQ2_XXS | 7.9 GiB | 16.3 GiB | 38.8 GiB |
| UD-IQ2_M | 10.0 GiB | 18.5 GiB | 41.0 GiB |
| UD-Q2_K_XL | 11.0 GiB | 19.5 GiB | 42.0 GiB |
| UD-IQ3_XXS | 11.0 GiB | 19.6 GiB | 42.1 GiB |
| Q3_K_S | 12.3 GiB | 20.9 GiB | 43.4 GiB |
| Q3_K_M | 13.7 GiB | 22.4 GiB | 44.9 GiB |
| UD-Q3_K_XL | 14.3 GiB | 23.0 GiB | 45.5 GiB |
| IQ4_XS | 15.2 GiB | 24.0 GiB | 46.5 GiB |
| IQ4_NL | 16.1 GiB | 24.9 GiB | 47.4 GiB |
| Q4_0 | 16.1 GiB | 25.0 GiB | 47.5 GiB |
| Q4_K_S | 16.2 GiB | 25.0 GiB | 47.5 GiB |
| Q4_K_M | 17.1 GiB | 25.9 GiB | 48.4 GiB |
| UD-Q4_K_XL | 17.5 GiB | 26.4 GiB | 48.9 GiB |
| Q4_1 | 17.8 GiB | 26.7 GiB | 49.2 GiB |
| Q5_K_S | 19.7 GiB | 28.7 GiB | 51.2 GiB |
| Q5_K_M | 20.2 GiB | 29.2 GiB | 51.7 GiB |
| UD-Q5_K_XL | 20.4 GiB | 29.4 GiB | 51.9 GiB |
| Q6_K | 23.5 GiB | 32.6 GiB | 55.1 GiB |
| UD-Q6_K_XL | 25.6 GiB | 34.9 GiB | 57.4 GiB |
| Q8_0 | 30.9 GiB | 40.4 GiB | 62.9 GiB |
| UD-Q8_K_XL | 32.6 GiB | 42.2 GiB | 64.7 GiB |
Start it with a local runtime
- Ollama
ollama run hf.co/unsloth/gemma-4-31B-it-GGUF:Q4_0 - LM Studio
lms get unsloth/gemma-4-31B-it-GGUF lms server start - llama.cpp server
llama-server -hf unsloth/gemma-4-31B-it-GGUF:Q4_0 --jinja - vLLM
vllm serve google/gemma-4-31B-it - SGLang
sglang serve --model-path google/gemma-4-31B-it --port 30000
Use it from your harness
Set up for Abacus with the model google/gemma-4-31b-it. Each endpoint page has the same setup for its own address.
OpenCode
Put this in opencode.json in your project folder:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"abacus": {
"npm": "@ai-sdk/openai-compatible",
"name": "Abacus",
"options": {
"baseURL": "https://routellm.abacus.ai/v1",
"apiKey": "{env:ABACUS_API_KEY}"
},
"models": {
"google/gemma-4-31b-it": {
"name": "Gemma 4 31B",
"limit": {
"context": 262144,
"output": 16384
}
}
}
}
}
}- OpenCode reads any OpenAI-compatible address through the @ai-sdk/openai-compatible package, and an address that speaks the Responses API through @ai-sdk/openai.
From OpenCode documentation, read .
Pi
Put this in ~/.pi/agent/models.json:
{
"providers": {
"abacus": {
"baseUrl": "https://routellm.abacus.ai/v1",
"api": "openai-completions",
"apiKey": "$ABACUS_API_KEY",
"models": [
{
"id": "google/gemma-4-31b-it"
}
]
}
}
}- The apiKey field can name an environment variable as $NAME.
From Pi documentation, read .
Codex
Codex speaks only the Responses API, and Abacus documents no Responses address. A gateway that offers one can sit in between.
- Codex speaks the Responses API only: responses is the one supported wire API of a custom provider. Ollama and LM Studio are built in and start with --oss.
From Codex documentation, read .
Claude Code
Claude Code sends Anthropic Messages requests, and Abacus documents no such address. A gateway that translates to that API can sit in between.
- Claude Code sends Anthropic Messages requests to ANTHROPIC_BASE_URL. Anthropic says it does not support routing Claude Code to models other than Claude through any gateway, so some features may not work with another model.
From Claude Code documentation, read .
Other ways to reach it
- ai&, model
google/gemma-4-31b-it - Berget.AI, model
google/gemma-4-31B-it - Crusoe, model
google/gemma-4-31b-it - DeepInfra, model
google/gemma-4-31B-it - FastRouter, model
google/gemma-4-31b-it - Friendli, model
google/gemma-4-31B-it - Hugging Face, model
google/gemma-4-31B-it - Infomaniak, model
google/gemma-4-31B-it - Kilo Gateway, model
google/gemma-4-31b-it - Lilac, model
google/gemma-4-31b-it - NanoGPT, model
google/gemma-4-31b-it
Published results
These are results other people published. Baltor did not run them and does not rank models by them.
- Results the maker published on the model card published by google Hugging Face, read
- Artificial Analysis Coding Index: 43.4 published by Artificial Analysis OpenRouter, read
- Artificial Analysis Agentic Index: 4.2 published by Artificial Analysis OpenRouter, read
Sources of this page
- huggingface.co/api/models/google/gemma-4-31B-it, read
- huggingface.co/google/gemma-4-31B-it/raw/main/config.json, read
- huggingface.co/api/models/unsloth/gemma-4-31B-it-GGUF/tree/main, read
- openrouter.ai/api/v1/models/google/gemma-4-31b-it-20260402/endpoints, read
- openrouter.ai/api/v1/models, read
- models.dev/api.json, read
Paid links
No link in this directory is a paid link or an ad, and no listing is paid for. The order and the contents of every list come from the sources named on this page.