Gemma 3 Context Window vs a 100K Token API
The window here is 100,000 tokens, shared by your prompt and the reply. This page shows how to measure it, budget it and keep long chats from running into the limit.
Updated

No card needed. After sign-up, claim $0.50 of free test credit with one click (once per person).
Key points
- The window is 100,000 tokens for prompt plus completion together
- Every chat turn resends the history, so input grows with conversation length
- A full 100k prompt costs $0.015 in input; a 100-turn chat in the example costs about $0.55
- Pin the character profile, summarize old turns, and trim by token count
The number you need
When people look up the Gemma 3 context window, they usually want to know how much text they can put into one request. For the Gemma models themselves, the window depends on the model size, so read the model card of the checkpoint you care about. For this API the answer is fixed: 100,000 tokens, counted across the prompt and the completion together.
That budget covers everything the model sees and writes in one call: the system prompt, the character profile, the whole message history, any document you paste in, and the reply. If your prompt uses 80,000 tokens, the completion can use up to the remaining 20,000. The max_tokens parameter is optional; when you leave it out, the completion may use the rest of the window.
The service is an independent hosted model with an OpenAI-compatible endpoint, not an official vendor API, so its window is its own and should not be assumed equal to any particular Gemma release. If you are comparing the two approaches in more depth, the page on API versus chat alternatives covers the trade-offs.
What a token is, roughly
A token is a chunk of text, often a short word or part of a longer one. For ordinary English prose, a common rule of thumb is that 1,000 tokens equal about 750 words, or about 4 characters per token. Code, non-English text and unusual names use more tokens per word. Treat these numbers as estimates and measure with real data.
| Content | Approximate size |
|---|---|
| Short system prompt | 200 to 500 tokens |
| Detailed character profile | 800 to 2,000 tokens |
| One chat turn (user plus reply) | 500 to 1,000 tokens |
| A 10,000-word document | about 13,000 tokens |
| Full window | 100,000 tokens, roughly 75,000 words |
The reliable measurement is the usage block in each response. It reports prompt and completion tokens exactly, and with streaming it arrives at the end. Log it from your first test onward.
Why chats fill the window faster than you expect
The API is stateless. It does not remember earlier requests, so your app sends the full conversation every turn. That has two consequences: the prompt grows with every turn, and the input bill grows with it.
Work through an example. A system prompt and character profile take 1,000 tokens. Each turn adds a 300-token user message and a 400-token reply, so 700 tokens. At turn 100 the prompt holds 1,000 + 99 x 700 = 70,300 tokens, and the reply adds 400 more. The window would run out near turn 140, where the prompt reaches about 99,000 tokens.
Now the cost. The prompts across 100 turns add up to 100 x 1,000 + 700 x (0 + 1 + ... + 99) = 100,000 + 700 x 4,950 = 3,565,000 input tokens. That costs 3,565,000 x $0.15 / 1,000,000 = $0.53475. The 100 replies total 40,000 output tokens, which cost 40,000 x $0.50 / 1,000,000 = $0.02. The whole session is about $0.55. A single turn at the 70,300-token mark costs $0.010545 for input plus $0.0002 for output, so roughly one cent.
So a long session is affordable, but the last turns cost about 70 times what the first ones do. Trimming history is a cost lever as well as a limit guard.
Trimming history in code
Do the trimming yourself. Do not rely on the server to cut old messages for you. A simple approach keeps the system message, then walks backward from the newest turn and stops when a budget is reached.
from openai import OpenAI
client = OpenAI(base_url="https://api.gemmansfw.cc/v1", api_key="YOUR_KEY")
def est_tokens(text):
return len(text) // 4 + 4 # rough estimate
def fit(messages, budget=80000):
system, rest = messages[0], messages[1:]
kept, total = [], est_tokens(system["content"])
for m in reversed(rest):
t = est_tokens(m["content"])
if total + t > budget:
break
kept.append(m)
total += t
return [system] + list(reversed(kept))
history = [{"role": "system", "content": "You are the narrator of a slow-burn fantasy story."}]
history.append({"role": "user", "content": "Describe the old lighthouse at dusk."})
resp = client.chat.completions.create(
model="uncensored",
messages=fit(history),
max_tokens=1200,
)
print(resp.usage.prompt_tokens, resp.usage.completion_tokens)
A budget of 80,000 leaves 20,000 tokens for the reply and for estimation error. Pick a lower number if you want cheaper turns. Compare your estimate with usage.prompt_tokens now and then and adjust the divisor if it drifts.
Long roleplay and fiction
For stories and character chats, raw trimming drops the oldest turns, which is exactly where the setting and relationships were established. A few habits keep the plot intact.
- Pin the profile. Keep the system prompt and character description at the top of every request, outside the trimming logic.
- Summarize, then drop. When history passes a threshold such as 40,000 tokens, ask the model for a 500-token summary of the oldest half, store it, and replace those turns with the summary.
- Keep a facts list. Names, places, promises and unresolved plot threads fit in a few hundred tokens and prevent contradictions.
- Repeat the style rule near the end. A one-line reminder in the final user message holds tone better than a rule buried 60,000 tokens back.
These stories are for adults, and the rule on minors has no exceptions: no sexual content involving minors in any request. Fiction, companion and roleplay apps for adults are the intended use, within the law. The documentation lists the parameters you can tune for style, including temperature, top_p, stop and the penalties.
Document analysis with one big prompt
The window also suits reading tasks. A 60,000-word report is about 80,000 tokens, which fits with room for a short answer. Sending it in one request lets the model relate a detail on page 5 to a table on page 90, which chunked pipelines often miss.
Price it before you run it. A prompt of 100,000 tokens costs 100,000 x $0.15 / 1,000,000 = $0.015 in input. Ten such calls cost $0.15. If each returns 1,000 tokens, add 10 x 1,000 x $0.50 / 1,000,000 = $0.005, for $0.155 total. If you ask many questions about the same document, remember that each question resends it, so batch your questions into one prompt when you can.
Put the instructions after the document as well as before it, ask for quotes or section references so you can verify answers, and set max_tokens to the length you actually want. Streaming is worth enabling for long outputs. Note that a streamed request occupies its concurrency slot until the stream ends, and a full key allows 8 at once.
Paying for long contexts
This site accepts crypto only: USDT on TRC20 or USDC on Base. Top-ups are any whole amount from $20 to $500, with +5% from $50, +10% from $100 and +15% from $200. A $100 top-up becomes $110 of credit. At the 100-turn session cost of about $0.55 above, that is around 200 sessions. Credit is prepaid, never expires, and failed or refused requests are not charged.
New users can claim $0.50 of trial credit with one click on the API key page, valid for 7 days and needs no up-front payment. Enough for one full-window call and a handful of chat sessions. The pricing page has the current terms.
More guides
Questions and answers
What is the context window of this API?
100,000 tokens, counted across the prompt and the completion together. max_tokens is optional.
Is it the same as the Gemma 3 context window?
Not necessarily. This is an independent hosted model with its own window, so check the model card of any Gemma release you want to compare against.
Does the API remember earlier chats?
No. It is stateless, so your app must send the conversation history with every request.
How much does a full 100k prompt cost?
The input alone costs $0.015 at $0.15 per 1M tokens. Output is billed separately at $0.50 per 1M.
What happens if my prompt is too long?
Do not rely on the server to trim it. Keep prompt plus expected completion under 100,000 tokens and trim old turns in your own code.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.