EN ▾
Get API key

Gemma 3 27B Context Window vs a 100k Hosted Option

Context window means the amount of text a model can read and write in one request. If you are comparing the gemma 3 27b context window with a hosted option, this page explains what the number means and how to budget a 100,000-token window.

Updated

Long paper scroll entering a glass window with a gauge, illustrating a 100k token context window

What a context window actually limits

A context window is the cap on tokens the model can handle in a single call. Your system prompt, the chat history, any pasted documents, tool results and the model's own reply all count against it. When the total goes over, the request fails or the oldest material has to be dropped.

The official number for Gemma 3 27B is set by Google and is documented on its model card, so look it up there rather than trusting a forum post. Local runtimes also let you choose a smaller window than the model supports, because every token you allow reserves memory. That is why the value you see in your own setup may be lower than the published maximum.

For this service the rule is simple: 100,000 tokens, prompt plus completion. It is a hosted, OpenAI-compatible endpoint for one open-weight model from an independent provider, not Google's own Gemma API. The size of the window here does not depend on any Gemma release.

Turning tokens into pages

Tokens are pieces of words. For English prose a common rough guide is that one token is about four characters, or three quarters of a word. Other languages and code usually need more tokens per word, so measure your own text.

TokensApprox. English wordsInput cost at $0.15 per 1M
8,0006,000$0.0012
32,00024,000$0.0048
100,00075,000$0.015

The word counts are estimates. A 100,000-token window is therefore enough for roughly a short novel's worth of text, but you still have to leave space for the answer, because output counts toward the same total.

Why long windows cost memory when you self-host

When you run a 27B model on your own machine, the weights are only part of the memory bill. The runtime also stores a key-value cache for every token in the context, and it grows with window size. Long contexts can need many gigabytes beyond the weights, which is why people running big models on one consumer GPU often set the window to 8,000 or 16,000 tokens.

That trade-off is the reason to use a hosted endpoint for long documents. The provider handles the cache and you send a request. You do not need to size a GPU for a 90,000-token prompt that you will send twice a week. If you do keep weights local, the Gemma 4 API and alternatives page explains how our endpoint differs from running a checkpoint yourself.

Using the 100k window for fiction and agents

Long-form writing

Put your story bible first: characters, tone rules, timeline, and the last two chapters. Then give the instruction at the end, such as "Write the next scene, 800 words, keep the narrator's voice." Models tend to follow late instructions better than early ones, so restate the key constraint in the final message. This is fiction work for adult authors, and the model answers without content refusals for lawful adult use. One rule is fixed: no sexual content involving minors.

Agents with tools

Tool calling is supported: send tools, receive tool_calls, and return results as messages with role: "tool". Agents fill a window fast because each tool result is appended. Cap each result to a few thousand tokens before you add it, and drop results that no later step needs.

A simple history trimmer

from openai import OpenAI

client = OpenAI(base_url="https://api.gemmaabliterated.com/v1", api_key="YOUR_KEY")

def rough_tokens(text: str) -> int:
    return len(text) // 4  # estimate only

def trim(messages, budget=90000):
    system, rest = messages[0], messages[1:]
    total = rough_tokens(system["content"]) + sum(rough_tokens(m["content"]) for m in rest)
    while rest and total > budget:
        total -= rough_tokens(rest.pop(0)["content"])
    return [system] + rest

history = [{"role": "system", "content": "You are a co-writer."}]
history.append({"role": "user", "content": "Continue chapter 12."})
resp = client.chat.completions.create(model="uncensored", messages=trim(history))
print(resp.usage)

The budget of 90,000 leaves about 10,000 tokens for the reply. The response's usage field gives the true counts, so adjust the estimate after a few calls.

What a long conversation costs

Chat APIs are stateless: each turn resends the history, and you pay for those input tokens again. Take a chat where turn n sends a prompt of n x 1,000 tokens and gets a 500-token reply, over 20 turns.

  • Input: 1,000 x (1 + 2 + ... + 20) = 1,000 x 210 = 210,000 tokens, which is 210,000 x $0.15 / 1M = $0.0315.
  • Output: 20 x 500 = 10,000 tokens, which is 10,000 x $0.50 / 1M = $0.005.
  • Total: $0.0365 for the whole 20-turn session.

Input grows with the square of the number of turns, so a 100-turn chat without trimming costs far more per turn than the first ones. Summarizing old turns into a short note keeps the curve flat. Prices on the pricing page are the same for every request size, and failed or refused requests are not charged.

Choosing a window size per task

A big window is a ceiling, not a target. Using less of it is usually faster and cheaper, and it often gives better answers because the model has less irrelevant text to wade through. A practical split looks like this.

  • Short chat, under 4,000 tokens. Send the whole history. Nothing to manage.
  • Roleplay or co-writing, 10,000 to 40,000 tokens. Keep the persona and the latest scenes verbatim, and compress older scenes into a summary of a few hundred words.
  • Document work, 40,000 to 90,000 tokens. Send the document once with the instruction at the end. Avoid chatting back and forth with the full text attached, because each turn pays for it again.
  • Agent loops. Keep a budget in code, and stop or summarize before you cross it.

Remember the output side. If you set no max_tokens, the completion may use all remaining space, which on a 20,000-token prompt means a possible 80,000 tokens of output at $0.50 per 1M. In practice replies end far sooner, but setting a cap keeps a runaway generation from costing more than you planned.

The window is not the only cap. A full key allows 8 concurrent requests and 300 per minute; a trial key allows 2 and 60. The body limit is 8 MB. A streamed request holds its concurrency slot until the stream ends. New users can claim $0.50 of trial credit with one click after sign-up, valid for 7 days with no card, from the API key page. Setup steps live in the quickstart.

Questions and answers

What is the official context window of Gemma 3 27B?

Google publishes it on the model card, so check there for the current number. This service has its own 100,000-token window and does not state the figure for any Gemma release.

Does the 100,000 tokens include the reply?

Yes. Prompt and completion together must fit in 100,000 tokens.

How many words is 100,000 tokens?

Roughly 75,000 English words, though the ratio changes with language and content.

Do I pay again for history on every turn?

Yes. The API is stateless, so each call bills the full prompt as input tokens. Trim or summarize old turns to control cost.

Your key is one form away

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

Get API key