api.models

settings

api.models.create({ settings })

How a session behaves: what it is told to be, how freely it answers, how much it may write, and which server-side tools it may reach.

set at creationapplies to every callno credit by itself
Using Python?

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

Settings belong to the session, not to a call: they are recorded once and applied to everything that session generates. To change them, open another session.

The fields

instructionsstring

The system instruction. Who the model is, what it must and must not do, which language to answer in.

temperaturenumber

How freely it answers. 0 is applied, not treated as absent.

maxOutputTokensinteger

The output ceiling. It is imposed on the provider, not merely declared.

thinkingLevelstring

minimal · low · medium · high, on models that think.

toolsstring[]

Server-side tools this session may use: "search", "fetch". See below.

negativePromptstring

On image and video models: what to keep out of the result.

seedinteger

On models that accept one, for repeatable output.

instructions

This is the setting that does most of the work. It is sent apart from your message, so it is not something the conversation can talk the model out of as easily as a line buried in a prompt.

const support = await api.models.create({
  model: "gemini-3.5-flash",
  settings: {
    instructions: [
      "You answer customer questions about our billing.",
      "Answer in the language of the question.",
      "When you do not know, say so and offer to escalate. Never invent a policy.",
      "Never ask for a card number, and never repeat one back.",
    ].join("\n"),
    temperature: 0.2,
  },
});
support = api.models.create(
    model="gemini-3.5-flash",
    settings={
        "instructions": "\n".join([
            "You answer customer questions about our billing.",
            "Answer in the language of the question.",
            "When you do not know, say so and offer to escalate. Never invent a policy.",
            "Never ask for a card number, and never repeat one back.",
        ]),
        "temperature": 0.2,
    },
)
Write the refusals, not just the role

« You are a helpful assistant » decides nothing. What changes behaviour is the specific things it must not do, and what to do instead when it cannot answer.

temperature

ValueUse it for
0Extraction, classification, anything you compare against an expected answer.
0.2 – 0.4Support answers, summaries — correct, with natural phrasing.
0.7 and upDrafting, naming, variations you want to differ from each other.

0 is a real value here: it is passed through rather than read as « unset ». That matters because temperature: 0 is exactly what you want for anything you test.

maxOutputTokens

The ceiling is imposed on the provider, which is what makes it a bound rather than a hope: the model cannot answer past it. Two consequences worth knowing.

  • It caps what you can be billed for the output of a call — the worst case is the ceiling, not the model's maximum.
  • Thinking counts inside it. On a model that thinks, a tight ceiling can be spent reasoning, leaving almost nothing for the answer.
// A classifier that must answer in one word, cheaply and bounded
await api.models.create({
  model: "gemini-3.5-flash",
  settings: { instructions: "Answer with exactly one of: billing, technical, other.",
              temperature: 0, maxOutputTokens: 8 },
});
# A classifier that must answer in one word, cheaply and bounded
api.models.create(
    model="gemini-3.5-flash",
    settings={"instructions": "Answer with exactly one of: billing, technical, other.",
              "temperature": 0, "maxOutputTokens": 8},
)

Each model's own maximum is in the catalogue, as maxOutput. Asking for more than that is lowered to it.

tools — search and fetch

Listing a server-side tool lets the session reach the web while answering: "search" looks things up, "fetch" opens a page. The context is gathered on the server and supplied with your question.

const researcher = await api.models.create({
  model: "gemini-3.5-flash",
  settings: {
    tools: ["search", "fetch"],
    instructions: "Cite the source of every fact you state. Say when you could not verify something.",
  },
});
researcher = api.models.create(
    model="gemini-3.5-flash",
    settings={
        "tools": ["search", "fetch"],
        "instructions": "Cite the source of every fact you state. Say when you could not verify something.",
    },
)
Reaching the web costs credits, and it is not free of judgement

Each lookup is billed on top of the answer. And a page is not a fact: ask for sources in the instructions, so what comes back can be checked rather than believed.

These two are all a session gets. Reading files, running commands, writing to a storage — that is the agent engine, where every such step is a tool you permit or refuse. See Permissions.

On media models

Image and video models read negativePrompt and seed. What decides the price of a clip — its definition, its length, whether it has sound — travels with the request rather than sitting in settings, because those are what you are buying.