YepAPI
GoogleText Generation/v1/ai/chat

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 typePrice
Input$0.30 / 1M tokens
Output$0.59 / 1M tokens
Context window262K tokens
What it costsPer jobPer 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.

POST/v1/ai/chat

Maximum tokens in the response.

Real-time tokens

Hit "Send Request" to see the response

Gemma 4 31B specs

ProviderGoogle
Model IDgoogle/gemma-4-31b-it
Endpoint/v1/ai/chat
TypeText Generation
Context window262K tokens
Max output131K tokens
ReasoningNo
OpenAI-compatibleYes — /v1/ai/chat/completions

How to get a Gemma 4 31B API key

  1. 1

    Create an account

    Sign up at yepapi.com with Google or email. It takes about 30 seconds.

  2. 2

    Create an API key

    Open the dashboard, go to API Keys and create a key. Copy it — it starts with yep_sk_.

  3. 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. 4

    Pay as you go

    Usage is billed per request from your balance. Top up any amount; there is no subscription.

Strengths

✓
Open-weight

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.

✓
Ultra low cost

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.

✓
131K output

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.

✓
262K context

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.

ModelProviderPriceContext
Gemma 4 31BGoogle$0.30 in / $0.59 out per 1M262K
Gemma 4 26BGoogle$0.13 in / $0.44 out per 1M262K
Gemini 2.5 Flash LiteGoogle$0.15 in / $0.59 out per 1M1.0M
Gemini 3.1 Flash LiteGoogle$0.37 in / $2.22 out per 1M1.0M
Gemini 2.5 FlashGoogle$0.44 in / $3.69 out per 1M1.0M
Gemini 3.5 Flash LiteGoogle$0.44 in / $3.69 out per 1M1.0M
Nemotron 3 SuperNVIDIA$0 in / $0 out per 1M262K
Qwen3.7 FlashQwen$0.04 in / $0.19 out per 1M1M

Why use Gemma 4 31B through YepAPI?

✓One API key for all models — no separate accounts
✓OpenAI SDK compatible — just change the base URL
✓No monthly minimums — pay per token
✓Switch models with one line of code
✓Full provider passthrough — citations, search results, and all extras included
✓Streaming and non-streaming support on every model
✓Works with Cursor, Claude, LangChain, and any LLM tool
✓Unified billing across all providers

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.

Start generating in 30 seconds

Pay per call, no subscriptions.

What developers say

“Switched from SerpAPI and cut our SERP costs by 80%. Same data quality, way simpler billing.”

Marcus T.

SEO Platform Founder

“One API key for AI models, SERP data, and web scraping. Saved us from managing 4 separate providers.”

Priya S.

Full-Stack Developer

“The $5 free credit let us prototype our entire rank tracking feature before committing. No other API does that.”

Jake R.

Indie Hacker

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.

Ready to use Gemma 4 31B?

Pay per call, no subscriptions.

Explore more models