Refract › Models › Gemma 4 31B
Gemma 4 31B API
Use Gemma 4 31B by Google through Refract's OpenAI-compatible API for $0.13 per 1M input and $0.40 per 1M output tokens. Pay per token, no subscription.
| Model ID | gemma-4-31b |
|---|---|
| Provider | |
| Input, per 1M tokens | $0.13 |
| Output, per 1M tokens | $0.40 |
| Context window | 256,000 tokens |
Google’s 31B Gemma 4 model for text generation and image understanding.
About this model
Gemma 4 31B is Google's Gemma 31B model on Refract, and 4 of the 6 Google models here cost more and 1 costs less. It reads up to 256K tokens of context and writes up to 128K tokens per reply.
How it compares
- Gemma 4 26B A4B: Gemma 4 26B A4B costs 17% less; context 256K vs 262K; max reply 128K vs 131K; cached input $0.13 vs $0.11.
- Gemini 4 Neon: Gemini 4 Neon costs 238% more; context 256K vs 1M; max reply 128K vs 66K; cached input $0.13 vs $0.080.
- Gemini 4 Argon: Gemini 4 Argon costs 575% more; context 256K vs 1M; max reply 128K vs 66K; cached input $0.13 vs $0.030.
What a request costs
A typical chat message (2,000 tokens in, 400 out) costs about $0.0004. A coding-agent step (60,000 tokens in, 54,000 of them from cache, 800 out) costs about $0.0083.
Chat with Gemma 4 31B · Get an API key
Use it from code
curl https://refracthub.com/v1/chat/completions \
-H "Authorization: Bearer $REFRACT_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gemma-4-31b", "messages": [{"role": "user", "content": "Hello"}]}'from openai import OpenAI
client = OpenAI(base_url="https://refracthub.com/v1", api_key="YOUR_REFRACT_KEY")
reply = client.chat.completions.create(model="gemma-4-31b", messages=[{"role": "user", "content": "Hello"}])
print(reply.choices[0].message.content)
Questions
How much does Gemma 4 31B cost on Refract?
$0.13 per 1M input tokens and $0.40 per 1M output tokens. You pay only for the tokens you use, with no subscription.
Gemma 4 31B or Gemma 4 26B A4B: which should I use?
Gemma 4 26B A4B is cheaper. Both work with the same key and the same API, so you can try one and switch by changing the model name from "gemma-4-31b" to "gemma-4-26b".
Does it work with the OpenAI SDK?
Yes. Point the OpenAI SDK, or any OpenAI-compatible app, at https://refracthub.com/v1 with your Refract key and use the model name "gemma-4-31b". The Anthropic Messages format works too.
Can I use Gemma 4 31B without writing code?
Yes. Chat with it on the web at https://refracthub.com/chat, or use the Refract desktop app for Windows.
Other Google models
- Gemini 4 Argon: $0.60 / $3.00 per 1M tokens
- Gemini 4 Carbon: $0.91 / $4.55 per 1M tokens
- Gemini 4 Hydrogen: $0.68 / $3.41 per 1M tokens
- Gemini 4 Neon: $0.90 / $0.90 per 1M tokens
- Gemma 4 26B A4B: $0.11 / $0.33 per 1M tokens