Refract

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 IDgemma-4-31b
ProviderGoogle
Input, per 1M tokens$0.13
Output, per 1M tokens$0.40
Context window256,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

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

All 56 models