EN ▾
Get API key

Gemma 4 API Rate Limit: Real Numbers and 429 Fixes

Every hosted API caps how fast you can call it, and this one is no different. Here are the exact limits for the gemma 4 api rate limit question on this service, how to read 429 errors, and code that stays inside the caps.

Updated

Isometric lanes with light packets and a gate, illustrating API concurrency and rate limiting

The limits in one table

This service is a hosted, OpenAI-compatible endpoint for one open-weight model run by an independent provider. It is not Google's Gemma API, so Google's quotas do not apply here. These are the numbers that do.

LimitFull keyTrial key
Concurrent requests82
Requests per minute30060
Max request body8 MB8 MB
Context window100,000 tokens100,000 tokens

The context window counts the prompt and the completion together. The max_tokens parameter is optional, and a completion can use whatever the prompt leaves free. A trial key comes from the $0.50 one-click credit on the API key page; a full key is what you have once you have topped up.

Two kinds of limit, and why concurrency bites first

Requests per minute is a rate. Concurrency is a count of calls in flight at the same moment. They fail in different ways, so it helps to know which one you hit.

Suppose a typical reply takes 10 seconds to finish (your number will differ). Each of 8 slots can complete 6 calls a minute, so 8 slots give 8 x 6 = 48 completed calls per minute. That is far below 300. For long replies, concurrency is the cap that matters, not the per-minute rate. With short replies of 1 second, the same 8 slots could in theory finish 480 a minute, and then the 300 per minute limit applies.

For a trial key the same math gives 2 slots x 6 = 12 calls per minute at 10 seconds each. Trial users rarely reach 60 per minute unless replies are very short.

Streaming deserves a separate note. A streamed request occupies its concurrency slot until the stream ends, not until the first token arrives. If your user closes a tab and your server keeps reading the stream, the slot stays taken. Abort the upstream request when the client disconnects.

What a 429 looks like and what to do

Going over a limit returns HTTP 429 with a JSON error. The error code tells you the cause.

  • rate_limited: you sent too many requests in the current minute. Wait, then continue. Spread calls out with a small delay.
  • concurrency: too many requests are running at once. Queue calls so no more than 8 (or 2 on a trial key) are in flight.
  • A 429 with a Retry-After: 5 header: the service is briefly overloaded. Wait the 5 seconds and retry.

Responses include X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency, so your code can read the limits for the key it is using instead of hard-coding them. They also include X-Request-Id, which you should log and quote if you contact support, and X-Balance-USD, which shows your remaining credit.

Client code that stays inside the caps

The simplest control is a semaphore sized to your concurrency limit, plus a retry with backoff on 429.

import asyncio
from openai import AsyncOpenAI, RateLimitError

client = AsyncOpenAI(
    base_url="https://api.gemmaabliterated.com/v1",
    api_key="YOUR_KEY",
    max_retries=0,
)
slots = asyncio.Semaphore(8)  # use 2 on a trial key

async def ask(prompt: str) -> str:
    async with slots:
        for attempt in range(5):
            try:
                r = await client.chat.completions.create(
                    model="uncensored",
                    messages=[{"role": "user", "content": prompt}],
                )
                return r.choices[0].message.content
            except RateLimitError:
                await asyncio.sleep(5 * (attempt + 1))
    raise RuntimeError("still rate limited after 5 tries")

async def main():
    prompts = [f"Write a one-line tagline #{i}" for i in range(40)]
    results = await asyncio.gather(*(ask(p) for p in prompts))
    print(len(results), "done")

asyncio.run(main())

Setting max_retries=0 stops the SDK from retrying on its own, so your loop controls the timing. Sleeping inside the semaphore, as written, holds the slot during the wait, which keeps the load gentle. If you prefer to release the slot while waiting, move the sleep outside the async with block.

The same idea works in curl for a quick check of headers:

curl -i https://api.gemmaabliterated.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "uncensored", "messages": [{"role": "user", "content": "ping"}], "max_tokens": 5}'

Working with the 100,000-token context window

The window is the other limit you will meet. A call fails or truncates when prompt plus completion would exceed 100,000 tokens, so measure long inputs before sending. A rough rule for English is about four characters per token, which means 100,000 tokens is around 400,000 characters. Treat that as an estimate and leave a margin.

Token count also sets cost. A prompt of 80,000 tokens with a 2,000-token reply costs 80,000 x $0.15 / 1M = $0.012 for input, plus 2,000 x $0.50 / 1M = $0.001 for output, so $0.013 in total. At 8 concurrent calls of that size, running continuously for an hour with each call taking about 20 seconds would be 8 x 3 x 60 = 1,440 calls, or about $18.72. Your timings will differ; the point is that the large window makes spend, not rate, the thing to watch. Failed or refused requests are not charged.

If you hit the window often, trim old chat turns, summarize earlier material, or split the job. The docs show how the request fields map to what you already use with other OpenAI-style APIs.

A pre-launch checklist for rate limits

Before you ship a feature that calls the API from many users at once, walk through this list.

  1. Put a queue between your users and the API, sized to 8 in-flight calls (or 2 on a trial key).
  2. Show a waiting state in the interface instead of retrying silently ten times.
  3. Cap max_tokens for features that need short answers, so slots free up quickly.
  4. Log X-Request-Id on every response, and the error code on every 429.
  5. Watch X-Balance-USD and alert yourself before the balance reaches zero.
  6. Test with a burst of 20 parallel calls on staging to see your retry path in action.

Most rate-limit pain comes from loops that retry instantly. A 429 that is answered with another request one millisecond later only makes the next 429 more likely. A fixed pause of a few seconds, or a pause that grows each attempt, solves almost every case. Where you can, spread scheduled jobs across the minute instead of firing them all on the hour.

When the default limits are not enough

The limits above apply per key. If your workload is steady and needs more than 8 parallel calls, the practical choices are to batch work so each call does more, to cut reply length with max_tokens so slots free up faster, or to ask support what is possible. We do not publish a higher tier, so do not plan around one.

Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, prepaid, with no subscription. Top-ups run from $20 to $500, with +5% from $50, +10% from $100 and +15% from $200. See pricing for details. The service is text only, and the model answers without content refusals for lawful adult use, with a hard stop on sexual content involving minors.

Questions and answers

Are these Google's Gemma API limits?

No. This is an independent OpenAI-compatible service, and the limits above are its own. Check Google's documentation for their quotas.

What does a 429 with Retry-After: 5 mean?

The service is temporarily overloaded. Wait 5 seconds and send the request again.

Do rate-limited requests cost money?

No. Failed or refused requests are not charged.

How do I raise the concurrency limit?

A full key allows 8 concurrent requests, a trial key 2. Topping up gets you the full key; beyond that, contact support to discuss your workload.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key