Get an API key
api.agents

Options · model and thinking

model · fallbackModels · thinking · maxOutputTokens

Which model serves each turn, what happens when it will not, how hard it thinks, and how much it may write.

model requiredfallback per turn16 000 output tokens
Using Python?

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

modelstringrequired

The model name. Not required when reopening a session with id.

fallbackModelsstring[][]

Tried in order when a model gives up. A name equal to model is dropped.

thinkingstringnull

minimal · low · medium · high.

maxOutputTokensinteger16 000

Imposed on the provider, per turn. Thinking counts inside it.

api.agents.create({
  runtime: "local", machine: pc,
  model: "gemini-3.7-flash",
  fallbackModels: ["gemini-3.5-flash"],
  thinking: "medium",
  maxOutputTokens: 24_000,
});
api.agents.create(
    runtime="local", machine=pc,
    model="gemini-3.7-flash",
    fallback_models=["gemini-3.5-flash"],
    thinking="medium",
    max_output_tokens=24_000,
)

Fallback is per turn

Two attempts on a model, then the next one. The following step starts again from the main model — a run does not stay demoted because one turn failed. Watch the turn event's model to see which actually served.

The fallback's window matters

A smaller model may refuse a history the first one accepted

The context limit is resolved from the main model. Pick fallbacks of comparable size, or set contextTokens to a value all of them hold.

maxOutputTokens is imposed, not suggested

It is sent to the provider as a cap, which is what makes the pre-authorisation of a turn meaningful. Thinking tokens count inside it: a high thinking setting with a low cap leaves little room for the answer.

Thinking is billed

At the output rate, like anything the model writes. medium or high on a long agent run is a real line on the bill — worth setting deliberately rather than by default.

Changing it

The model is fixed for the life of the agent object. To work with another one, create another agent — or reopen the same session with a different model.