When a team moves several tools behind Vector Engine, the visible configuration often looks simple: one OpenAI-compatible API gateway, one Base URL, one API Key pattern, and a model name copied into Dify, Cursor, and a Node.js service. The hidden risk is that each tool may cache route information differently. A model that works in a local script can still fail in a workflow if a stale model name, an old Base URL, or a scoped key remains inside another tool.
This tutorial builds a small Node.js probe that records a model route snapshot before the tools depend on it. The goal is not to benchmark Vector Engine. The goal is to make the LLM API provider layer observable enough that model_not_found can be traced to a concrete source.
What the probe checks
Use the probe before changing production configuration in Dify or Cursor:
| Check | Why it matters | Failure clue |
|---|---|---|
| Base URL shape | Keeps every client on the same OpenAI-compatible endpoint | 404, HTML response, or network-level error |
| API Key presence | Separates missing key from route errors | 401 or authorization failure |
| Model name | Confirms the route is visible to the key | model_not_found |
| Route cache hash | Detects stale local config or stale tool config | Different hash between tools |
| Minimal chat call | Confirms the OpenAI-compatible API gateway accepts the payload | Response schema mismatch |
Environment file
Keep tool configuration explicit. The probe reads three named configs so the result can be compared with Dify and Cursor settings.
VECTOR_ENGINE_BASE_URL=https://api.vectorengine.cn/v1
VECTOR_ENGINE_API_KEY=replace_with_your_key
VECTOR_ENGINE_MODEL=replace_with_model_name
DIFY_BASE_URL=https://api.vectorengine.cn/v1
DIFY_MODEL=replace_with_model_name
CURSOR_BASE_URL=https://api.vectorengine.cn/v1
CURSOR_MODEL=replace_with_model_name
Do not print the API Key. The route cache needs enough evidence for engineering review, not secrets.
Node.js probe
import crypto from "node:crypto";
const required = [
"VECTOR_ENGINE_BASE_URL",
"VECTOR_ENGINE_API_KEY",
"VECTOR_ENGINE_MODEL",
"DIFY_BASE_URL",
"DIFY_MODEL",
"CURSOR_BASE_URL",
"CURSOR_MODEL",
];
for (const name of required) {
if (!process.env[name]) {
throw new Error(`Missing environment value: ${name}`);
}
}
function normalizeBaseUrl(value) {
return value.replace(/\/+$/, "");
}
function routeHash(route) {
return crypto
.createHash("sha256")
.update(JSON.stringify(route))
.digest("hex")
.slice(0, 12);
}
const routes = [
{
tool: "Vector Engine direct",
baseUrl: normalizeBaseUrl(process.env.VECTOR_ENGINE_BASE_URL),
model: process.env.VECTOR_ENGINE_MODEL,
},
{
tool: "Dify",
baseUrl: normalizeBaseUrl(process.env.DIFY_BASE_URL),
model: process.env.DIFY_MODEL,
},
{
tool: "Cursor",
baseUrl: normalizeBaseUrl(process.env.CURSOR_BASE_URL),
model: process.env.CURSOR_MODEL,
},
];
console.table(
routes.map((route) => ({
tool: route.tool,
baseUrl: route.baseUrl,
model: route.model,
routeHash: routeHash(route),
})),
);
const response = await fetch(`${routes[0].baseUrl}/chat/completions`, {
method: "POST",
headers: {
"content-type": "application/json",
authorization: `Bearer ${process.env.VECTOR_ENGINE_API_KEY}`,
},
body: JSON.stringify({
model: routes[0].model,
messages: [{ role: "user", content: "Return the word ready." }],
temperature: 0,
}),
});
const text = await response.text();
let body;
try {
body = JSON.parse(text);
} catch {
body = { raw: text.slice(0, 240) };
}
console.log({
status: response.status,
model: routes[0].model,
error: body.error?.code || body.error?.message || null,
});
if (body.error?.code === "model_not_found") {
process.exitCode = 2;
}
How to read the output
If the three route hashes differ, do not start with provider blame. Compare the Base URL and model name in Dify, Cursor, and the Node.js service. A route hash mismatch usually means one tool is still carrying an older value.
If the route hashes match but the direct call returns model_not_found, the model name is probably not available for that key or has been copied incorrectly. If the direct call works but Dify or Cursor fails, record each tool's visible Base URL, model field, and key scope before changing anything else.
This is why a small cache probe is useful in a shared LLM API provider layer. It gives the team a repeatable artifact: the exact route, the normalized endpoint, the model name, and the failure category. That is enough to turn a vague "Vector Engine is broken" report into a focused configuration review.
Registration URL: https://api.vectorengine.cn/register?aff=Igym
在 Dify 和 Cursor 依赖前,为 Vector Engine 构建模型路由缓存探测脚本
当团队把多个工具接到向量引擎后,表面配置通常很简单:一个 OpenAI 兼容 API 网关、一个 Base URL、一套 API Key 规则,再把 model name 分别填进 Dify、Cursor 和 Node.js 服务。真正容易出问题的是缓存。某个模型在本地脚本里可用,不代表工作流里也一定可用,因为另一个工具里可能还留着旧的模型名、旧的 Base URL,或者权限范围不同的 Key。
这篇教程用 Node.js 写一个小型探测脚本,在工具依赖路由前记录模型路由快照。目标不是测试向量引擎的性能,而是让向量引擎API中转站所在的 LLM API provider layer 有足够的排错证据,从而把 model_not_found 定位到具体来源。
探测内容
在修改 Dify 或 Cursor 的生产配置前,可以先运行这个探测:
| 检查项 | 作用 | 失败线索 |
|---|---|---|
| Base URL 形态 | 确认每个客户端都指向同一个 OpenAI 兼容端点 | 404、HTML 响应或网络错误 |
| API Key 是否存在 | 区分缺 Key 与路由错误 | 401 或授权失败 |
| model name | 确认这个 Key 能看到目标路由 | model_not_found |
| 路由缓存哈希 | 发现本地配置或工具配置陈旧 | 不同工具的哈希不一致 |
| 最小聊天请求 | 确认 API中转站 接受 OpenAI 兼容请求体 | 响应结构不一致 |
环境变量
把工具配置写清楚。脚本会读取三组配置,便于和 Dify、Cursor 的界面设置对照。
VECTOR_ENGINE_BASE_URL=https://api.vectorengine.cn/v1
VECTOR_ENGINE_API_KEY=replace_with_your_key
VECTOR_ENGINE_MODEL=replace_with_model_name
DIFY_BASE_URL=https://api.vectorengine.cn/v1
DIFY_MODEL=replace_with_model_name
CURSOR_BASE_URL=https://api.vectorengine.cn/v1
CURSOR_MODEL=replace_with_model_name
不要打印 API Key。路由缓存只需要足够的工程排查证据,不需要泄露密钥。
Node.js 探测脚本
上面的英文部分已经给出了完整代码。实际运行时重点看三类输出:每个工具的 Base URL、model name,以及由这些字段生成的 routeHash。只要哈希不一致,就说明 Dify、Cursor 或 Node.js 服务里至少有一个配置没有对齐。
如何判断结果
如果三个 routeHash 不一致,先不要把问题归因到向量引擎中转站。应该先对比 Dify、Cursor 和 Node.js 服务里的 Base URL 与模型名。路由哈希不一致,通常意味着某个工具仍然带着旧值。
如果 routeHash 一致,但直连调用返回 model_not_found,更可能是模型名对当前 Key 不可见,或者复制时有误。如果直连调用成功,但 Dify 或 Cursor 失败,就把每个工具界面里的 Base URL、model 字段和 Key 权限范围记录下来,再进入下一步排查。
这个小脚本的价值在于,它让共享的 LLM API provider layer 有一份可复现的证据:标准化后的端点、模型名、路由哈希和失败分类。这样,含糊的“向量引擎不可用”就能变成一次明确的配置审查。
Top comments (0)