LLM 回答
让模型为某条路由作答——Dcision 使用你工作区自己的密钥调用 OpenRouter 或 Vercel AI Gateway,以路由的提示词作为系统消息、以 state 作为输入。
LLM 目的地为某条路由生成回答。它触发时,Dcision 会向你选择的模型发送一个聊天请求——以路由的提示词作为 system 消息,以 state(或你选择的模板)作为 user 消息——并在响应中返回模型的文本。
这就是一个决策如何既能路由又能作答:Jev 判断一条消息与账单有关,再由账单提示词撰写回复。
你的密钥,你的提供商
LLM 回答使用你自己的提供商密钥运行——从不使用 Dcision 的引擎密钥:
provider | 调用 | 密钥 |
|---|---|---|
openrouter(默认) | POST https://openrouter.ai/api/v1/chat/completions | 你的 OpenRouter 密钥 |
vercel | POST https://ai-gateway.vercel.sh/v1/chat/completions | 你的 Vercel AI Gateway 密钥 |
在 设置 → 引擎 → 服务商密钥 中保存密钥——与为 Jev 自带密钥使用的是同一组密钥;管理员和所有者可以添加它们。保存密钥并不会改变引擎:决策可以继续使用 Dcision 的引擎密钥运行,而它们的 LLM 目的地使用你的密钥。提供商会把 token 费用计入你的账户;Dcision 不对其收费,决策本身照常计费。
配置
{
"key": "sales_llm",
"type": "llm",
"when": { "conditions": [{ "field": "route", "on": "output", "operator": "eq", "value": "sales" }] },
"llm": {
"provider": "openrouter",
"model": "openai/gpt-5-mini",
"instructions": "You are Acme's sales team. Answer the lead in two sentences, say that a person will follow up today and never quote prices.",
"input": "{{state.message}}",
"maxTokens": 300,
"temperature": 0.3,
"timeoutMs": 15000
}
}| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
provider | string | openrouter | openrouter 或 vercel。 |
model | string | — | 提供商的模型 ID,例如 openai/gpt-5-mini——字母、数字和 . _ : / -,最多 120 个字符。编辑器会给出一些建议。 |
instructions | string | — | 路由的提示词,作为系统消息发送:1 到 8,000 个字符,可包含变量。 |
input | string | 整个 state | 用户消息:最多 8,000 个字符,可包含变量。留空则以文本形式发送 state——字符串原样发送,对象或列表以 JSON 发送。 |
maxTokens | integer | 512 | 16 到 2,048。 |
temperature | number | 0.3 | 0 到 2。 |
timeoutMs | integer | 20000 | 1,000 到 25,000:Dcision 等待模型的时长。 |
提示词和输入使用文本编码;其中不能使用密钥。
在响应中
{
"key": "sales_llm",
"type": "llm",
"status": "completed",
"text": "Thanks for reaching out! Someone from our sales team will contact you today to talk about your 500 users.",
"model": "openai/gpt-5-mini",
"usage": { "input_tokens": 61, "output_tokens": 27 }
}model 是提供商报告的模型,usage 是它统计的 token——这是提供商的数字,与决策自身的 metrics 分开。
当调用无法进行或失败时,条目会说明原因,而决策仍会作答:
{ "key": "sales_llm", "type": "llm", "status": "failed", "error": "Add your OpenRouter key in Settings → Engine to use LLM replies." }error | 原因 |
|---|---|
| Add your OpenRouter key in Settings → Engine to use LLM replies. | 该提供商没有保存密钥(消息中会指明提供商)。 |
| OpenRouter answered 401: … | 提供商拒绝了请求;后面跟着它自己的消息。 |
| OpenRouter returned an empty answer. | 提供商的回答中没有文本。 |
| No answer from OpenRouter within 15 s. | 超过了 timeoutMs。 |
| Couldn't reach OpenRouter. | 网络错误。 |
LLM 调用只进行一次——不会重试——失败会作为失败的目的地显示在决策的概览中。
延迟
调用方会等待 LLM 回答:它们在决策之后运行,与其他需要等待的目的地(sync 模式的智能体)并行,因此响应会在其中最慢的那个完成后才到达。一个决策每次执行最多可以进行 3 次这样的调用;更多的会以 "reason": "limit" 被跳过。
给你的 HTTP 客户端设置一个超时,覆盖决策的 timeoutMs 加上最长的目的地 timeoutMs——例如 5 秒 + 15 秒 + 一些余量。SDK 默认每次尝试等待 30 秒。响应中的 metrics.latency_ms 只衡量决策本身:不包括这些调用所花的时间。
在 Playground 中
预览会显示提示——提供商、模型、渲染后的指令和消息——而不调用模型。打开真实执行目的地即可获得真实回答;参见测试目的地。
数据
输入——除非你设置了 input,否则就是整个 state——会在你的账户及其条款下发送给你选择的提供商。只发送回答所需的内容:用 "input": "{{state.message}}" 代替整个 state。