创建会话不花费任何成本,也不使用模式。 它记录了配置; 第一次 generate() 即是花费。
参数
modelstring必填由 目录目录目录目录失踪 SDK 任何请求之前都先抛出。
settingsobject其行为方式:指令、温度、输出上限、服务器端工具。 设置设置设置设置.
schemaobjectA A A JSON 设置相片, 并设置会话解答对象而不是流言。 见 化学.
memoryboolean默认默认为 true. false 意味着什么也没有被存储 每一个电话都是从空开始的
storagestring存储代号:上载文件作为上下文提供给会议。
返回值
const assistant = await api.models.create({ model: "gemini-3.5-flash" });
assistant.id; // keep this to reopen the session later
assistant.model;
assistant.settings; // {}
assistant.schema; // null
assistant.memory; // true
assistant.title; // "" until the first exchange names it
assistant.createdAt;assistant = api.models.create(model="gemini-3.5-flash")
assistant.id # keep this to reopen the session later
assistant.model
assistant.settings # {}
assistant.schema # None
assistant.memory # True
assistant.title # "" until the first exchange names it
assistant.created_at内内内存,以及它改变什么
这是人们会犯错的选择,因为这两种价值观都是合理的,而且出于相反的原因,它们都是合理的。
| 内存: 真实( 默认) | 内内内存: 假 | |
|---|---|---|
| 谈话 | 每次电话都保留并重新发出 | 无法保存, 每一次呼叫都是从空开始 |
| 稍后重新打开 | 开始( id) 继续 | 没有什么可以继续的 |
| 每一电话费用 | 和谈话长长,然后结 | 平平 |
| 良好 | 助理、线、任何后续跟进 | 分类、提取、一手一手的工作量 |
它停止了对话的存储和重播。 您发送的内容仍然可以找到要解答的模式。 决定您在输入中留下的边, 而不是在国旗上 。
长长的谈话会怎样
含有记忆的会话不会永远重新发送一个不断增长的历史。 旧半部分经过一定的一卷被总结一次, 摘要会与会话一起保存, 最近的讯息会跟随它。 概要只有在卷积再次增长时才被重新编辑 。
- 该摘要本身是一个示范呼吁,因此,它被计为账单——一次,而不是一次。
- 你没有触发它,也不能把它关掉;正是它使长时间的会议每次不花费更多费用。
- 永远保持的治疗,你打算永远保持的治疗,你打算永远保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算永远保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你打算保持的治疗,你,你打算保持的治疗,你打算保持的 和 重播逐字记录不是现在这样。
仓储的,和所供用的食物,
有关段落都通过您的问题找到并提供, 而不是贴上。
const docs = await api.storage.get({ id: storageId });
const assistant = await api.models.create({
model: "gemini-3.5-flash",
storage: docs.id,
settings: { instructions: "Answer only from the documents. Say so when they do not cover it." },
});
await assistant.generate({ inputs: [{ type: "text", content: "What is our refund window?" }] });docs = api.storage.get(id=storage_id)
assistant = api.models.create(
model="gemini-3.5-flash",
storage=docs.id,
settings={"instructions": "Answer only from the documents. Say so when they do not cover it."},
)
assistant.generate(inputs=[{"type": "text", "content": "What is our refund window?"}])随附文件提供这些文件;它不会阻止模型从别处回答,如果你想与它们捆绑在一起,请在指示中说,并期望它告诉你,当它们不覆盖问题时。
错误
| 代码 | 状态 | 触发条件 |
|---|---|---|
| —(在本地抛出) | — | 模式没有通过。 SDK 任何请求之前都先抛出。 |
| model_required | 400 | 服务器看到时模型是空的。 |
| 未经授权 | 401 | 调用时没有有效的会话或密钥 。 |
未列入目录的型号是 否 在此拒绝。 创建会话记录姓名; 拒绝出现在第一个 generate(),这是模型实际上被要求的地方。
// Check the name yourself if you want the failure early
const grid = await api.catalogue();
const known = grid.some((row) => row.model === wanted);
if (!known) throw new Error(`${wanted} is not in the catalogue`);# Check the name yourself if you want the failure early
grid = api.catalogue()
if not any(row["model"] == wanted for row in grid):
raise ValueError(f"{wanted} is not in the catalogue")