Gemma 4 API: How to Call It and an Alternative
If you searched for a gemma 4 api, you probably want one HTTP endpoint you can call from code. This guide covers the usual routes to Gemma, the request format, and an independent alternative for text that needs no content refusals.

Key points
- Gemma is a family of open-weight models, so you can self-host it or use a hosted provider; check each provider's current model list.
- Most hosted endpoints speak the OpenAI chat format, so one client works across them after you change the base URL and key.
- This site is not Gemma and not Google. It hosts one independent open-weight model tuned to answer without content refusals for lawful adult use.
- Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, pay as you go.
What a Gemma API call actually is
Gemma is a family of open-weight language models published by Google. Open weights mean the files can be downloaded and run on your own hardware, and it also means that many companies can host them and sell access. So "the Gemma API" is not one thing. It can be Google's own hosted offering, a third-party inference host, or a server you run yourself.
Whichever route you pick, the call itself is almost always the same shape: an HTTPS POST with a list of chat messages, a model name, and a few sampling settings, and a JSON reply with the generated text. Many providers copied the OpenAI chat completions format because so much client code already speaks it. That is the useful fact for you. If your code works against one OpenAI-style endpoint, moving to another is a matter of changing three values: base URL, key and model name.
Which Gemma versions exist, what they are called, and which host carries them changes over time, and I do not want to guess here. Open the provider's model page and confirm the exact model ID before you write any code.
Three ways to reach Gemma
Here is how the options compare on the points that matter when you are choosing. The table lists only things that are true by construction, not prices or speeds.
| Route | You manage | Good when |
|---|---|---|
| Google's hosted offering | An account, a key, quotas | You want the vendor's own endpoint and its terms of use |
| Third-party inference host | An account and a key | You want a pay-per-token endpoint without running hardware |
| Self-hosting | GPUs, drivers, a server such as vLLM or llama.cpp, updates | You need full control or have a fixed local workload |
Self-hosting gives the most control and the most chores. A model that fits your GPU memory is a good start, but you still have to handle batching, restarts and context limits yourself. A hosted endpoint takes those chores away and charges for tokens instead.
One more point about content rules. A model released by a large company usually ships with safety tuning, and the host may add its own filtering on top. That is reasonable for many products. If you build adult fiction or roleplay tools and your lawful use keeps hitting refusals, you need a model that was tuned differently. That is where the alternative below comes in.
The request format, with working code
The shape below is the OpenAI chat completions format. It is the same one the endpoint on this site accepts. For the Gemma host of your choice, swap the base URL, key and model name for the ones in that provider's docs.
curl
curl https://api.gemmansfw.top/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [
{"role": "system", "content": "You are a concise technical assistant."},
{"role": "user", "content": "Explain what a context window is in two sentences."}
],
"temperature": 0.7
}'
Python with the openai SDK
from openai import OpenAI
client = OpenAI(
base_url="https://api.gemmansfw.top/v1",
api_key="YOUR_KEY",
)
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "You are a concise technical assistant."},
{"role": "user", "content": "Explain what a context window is in two sentences."},
],
temperature=0.7,
)
print(resp.choices[0].message.content)
print(resp.usage)
Node
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.gemmansfw.top/v1",
apiKey: process.env.API_KEY,
});
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "List three uses of JSON mode." }],
});
console.log(resp.choices[0].message.content);
Two details trip people up. The key goes in an Authorization: Bearer header, not in the URL. And the base URL already ends in /v1, so the SDK appends /chat/completions itself. If you add the path twice you get a 404.
An independent alternative for unfiltered text
This site does not sell Gemma. It is not an official API of Google, Meta, Mistral, Qwen, DeepSeek, OpenAI or any other vendor, and it is not a router that forwards requests to those vendors. It hosts one open-weight model, run by an independent provider, that was tuned to answer without content refusals for lawful adult use. In requests you name it with the model ID uncensored.
That makes it a fit for a narrow set of jobs: fiction and roleplay tools for adults, companion apps, writing assistants that should not break character, and any text pipeline where refusals are the main failure you see. It is text only. There is no image, audio or video generation, no embeddings and no fine-tuning. One rule has no exceptions: no sexual content involving minors.
If you need a specific Gemma version for a benchmark, a research comparison or a licence reason, use a Gemma host instead. This endpoint will not give you that model. If you need a model that does not refuse lawful adult requests, and you already have OpenAI-style client code, it takes about five minutes to try. The page on API docs and request reference lists every supported parameter.
Features your existing client code keeps working with
The endpoint supports POST /v1/chat/completions and GET /v1/models. Beyond plain chat, these parts of the OpenAI format are implemented:
- Streaming over server-sent events with
stream: true, with token usage reported at the end. - Tool calling with
toolsandtool_choice, streamedtool_calls, and results sent back asrole: "tool"messages. - JSON mode with
response_format: {"type": "json_object"}. - Sampling controls: temperature, top_p, stop, seed and the repetition penalties are passed through.
Here is a streaming call in Python. Print tokens as they arrive and read usage from the last chunk if your SDK exposes it:
from openai import OpenAI
client = OpenAI(base_url="https://api.gemmansfw.top/v1", api_key="YOUR_KEY")
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Write a four-line scene opener set on a night train."}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if getattr(chunk, "usage", None):
print("\n", chunk.usage)
The context window is 100,000 tokens, counting the prompt and the completion together. max_tokens is optional, so a reply can use whatever room is left. Bodies up to 8 MB are accepted.
Rate limits and how to handle them
A full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 concurrent and 60 per minute. Every response carries X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency, which are handy to log.
When you go over, the API answers with HTTP 429. The error code tells you which limit you hit: rate_limited means too many requests per minute, concurrency means too many at once. A short temporary overload also returns 429, with a Retry-After: 5 header. A streamed request holds its concurrency slot until the stream ends, so a stalled consumer can starve your own other calls.
import time
from openai import OpenAI, RateLimitError
client = OpenAI(base_url="https://api.gemmansfw.top/v1", api_key="YOUR_KEY")
def ask(prompt, tries=4):
for attempt in range(tries):
try:
r = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": prompt}],
)
return r.choices[0].message.content
except RateLimitError as e:
wait = 5 * (attempt + 1)
time.sleep(wait)
raise RuntimeError("still rate limited")
Failed or refused requests are not charged, so retrying costs nothing extra when a call fails.
What it costs and how to start
Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens. There is no subscription. You top up prepaid credit and pay for tokens as you use them, and the credit never expires. A typical request with 2,000 input tokens and 500 output tokens costs $0.00055, so a dollar covers roughly 1,800 of them. The full table is on the token pricing page.
New users can claim $0.50 of trial credit with one click on the key page after sign-up. It is one per person, valid for 7 days, and needs no payment details. Sign-up is with Google or with email and password. Go to get an API key, claim the trial, and run the curl command above. If you want the broader background on how Gemma relates to this site, the article Gemma 4 API, how it works and alternatives covers it.
Top-ups are any whole amount from $20 to $500, paid in crypto (USDT on TRC20 or USDC on Base). Larger top-ups add a bonus: 5% from $50, 10% from $100 and 15% from $200. Prompts are not used for training.
More guides
Questions and answers
Is this the official Gemma API?
No. It is an independent hosted service that runs one open-weight model tuned to answer without content refusals for lawful adult use. It is not an API of Google or any other vendor.
Can I use the OpenAI SDK with it?
Yes. Set the base URL to https://api.gemmansfw.top/v1, use your key as the bearer token, and set the model to uncensored. Chat completions, streaming, tool calling and JSON mode work as in the OpenAI format.
How much context can I send?
The window is 100,000 tokens, shared by the prompt and the completion. Request bodies can be up to 8 MB.
Can I try it before paying?
Yes. After sign-up you can claim $0.50 of trial credit with one click on the API key page. It is one per person and valid for 7 days.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.