Get an API key
Context

Window per model

The engine reads the real window from the catalogue and never lets you ask for more than it. The default stays at 200 000 whatever the model allows.

read from the cataloguecached 10 minutescontext_too_large
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

How the limit is decided

  • The model's window is read from catalogue() at the start of a run, and kept for ten minutes.
  • Without contextTokens, the limit is the smaller of 200 000 and that window.
  • With contextTokens, that is the limit — unless it is larger than the window, which is refused.
// Default on a model with a 1 048 576-token window → limit 200 000
api.agents.create({ runtime: "local", machine: pc, model: "gemini-3.5-flash" });

// Asking for more than the model has
api.agents.create({ runtime: "local", machine: pc, model, contextTokens: 2_000_000 });
// IaGenifyError context_too_large: contextTokens (2,000,000) is larger than
// the context window of … (1,048,576 tokens).
from iagenify import IaGenifyError

# Default on a model with a 1 048 576-token window → limit 200 000
api.agents.create(runtime="local", machine=pc, model="gemini-3.5-flash")

# Asking for more than the model has: refused on the first run, once the window is read
agent = api.agents.create(runtime="local", machine=pc, model=model, context_tokens=2_000_000)
try:
    agent.run(message="…")
except IaGenifyError as error:
    print(error.code)   # "context_too_large"

What is accepted

contextTokensinteger200 000

A whole number of tokens, at least 10 000. Anything else is refused with invalid_context at creation.

The catalogue is read at run time, not at creation, so context_too_large surfaces on the first run() rather than when the object is built.

Why the default is lower than the window

A window is what fits, not what is wise

A turn carrying 800 000 tokens is slow and expensive on every step that follows, because the whole history is re-sent each time. 200 000 is a working ceiling that keeps a step quick; raising it is a decision you make for a specific job, not a default you inherit.

Reading it back

agent.context;
// { tokens: 31_204, limit: 200_000, window: 1_048_576, cachedTokens: 22_400,
//   cleared: 3, parts: { system: 2_100, tools: 3_900, memory: 180, messages: 25_024 } }
agent.context
# {"tokens": 31_204, "limit": 200_000, "window": 1_048_576, "cachedTokens": 0,
#  "cleared": 3, "parts": {"system": 2_100, "tools": 3_900, "memory": 0, "messages": 25_204}}
FieldIs
tokensThe size of the last turn, as the provider measured it.
limitThe limit in force — your contextTokens, or the default.
windowThe model's own window, or null if the catalogue could not be read.
cachedTokensHow much of the last turn the provider served from its cache.
clearedHow many tool results have been emptied so far.
partsThe breakdown: system, tools, memory, messages.

If the catalogue cannot be read

The run continues with the limit you asked for, or the default. window stays null and nothing is refused for being too large — a transient failure reading a price list is not a reason to stop working.

Mind it when you set fallbackModels

The limit is resolved from the main model. A fallback with a smaller window can refuse a history the main one accepted — so pick fallbacks of comparable size, or keep contextTokens at a value all of them hold.