{"slug":"gemma-4-31b-it","name":"Gemma 4 31B","family":"gemini","family_name":"Gemini","developer":"Google","color":"#4285f4","status":"active","released":"2026-04-02","snapshot_of":null,"open":true,"context":262144,"max_output":32768,"knowledge_cutoff":null,"modalities":["text","image","video"],"output_modalities":["text"],"reasoning":true,"tools":true,"structured_output":true,"huggingface":"google/gemma-4-31B-it","speed":32.5,"latency":0.93,"short":"Google's open-weight model, released April 2026, accepting text, image and video input. It is very cheap and efficient but ranks low on most benchmarks.","strengths":["Seventh of 194 for intelligence per dollar, at 288.5 points","Blended price $0.18 per million tokens, 24th cheapest of 194","262k context window with image and video input","LMArena text rating 1443, 50th of 114, slightly above median"],"weaknesses":["Intelligence index 51.2, 86th of 114, below median 59.5","SimpleQA Verified 10.4%, last of 76 models tested","GPQA Diamond 75.8%, 85th of 94; OTIS Mock AIME 84th of 95"],"best_for":"Low-cost, high-volume agent tasks needing tool calling, long context or image input, where top benchmark scores matter less.","long":"Gemma 4 31B is an open-weight model from Google, released April 2026, that accepts text, image and video and offers a 262k context window with up to 32k output tokens. It supports tool calling, structured output and a reasoning mode. Its main appeal is cost: input is $0.12 and output $0.35 per million tokens, a blended $0.18 against a registry median of about $1.01, which gives it seventh place for intelligence per dollar.\n\nOn capability it sits in the lower part of the registry. Its intelligence index is 51.2 against a median of 59.5, ranking 86th of 114. It scores 75.8% on GPQA Diamond and 73.3% on OTIS Mock AIME, both well below median, and 10.4% on SimpleQA Verified, last of 76 models tested. Its LMArena text rating of 1442.9 is slightly above the median, so chat preference is roughly typical.","described":true,"gateway":true,"byok":true,"string":"gateway/doubleword:google/gemma-4-31B-it","input":0.12,"output":0.35,"cache_read":null,"blended":0.1775,"efficiency":288.5,"bench":{"index":51.2,"gpqa":75.8,"aime":73.3,"simpleqa":10.4,"scicode":45.5,"webdev":1364.1,"lmarena":1442.9,"eci":144.1},"offers":[{"provider":"doubleword","name":"Doubleword","model_id":"google/gemma-4-31B-it","api":["openai"],"input":0.12,"output":0.35,"cache_read":null,"cache_write":null,"input_tiers":[],"output_tiers":[],"context":null,"deprecated":false,"gateway":true,"gateway_route":"doubleword","byok":true,"string":null,"gateway_string":"gateway/doubleword:google/gemma-4-31B-it"},{"provider":"novita","name":"Novita","model_id":"google/gemma-4-31b-it","api":["openai"],"input":0.14,"output":0.4,"cache_read":null,"cache_write":null,"input_tiers":[],"output_tiers":[],"context":262144,"deprecated":false,"gateway":false,"gateway_route":null,"byok":true,"string":null,"gateway_string":null},{"provider":"openrouter","name":"OpenRouter","model_id":"google/gemma-4-31b-it","api":["openai"],"input":0.15,"output":0.4,"cache_read":0.06,"cache_write":null,"input_tiers":[],"output_tiers":[],"context":262144,"deprecated":false,"gateway":false,"gateway_route":null,"byok":true,"string":"openrouter:google/gemma-4-31b-it","gateway_string":null}],"ranks":{"intelligence":83,"popularity":35,"efficiency":7,"speed":164,"price":24},"top_score":0.7608,"about":["Google's open-weight model, released April 2026, accepting text, image and video input. It is very cheap and efficient but ranks low on most benchmarks.","Gemma 4 31B is an open-weight model from Google, released April 2026, that accepts text, image and video and offers a 262k context window with up to 32k output tokens. It supports tool calling, structured output and a reasoning mode. Its main appeal is cost: input is $0.12 and output $0.35 per million tokens, a blended $0.18 against a registry median of about $1.01, which gives it seventh place for intelligence per dollar.","On capability it sits in the lower part of the registry. Its intelligence index is 51.2 against a median of 59.5, ranking 86th of 114. It scores 75.8% on GPQA Diamond and 73.3% on OTIS Mock AIME, both well below median, and 10.4% on SimpleQA Verified, last of 76 models tested. Its LMArena text rating of 1442.9 is slightly above the median, so chat preference is roughly typical."],"examples":[{"file":"hello.py","lang":"python","code":"# /// script\n# dependencies = [\"pydantic-ai\"]\n# ///\nimport os\n\nfrom pydantic_ai import Agent\n\nos.environ['PYDANTIC_AI_GATEWAY_API_KEY'] = '...'\n\nagent = Agent('gateway/doubleword:google/gemma-4-31B-it', instructions='Be concise, reply with one sentence.')\n\nresult = agent.run_sync('Where does \"hello world\" come from?')\nprint(result.output)","soon":false},{"file":"structured_output.py","lang":"python","code":"# /// script\n# dependencies = [\"pydantic-ai\"]\n# ///\nimport os\n\nfrom pydantic import BaseModel\nfrom pydantic_ai import Agent\n\nos.environ['PYDANTIC_AI_GATEWAY_API_KEY'] = '...'\n\n\nclass CityLocation(BaseModel):\n    city: str\n    country: str\n\n\nagent = Agent('gateway/doubleword:google/gemma-4-31B-it', output_type=CityLocation)\n\nresult = agent.run_sync('Where were the olympics held in 2012?')\nprint(result.output)\n#> city='London' country='United Kingdom'","soon":false},{"file":"tools.py","lang":"python","code":"# /// script\n# dependencies = [\"pydantic-ai\"]\n# ///\nimport os\nimport random\n\nfrom pydantic_ai import Agent, RunContext\n\nos.environ['PYDANTIC_AI_GATEWAY_API_KEY'] = '...'\n\nagent = Agent(\n    'gateway/doubleword:google/gemma-4-31B-it',\n    deps_type=str,\n    instructions=\"You're a dice game, roll the die and see if it matches the user's guess.\",\n)\n\n\n@agent.tool_plain\ndef roll_dice() -> str:\n    \"\"\"Roll a six-sided die and return the result.\"\"\"\n    return str(random.randint(1, 6))\n\n\n@agent.tool\ndef get_player_name(ctx: RunContext[str]) -> str:\n    \"\"\"Get the player's name.\"\"\"\n    return ctx.deps\n\n\nresult = agent.run_sync('My guess is 4', deps='Anne')\nprint(result.output)","soon":false},{"file":"streaming.py","lang":"python","code":"# /// script\n# dependencies = [\"pydantic-ai\"]\n# ///\nimport asyncio\nimport os\n\nfrom pydantic_ai import Agent\n\nos.environ['PYDANTIC_AI_GATEWAY_API_KEY'] = '...'\n\nagent = Agent('gateway/doubleword:google/gemma-4-31B-it')\n\n\nasync def main():\n    async with agent.run_stream('Explain prompt caching in three bullet points.') as response:\n        async for text in response.stream_text(delta=True):\n            print(text, end='', flush=True)\n\n\nasyncio.run(main())","soon":false},{"file":"pax.sh","lang":"sh","code":"export PYDANTIC_AI_GATEWAY_API_KEY='...'\n\nuvx pax --model 'gateway/doubleword:google/gemma-4-31B-it'","soon":true},{"file":"codex.sh","lang":"sh","code":"# npm install -g @openai/codex\nexport PYDANTIC_AI_GATEWAY_API_KEY='...'\n\ncodex --model 'google/gemma-4-31B-it' \\\n  -c model_provider='gateway' \\\n  -c model_providers.gateway.name='Pydantic AI Gateway' \\\n  -c model_providers.gateway.base_url='https://gateway.pydantic.dev/proxy/doubleword/v1' \\\n  -c model_providers.gateway.env_key='PYDANTIC_AI_GATEWAY_API_KEY'","soon":false},{"file":"ai_sdk.ts","lang":"ts","code":"// npm install ai @ai-sdk/openai-compatible\nimport { createOpenAICompatible } from '@ai-sdk/openai-compatible'\nimport { generateText } from 'ai'\n\nprocess.env.PYDANTIC_AI_GATEWAY_API_KEY = '...'\n\nconst doubleword = createOpenAICompatible({\n  baseURL: 'https://gateway.pydantic.dev/proxy/doubleword',\n  apiKey: process.env.PYDANTIC_AI_GATEWAY_API_KEY,\n})\n\nconst { text } = await generateText({\n  model: doubleword('google/gemma-4-31B-it'),\n  system: 'Be concise, reply with one sentence.',\n  prompt: 'Where does \"hello world\" come from?',\n})\nconsole.log(text)","soon":false}],"benchmarks":[{"id":"index","name":"Intelligence index","unit":"","desc":"Our composite of the benchmarks below, 0-100","category":"reference","floor":0,"ceiling":100,"url":"/methodology/","credit":"Pydantic, from the sources credited below"},{"id":"gpqa","name":"GPQA Diamond","unit":"%","desc":"Graduate-level science questions, multiple choice","category":"reasoning","floor":25,"ceiling":97,"url":"https://epoch.ai/benchmarks/gpqa-diamond","credit":"Epoch AI (CC BY 4.0)"},{"id":"aime","name":"OTIS Mock AIME","unit":"%","desc":"Competition mathematics problems with exact answers","category":"reasoning","floor":0,"ceiling":100,"url":"https://epoch.ai/benchmarks/otis-mock-aime-2024-2025","credit":"Epoch AI (CC BY 4.0)"},{"id":"simpleqa","name":"SimpleQA Verified","unit":"%","desc":"Short factual questions answered from memory, without search","category":"reasoning","floor":0,"ceiling":100,"url":"https://epoch.ai/benchmarks/simpleqa-verified","credit":"Epoch AI (CC BY 4.0)"},{"id":"scicode","name":"SciCode","unit":"%","desc":"Scientific programming problems written by researchers","category":"coding","floor":0,"ceiling":100,"url":"https://scicode-bench.github.io/","credit":"SciCode, via Epoch AI (CC BY 4.0)"},{"id":"webdev","name":"WebDev Arena","unit":"","desc":"Rating from human votes on web apps the models built","category":"coding","floor":1000,"ceiling":1900,"url":"https://web.lmarena.ai/leaderboard","credit":"LMArena, via Epoch AI (CC BY 4.0)"},{"id":"lmarena","name":"LMArena text","unit":"","desc":"Rating from blind human votes between pairs of chat responses","category":"preference","floor":1100,"ceiling":1600,"url":"https://lmarena.ai/leaderboard/text","credit":"LMArena (CC BY 4.0)"},{"id":"eci","name":"Epoch Capabilities Index","unit":"","desc":"Epoch AI's own composite across about 40 benchmarks; shown for comparison, not part of our index","category":"reference","floor":80,"ceiling":180,"url":"https://epoch.ai/benchmarks/eci","credit":"Epoch AI (CC BY 4.0)"}],"generated":"2026-11-25","gaps":{"speed":3,"index":80,"description":0}}