api.models

设置设置设置设置

api.models.create({ settings })

会话的进行方式:它被告诉什么,它能回答什么,它能自由回答什么,它能写多少,它能达到什么服务器端的工具。

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.

设置属于会话, 而不是呼叫 : 它们被记录一次, 并应用到会话产生的每件事物上。 要更改它们, 请打开另一会话 。

字段 字段

instructionsstring

系统指令。模型是谁,它必须做什么,它必须做什么,它不能做什么,回答的语文是什么。

temperaturenumber

如何自由的回答。 0 适用,不被视为缺席。

maxOutputTokensinteger

产出上限,是规定给提供者,而不仅仅是宣布。

thinkingLevelstring

minimal · low · medium · high模型上思考。

toolsstring[]

服务器侧工具 : "search", "fetch"。见 下 数.

negativePromptstring

图像和视频模型:如何避免结果。

seedinteger

接受一个模型的模型, 用于重复输出 。

指令指令

这是大部分工作都用的设置。 它与您的信息分开发送, 所以对话不能像 快速埋设的线一样轻易地 将模型说成是一线。

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,
    },
)
写拒绝书 不只是角色

”你是一个有帮助的助理, ” 什么都不做决定。 改变行为是它不能做的具体事情, 当它不能回答的时候, 该怎么做。

温度温度

值用来
0提取,分类,任何你比较 与预期答案。
0.2-0.4支助、答复、摘要——正确,用自然的措辞。
上上 0. 7起草、命名、变化,你都想彼此不同

0 此处是一个真正的值: 它通过而不是被解读为 ` unset '。 这很重要, 因为 temperature: 0 这正是你所想要的 任何测试

最大输出数Tokens

上限是强加给提供者的,而这正是它成为约束性的而不是希望的原因:模式无法应对。 有两个后果值得了解。

  • 它可以限制你可以开帐单 电话产出最差的情况是上限,而不是模式的最大。
  • 思考在里面计数。 在一个认为,可以用严格的上限来推理的模式上,几乎没有留下任何答案。
// 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},
)

每个模型的极限都在 目录目录目录目录, , 以 maxOutput要求超过它所下调的。

工具——搜索和获取

列出服务器端工具让会话在回答时到达网页 : "search" 看着事情的上升, "fetch" 打开页面。上下文在服务器上收集,并随您的问题提供。

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.",
    },
)
达到网络成本信用,不能无判断可言

每个搜索都标在答案的顶部。页面不是事实:在指令中询问源,所以可以检查回来的东西,而不是相信。

这两个都是会话。 读取文件、 运行命令、 写到存储处—— 即代理引擎, 每一个步骤都是您允许或拒绝的工具 。 权限权限.

关于媒体模式

阅读的图像和视频模型 negativePrompt 和 seed剪报的价格——其定义、长度、是否音响——由什么决定,它随请求而行,而不是坐在环境里,因为这正是你买的东西。