Skip to content

Gemma-4-31B-IT

POST /v1/chat/completions model: Gemma-4-31B-IT

The weights served here are google/gemma-4-31B-it, the instruction-tuned 31B model of Google’s Gemma 4 family. It is a dense model that takes text and images, and it answers without thinking unless you turn thinking on. Licence: Apache-2.0.

Send Gemma-4-31B-IT as model. GET /v1/models lists this model with name set to Gemma 4 31B; that name is not accepted as a model ID.

From the pinned config.json. Layer and attention dimensions below refer to text_config:

ArchitectureGemma4ForConditionalGeneration, model_type = gemma4
Text backbonedense, model_type = gemma4_text; no Mixture of Experts
Layers60 — 50 sliding-window + 10 full-attention
Sliding window1,024 tokens
Hidden dimension5,376
Attention32 query heads. Sliding-window layers: 16 KV heads, head dimension 256. Full-attention layers: 4 KV heads, head dimension 512
Key/value projectionshared (attention_k_eq_v = true)
Intermediate dimension21,504
Vocabulary262,144
Native context262,144
Checkpoint precisionbfloat16

The separate vision_config describes the vision tower:

Model typegemma4_vision
Layers / hidden dimension / heads27 / 1,152 / 16
Patch size16
Visual tokens per image280 by default (vision_soft_tokens_per_image)

The 31B model has no audio encoder: audio_config is null.

generation_config.json sets temperature = 1.0, top_p = 0.95 and top_k = 64. This endpoint accepts temperature and top_p; top_k is dropped (see the catalog overview).

Context length262,144 tokens
Input modalitiestext, image
Streaming✅
Tool calling✅
JSON output✅ json_object
Thinking✅ — off by default, turn on per request
Inference engineSGLang
Stabilityexperimental

Use ordinary user and assistant turns. If you need a system message, send one, first in the array; the chat template reads a leading system message as the system prompt. Other arrangements, and the developer role, have not been verified for this model.

Thinking is off by default: the chat template sets enable_thinking to false unless the request says otherwise. To turn it on, send this top-level field:

{"chat_template_kwargs": {"enable_thinking": true}}

With the Python OpenAI SDK, pass it as extra_body={"chat_template_kwargs": {"enable_thinking": True}}. Token Factory forwards chat_template_kwargs to the inference engine unchanged. How this model treats reasoning_effort has not been verified; use enable_thinking.

Thinking textchoices[0].message.reasoning, or choices[0].delta.reasoning when streaming
Final answerchoices[0].message.content

Thinking draws on the same max_tokens budget as the answer. If content comes back empty with finish_reason: "length", raise max_tokens.

Send images as image_url content parts:

{
"role": "user",
"content": [
{ "type": "image_url", "image_url": { "url": "data:image/png;base64,<BASE64_PNG>" } },
{ "type": "text", "text": "What does this image say?" }
]
}

Each image counts against the context window. The vision tower encodes an image as 280 tokens by default.

Not supported. The model has no audio encoder, so send text and images only.

Context window262,144 tokens, prompt plus output
Inputtext, image
JSON outputresponse_format: {"type": "json_object"}
Thinking switchchat_template_kwargs.enable_thinking
Terminal window
curl https://developer.amd.com.cn/radeon/api/v1/chat/completions \
-H "Authorization: Bearer $RADEON_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Gemma-4-31B-IT",
"chat_template_kwargs": {"enable_thinking": true},
"max_tokens": 4096,
"messages": [
{ "role": "system", "content": "Answer in one sentence." },
{ "role": "user", "content": "Why is the sky blue?" }
]
}'

The answer is in content; the thinking is in reasoning.