import requests r = requests.post( "https://api.aimlapi.com/v1/chat/completions", headers={"Authorization": "Bearer " + AIMLAPI_KEY}, json={ "model": "google/gemma-4-31b-it", "messages": [ { "role": "user", "content": "Hello!" } ] }, ) print(r.json())
const r = await fetch("https://api.aimlapi.com/v1/chat/completions", { method: "POST", headers: { Authorization: `Bearer ${process.env.AIMLAPI_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ "model": "google/gemma-4-31b-it", "messages": [ { "role": "user", "content": "Hello!" } ] }), }); console.log(await r.json());
curl -X POST https://api.aimlapi.com/v1/chat/completions \ -H "Authorization: Bearer $AIMLAPI_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"google/gemma-4-31b-it","messages":[{"role":"user","content":"Hello!"}]}'
OpenAI-compatible — swap the base URL and it works with your existing SDK.
| Type | Price |
|---|---|
| Input | |
| Output | |
| Cached input |
| Benchmark | Score | What it measures | Source | Retrieved |
|---|---|---|---|---|
| MMLU-Pro | 85.2% | Multi-discipline knowledge + reasoning (harder MMLU) | Source | July 13, 2026 |
| LiveCodeBench | 80.0% | Contamination-free competitive programming problems | Source | July 13, 2026 |
| GPQA Diamond | 84.3% | Google-proof graduate science questions (hardest subset) | Source | July 13, 2026 |
| Intelligence | 15.4 | Composite score across standardised reasoning, knowledge and problem-solving evaluations, measured independently by Artificial Analysis | Source | September 12, 2026 |
| Coding | 43.4 | Composite score across standardised coding evaluations, measured independently by Artificial Analysis | Source | September 12, 2026 |
| Model | Input | Output | Context | Best for |
|---|---|---|---|---|
Gemma 4 31B This page | Reasoning + agents | |||
| Reasoning + agents | ||||
| Balanced coding + agents | ||||
| Long-context, multimodal & agentic workflows | ||||
| Reasoning + agents |
Gemma 4 31B has a 256,000 tokens context window and can return up to 262,144 tokens.
Gemma 4 31B takes image, text as input and returns text.
Use google/gemma-4-31b-it as the model id. Requests go to https://api.aimlapi.com/v1/chat/completions.
Gemma 4 31B became available on April 3, 2026.
Gemma 4 31B is priced at input $1.361646 / 1M tokens, output $2.049346 / 1M tokens, cached input $1.361646 / 1M tokens.
Yes, Gemma 4 31B can stream responses as they are generated.
Yes, Gemma 4 31B accepts image input alongside text.
Gemma 4 31B was built by Google.