Gemma 4 31B API
Access Gemma 4 31B through one API key. Google's open-weight model at ultra-low cost.
Google's open-weight 31B model. Strong performance at ultra-low cost with 131K output tokens.
Takes 30 seconds.
Gemma 4 31B API pricing
Pay per request from your YepAPI balance — no subscription, no monthly minimum. Prices updated October 23, 2026.
| Token type | Price |
|---|---|
| Input | $0.30 / 1M tokens |
| Output | $0.59 / 1M tokens |
| Context window | 262K tokens |
| What it costs | Per job | Per 1,000 |
|---|---|---|
| Chat reply1K input + 500 output tokens | $0.0006 | $0.595 |
| RAG answer8K input + 800 output tokens | $0.0029 | $2.87 |
| Agent step with tools30K input + 2K output tokens | $0.01 | $10.18 |
| Long document summary100K input + 2K output tokens | $0.031 | $31.18 |
4,900+
Developers
2.3M+
API calls served
184
Endpoints
$0.01
Per call
Yep, that's it.
Try it live
Send a message and see Gemma 4 31B respond in real time.
Maximum tokens in the response.
Real-time tokens
Gemma 4 31B specs
| Provider | |
|---|---|
| Model ID | google/gemma-4-31b-it |
| Endpoint | /v1/ai/chat |
| Type | Text Generation |
| Context window | 262K tokens |
| Max output | 131K tokens |
| Reasoning | No |
| OpenAI-compatible | Yes — /v1/ai/chat/completions |
How to get a Gemma 4 31B API key
- 1
Create an account
Sign up at yepapi.com with Google or email. It takes about 30 seconds.
- 2
Create an API key
Open the dashboard, go to API Keys and create a key. Copy it — it starts with yep_sk_.
- 3
Call Gemma 4 31B
Send a request to /v1/ai/chat with the x-api-key header and model "google/gemma-4-31b-it".
- 4
Pay as you go
Usage is billed per request from your balance. Top up any amount; there is no subscription.
Strengths
Gemma 4 31B ships as an open-weight model from Google, so you can inspect, fine-tune, and self-host the same 31B-parameter weights served here through one API key.
At $0.30 per 1M input tokens and $0.59 per 1M output tokens, it delivers strong instruction following at a fraction of the cost of frontier proprietary models.
Generates up to 131,072 output tokens in a single response, enough for long-form documents, full code files, or large structured JSON without truncation.
A 262,144-token context window lets you feed entire codebases, long transcripts, or multi-document prompts in one request.
Quick start
Copy this snippet and start making calls with Gemma 4 31B.
const res = await fetch('https://api.yepapi.com/v1/ai/chat', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"model": "google/gemma-4-31b-it",
"messages": [
{
"role": "user",
"content": "Explain API gateways in 2 sentences."
}
],
"maxTokens": 256
}),
});
const { data } = await res.json();
console.log(data.message.content);Gemma 4 31B vs similar models
Every model below runs on the same API key — switch by changing the model ID.
| Model | Provider | Price | Context |
|---|---|---|---|
| Gemma 4 31B | $0.30 in / $0.59 out per 1M | 262K | |
| Gemma 4 26B | $0.13 in / $0.44 out per 1M | 262K | |
| Gemini 2.5 Flash Lite | $0.15 in / $0.59 out per 1M | 1.0M | |
| Gemini 3.1 Flash Lite | $0.37 in / $2.22 out per 1M | 1.0M | |
| Gemini 2.5 Flash | $0.44 in / $3.69 out per 1M | 1.0M | |
| Gemini 3.5 Flash Lite | $0.44 in / $3.69 out per 1M | 1.0M | |
| Nemotron 3 Super | NVIDIA | $0 in / $0 out per 1M | 262K |
| Qwen3.7 Flash | Qwen | $0.04 in / $0.19 out per 1M | 1M |
Why use Gemma 4 31B through YepAPI?
Gemma 4 31B API: open-weight reasoning at ultra-low cost
Gemma 4 31B is Google's open-weight 31-billion-parameter instruction-tuned model, built for developers who want strong general reasoning and code generation without frontier pricing. With a 262K context window and 131K max output, it handles long documents and large generations in a single call.
Through YepAPI you call Gemma 4 31B with one API key on the standard chat endpoint, paying just $0.30 per 1M input and $0.59 per 1M output tokens — ideal for high-volume, cost-sensitive workloads.
What is Gemma 4 31B?
Gemma 4 31B is an open-weight, instruction-tuned large language model from Google, part of the Gemma family derived from the same research as Gemini. It has 31 billion parameters and is designed for text-to-text tasks: answering questions, writing and explaining code, summarizing, and following multi-step instructions. Because the weights are openly published, teams can audit, fine-tune, or self-host the model, while still accessing it as a hosted endpoint when they want zero infrastructure. With a 262K-token context window and 131K-token output ceiling, it suits long-context reasoning and long-form generation at a price far below proprietary frontier models.
Build with Gemma 4 31B via YepAPI
Send chat completion requests to Gemma 4 31B over a single YepAPI key — no separate Google Cloud project, billing setup, or quota negotiation. Point your existing client at the /v1/ai/chat endpoint, pass your system and user messages, and stream responses back. The same key works across every model in the catalog, so you can route cheap bulk work to Gemma 4 31B and escalate harder requests to larger models without re-authenticating. It is a drop-in fit for chatbots, code assistants, and batch document processing.
Gemma 4 31B API pricing — $0.30/1M input, $0.59/1M output
Gemma 4 31B costs $0.30 per 1M input tokens and $0.59 per 1M output tokens through YepAPI. That makes it one of the cheapest capable 30B-class models available, so summarizing thousands of documents or powering a high-traffic assistant stays affordable. You pay only for the tokens you use, with no minimums or seat fees, and the same billing covers every model on the platform.
Gemma 4 31B for high-volume code and content
Gemma 4 31B shines on large-scale, cost-sensitive jobs: bulk summarization, classification, data extraction, and code generation across long files. Its 131K output ceiling means it can return complete multi-file code or long reports without splitting requests, while the 262K context lets it reason over entire repositories or document sets. For teams processing huge volumes where per-token cost dominates, it is a strong default.
What developers say
“Switched from SerpAPI and cut our SERP costs by 80%. Same data quality, way simpler billing.”
“One API key for AI models, SERP data, and web scraping. Saved us from managing 4 separate providers.”
“The $5 free credit let us prototype our entire rank tracking feature before committing. No other API does that.”
Frequently asked questions
Google's open-weight 31B model. Strong performance at ultra-low cost with 131K output tokens.
Gemma 4 31B costs $0.30 per 1M input tokens and $0.59 per 1M output tokens through YepAPI, billed per request with no monthly fee. For example, a chat reply (1K input + 500 output tokens) costs about $0.0006.
Sign up at yepapi.com (Google or email, about 30 seconds), open the dashboard and create an API key. The same key works for Gemma 4 31B and every other model — no separate Google account or waitlist.
Use "google/gemma-4-31b-it" as the model on /v1/ai/chat. The short alias "gemma-4" also works.
Yes. Point the OpenAI SDK at https://api.yepapi.com/v1/ai with your YepAPI key and set model to "google/gemma-4-31b-it". Streaming works the same way, so existing OpenAI code only needs the base URL and key changed.
Gemma 4 31B supports a 262K token context window with up to 131K output tokens per request.
Explore more models
Gemini 3.5 Flash
GoogleAccess Gemini 3.5 Flash through one API key. Google's latest fast multimodal model.
Gemini 3 Flash
GoogleAccess Gemini 3 Flash through one API key. Google's next-generation fast model.
Gemini 3.1 Pro
GoogleAccess Gemini 3.1 Pro through one API key. Google's next-generation model.
Kimi K2.5
Moonshot AIAccess Kimi K2.5 through one API key. Moonshot AI's flagship model.
Command A+
CohereAccess Command A+ through one API key. Cohere Enterprise Agentic Flagship.
Qwen 3 Coder
QwenAccess Qwen 3 Coder through one API key. Coding-specialized model at an ultra-low price.
More Text Generation models
- Qwen3.8 Omni Flash API · Qwen
- GPT-5.4 Nano API · OpenAI
- GPT-5.5 Pro API · OpenAI
- Seed-2.0-Code API · ByteDance
- MiMo-V2.6-Pro-UltraSpeed API · Xiaomi
- GPT-6 Sol Pro API · OpenAI
- GPT-5.6 Terra API · OpenAI
- GPT-6 Astra Pro API · OpenAI
- GPT-5.6 Luna API · OpenAI
- Step 3.5 Flash API · StepFun
- Claude Sonnet 5.5 API · Anthropic
- Seed 1.6 Flash API · ByteDance