Skip to content

Gemma 4 31B

Gemma 4 31B is Google's open-weight dense model from the Gemma 4 family (30.7 billion parameters), built for chat, coding, and tool-using assistant workflows that need a large context window. It is called through /v1/chat/completions with the canonical model id gemma/gemma-4-31b-it.

ModelContextInput / Output ($/1M)
gemma/gemma-4-31b-it262,1440.14 / 0.40
Terminal window
curl "$LLMTR_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer llmtr-your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma/gemma-4-31b-it",
"messages": [
{ "role": "user", "content": "Compare cursor-based and offset-based pagination for a REST API." }
],
"max_tokens": 1024
}'

The model can reason step by step before answering, but this is off by default. On a plain request, content carries the final answer directly with no separate reasoning trace.

Turn reasoning on by adding reasoning: true to the request, or use the :think suffix:

{ "model": "gemma/gemma-4-31b-it:think", "messages": [{ "role": "user", "content": "What is 17 times 24?" }], "max_tokens": 1024 }
// Or the reasoning field in the request body
{ "model": "gemma/gemma-4-31b-it", "reasoning": true, "messages": [{ "role": "user", "content": "What is 17 times 24?" }], "max_tokens": 1024 }

With reasoning on, the response carries a separate trace in message.reasoning_content; content still holds only the final answer. Reasoning tokens are counted in completion_tokens and billed as output, so keep max_tokens generous when reasoning is on.

The model accepts text and image together, and produces text only. Send the image as a base64 data URL:

Terminal window
curl "$LLMTR_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer llmtr-your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma/gemma-4-31b-it",
"messages": [{
"role": "user",
"content": [
{ "type": "text", "text": "What is in this image?" },
{ "type": "image_url", "image_url": { "url": "data:image/png;base64,<base64>" } }
]
}]
}'

Audio and video input are not supported.

Tool calling is native. tool_choice: "required" was measured live: forcing a tool call returns tool_calls arguments that are valid JSON. auto and a named function follow the same OpenAI-compatible contract but were not separately verified live for this model. See Tool Calling for details.

Terminal window
curl "$LLMTR_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer llmtr-your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma/gemma-4-31b-it",
"messages": [{ "role": "user", "content": "What is the weather in Istanbul?" }],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": { "city": { "type": "string" } },
"required": ["city"]
}
}
}],
"tool_choice": "required"
}'

response_format accepts both json_object and json_schema:

{
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "capital",
"schema": {
"type": "object",
"properties": {
"country": { "type": "string" },
"capital": { "type": "string" }
},
"required": ["country", "capital"]
}
}
}
}
  • Context window is 262,144 tokens (confirmed against official model cards and live measurement).
  • There is no separate output ceiling. No limit is applied to max_tokens beyond the context window; the gateway does not reject this with a 400.
  • There is no prompt caching. Repeated prompt prefixes are not billed at a discount.
  • Audio and video input are not supported.