大部分时间你想要一个会话: 您询问, 您会得到文本或结构化对象或文件, 对话会自行进行。 转弯是下层, 即代理环会不停地呼叫, 以及当循环是你的写时, 您会叫什么 。
两种形状,并肩并肩
| Session | 向左转 | |
|---|---|---|
| 创建于 | api.models.create() | 什么都没有——它是一个呼吁 |
| 状态状态状态状态状态状态状态状态 | 内存使用时保持服务器侧端 | 没有一个,你每次都把历史都寄出来 |
| 手背手背 | 产出:案文 JSON图像、音频、视频 | 模型的下一步移动: 文本, 或工具调用 |
| 工具工具工具工具 | 服务器端搜索和根据设置抓取 | 自己的声明,又回召你 |
| 截止时间截止时间 | 无——一代又一代人将走到最后 | 五分钟五分钟 |
| 你用它来 | 助理、抽取、发电 | 写入自己的代理机构环环 |
如果您不确定,请从会话开始
转弯要求您携带对话, 每次再发一次, 并决定工具呼叫的含义。 当您正在构建循环时, 正确的交易是正确的, 而当您不是时, 则不必要的交易 。
方法
| 方法 | 功能 |
|---|---|
| ({ 创建模式、 设置、 计划、 内存、 存储} ) | 开始开会。返回助理会议。 |
| (二) 获得(id) | 重新打开一个保存的会话。 返回一个助理会话 。 |
| 列表({ 限制} ) | 账户的会话, 最新的会话先开始。 返回普通对象 。 |
| 转转({ 模式、 信息、 工具,...} ) | 一种无国籍模式转弯,当地工具在召唤。 |
和列表 () 不返回相同类型的东西
手拿回一个助理会议, 并在其中生成( ) 。 列表( ) 手拿回普通数据, 没有方法 —— 从中传递一个代号, 以便您想继续时 得到( ) 。
一届会议, 结束至结束
const assistant = await api.models.create({
model: "gemini-3.5-flash",
settings: { instructions: "Answer in French, in at most three sentences." },
});
const result = await assistant.generate({
inputs: [{ type: "text", content: "Résume ce contrat." },
// A document is always a url — unlike image, audio or video, "file" has no content form.
{ type: "file", url: "https://example.com/contrat.pdf" }],
});
result.outputs; // [{ type: "text", content: "…" }]
result.usage.credits; // what it actually cost
await assistant.generate({ inputs: [{ type: "text", content: "Et les risques ?" }] });
// the contract is still in the conversation — you do not re-send itassistant = api.models.create(
model="gemini-3.5-flash",
settings={"instructions": "Answer in French, in at most three sentences."},
)
result = assistant.generate(inputs=[
{"type": "text", "content": "Résume ce contrat."},
{"type": "file", "url": "https://example.com/contrat.pdf"},
])
result["outputs"] # [{"type": "text", "content": "…"}]
result["usage"]["credits"] # what it actually cost
assistant.generate(inputs=[{"type": "text", "content": "Et les risques ?"}])
# the contract is still in the conversation — you do not re-send it转弯,结束到结束
let messages = [{ role: "user", content: "What is the weather in Tunis?" }];
const turn = await api.models.turn({
model: "gemini-3.5-flash",
messages,
tools: [{ name: "weather", description: "Current weather for a city.",
parameters: { city: { type: "string", required: true } } }],
});
turn.stopReason; // "tool_use"
turn.message.toolCalls; // [{ id, name: "weather", args: { city: "Tunis" }, signature }]
// You run the tool, you append the result, you call again.messages = [{"role": "user", "content": "What is the weather in Tunis?"}]
turn = api.models.turn(
model="gemini-3.5-flash",
messages=messages,
tools=[{"name": "weather", "description": "Current weather for a city.",
"parameters": {"city": {"type": "string", "required": True}}}],
)
turn["stopReason"] # "tool_use"
turn["message"]["toolCalls"] # [{"id", "name": "weather", "args": {"city": "Tunis"}, "signature"}]
# You run the tool, you append the result, you call again.环绕环绕环绕的环环是你的。 如果您不想写一个, 代理引擎就是已经建造的环环, 参见 代理引擎.
每一费用
这两家公司都根据供应商在单位内所收到的帐单 目录目录目录目录 给这个模型。 在设计之前, 有两件事值得了解。
- 一段有记忆的会话为其历史付出代价。 每一个电话都重复了对话, 所以一个长的电话每个回答比一个短的回答要花更多的费用—— 直到老的部分被总结出来, 而这都是自己决定的。
- 转弯为它的声明付出代价。 工具定义每次转弯都会被移动。 10个工具你从来不叫它 一次都花不完钱的代币。