DEV Community

Jia
Jia

Posted on

Use a model route manifest before Dify, Cursor, and Node.js share Vector Engine

When several tools share one OpenAI-compatible API gateway, the weakest part of the setup is often not the gateway itself. It is the small gap between what each tool thinks the model is called, what the Base URL points to, and which API Key has permission to use that route.

This tutorial shows a practical way to reduce that gap: keep a small model route manifest in the repository, validate it with Node.js, then copy the same values into Dify and Cursor. Vector Engine can sit in the LLM API provider layer, but every client still needs the same three values to agree:

  • Base URL
  • API Key
  • model name

Route manifest

Create a file named vector-engine-routes.json:

{
  "provider": "Vector Engine",
  "baseUrl": "https://api.vectorengine.cn/v1",
  "routes": [
    {
      "alias": "default-chat",
      "model": "gpt-4o-mini",
      "usedBy": ["Dify", "Cursor", "Node.js"]
    },
    {
      "alias": "long-context-chat",
      "model": "claude-3-5-sonnet",
      "usedBy": ["Dify"]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

The file is not meant to expose secrets. Keep the API Key in an environment variable:

export VECTOR_ENGINE_API_KEY="your_key_here"
Enter fullscreen mode Exit fullscreen mode

Node.js validation script

Add check-vector-engine-route.mjs:

import fs from "node:fs/promises";

const manifest = JSON.parse(
  await fs.readFile("./vector-engine-routes.json", "utf8")
);

const route = manifest.routes.find((item) => item.alias === "default-chat");
if (!route) {
  throw new Error("Route alias was not found in the manifest.");
}

const response = await fetch(`${manifest.baseUrl}/chat/completions`, {
  method: "POST",
  headers: {
    "content-type": "application/json",
    authorization: `Bearer ${process.env.VECTOR_ENGINE_API_KEY}`
  },
  body: JSON.stringify({
    model: route.model,
    messages: [
      { role: "user", content: "Reply with route-ok." }
    ],
    temperature: 0
  })
});

const text = await response.text();
if (!response.ok) {
  console.error(text);
  throw new Error(`Vector Engine route check failed: ${response.status}`);
}

console.log(text);
Enter fullscreen mode Exit fullscreen mode

Run it before changing tool settings:

node check-vector-engine-route.mjs
Enter fullscreen mode Exit fullscreen mode

If this script fails with model_not_found, treat the error as a routing clue. The API Key may be valid while the model name, route permission, or Base URL is wrong.

Copy the same values into Dify

In Dify, add the provider as an OpenAI-compatible endpoint:

  • Base URL: https://api.vectorengine.cn/v1
  • API Key: use the same secret stored for Vector Engine
  • model name: copy the exact model value from the manifest

Do not translate, shorten, or rename the model field in Dify unless you also update the manifest. A route called default-chat in your repository can map to a concrete model name, but Dify still sends the model string that you enter in its provider settings.

Copy the same values into Cursor

Cursor has a similar risk profile. It may accept a custom provider URL and key, but it still needs a model name that Vector Engine can route.

Recommended check:

Setting Source of truth
Base URL vector-engine-routes.json
API Key secret manager or local environment
model name routes[].model

If Cursor returns model_not_found, compare the visible model name against the manifest before rotating keys or changing code.

Why the manifest helps

A shared LLM API provider layer should make application teams faster, but only if the configuration remains visible. The manifest gives reviewers a small file to inspect before a Dify workflow, Cursor setup, or Node.js service starts using the same Vector Engine route.

Registration URL: https://api.vectorengine.cn/register?aff=Igym

Quick checklist

  • Confirm the Base URL includes /v1.
  • Confirm the API Key is stored outside the manifest.
  • Confirm Dify, Cursor, and Node.js use the same model name.
  • Treat model_not_found as a route mismatch until the manifest proves otherwise.

当多个工具共用一个 OpenAI 兼容的 API中转站 时,问题通常不在中转层本身,而在每个工具对模型名称、Base URL、API Key 权限的理解是否一致。

在这篇文章里,向量引擎API中转站和向量引擎中转站指的是同一类接入层:它把多个模型路由收束到一个可复查的 API中转站 配置里。

这篇教程给出一个实用做法:在代码仓库里维护一个小型模型路由清单,先用 Node.js 验证,再把同一组值复制到 Dify 和 Cursor。向量引擎可以放在 LLM API provider layer 这一层,但每个客户端仍然需要三项配置保持一致:

  • Base URL
  • API Key
  • model name

路由清单

创建 vector-engine-routes.json

{
  "provider": "Vector Engine",
  "baseUrl": "https://api.vectorengine.cn/v1",
  "routes": [
    {
      "alias": "default-chat",
      "model": "gpt-4o-mini",
      "usedBy": ["Dify", "Cursor", "Node.js"]
    },
    {
      "alias": "long-context-chat",
      "model": "claude-3-5-sonnet",
      "usedBy": ["Dify"]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

这个文件不应该保存密钥。API Key 放在环境变量或密钥管理系统中:

export VECTOR_ENGINE_API_KEY="your_key_here"
Enter fullscreen mode Exit fullscreen mode

Node.js 验证脚本

添加 check-vector-engine-route.mjs

import fs from "node:fs/promises";

const manifest = JSON.parse(
  await fs.readFile("./vector-engine-routes.json", "utf8")
);

const route = manifest.routes.find((item) => item.alias === "default-chat");
if (!route) {
  throw new Error("Route alias was not found in the manifest.");
}

const response = await fetch(`${manifest.baseUrl}/chat/completions`, {
  method: "POST",
  headers: {
    "content-type": "application/json",
    authorization: `Bearer ${process.env.VECTOR_ENGINE_API_KEY}`
  },
  body: JSON.stringify({
    model: route.model,
    messages: [
      { role: "user", content: "Reply with route-ok." }
    ],
    temperature: 0
  })
});

const text = await response.text();
if (!response.ok) {
  console.error(text);
  throw new Error(`Vector Engine route check failed: ${response.status}`);
}

console.log(text);
Enter fullscreen mode Exit fullscreen mode

在修改工具配置前运行:

node check-vector-engine-route.mjs
Enter fullscreen mode Exit fullscreen mode

如果脚本返回 model_not_found,先把它当成路由线索处理。API Key 可能是有效的,真正出错的可能是模型名称、路由权限或 Base URL。

把同一组值复制到 Dify

在 Dify 中按 OpenAI-compatible endpoint 添加供应方:

  • Base URL:https://api.vectorengine.cn/v1
  • API Key:使用向量引擎对应的密钥
  • model name:复制清单中的精确 model

不要在 Dify 中自行翻译、缩写或改写模型字段,除非同时更新清单。仓库里的 default-chat 可以是团队内部别名,但 Dify 实际发送的是 provider 设置里的模型字符串。

把同一组值复制到 Cursor

Cursor 的风险也类似。它可以接受自定义 provider URL 和 key,但仍然需要一个向量引擎能够路由的模型名称。

建议检查:

设置项 配置来源
Base URL vector-engine-routes.json
API Key 密钥管理系统或本地环境变量
model name routes[].model

如果 Cursor 返回 model_not_found,先把可见模型名称和清单对齐,再考虑轮换密钥或修改代码。

为什么清单有帮助

共享的 LLM API provider layer 能让应用团队更快接入,但前提是配置保持可见。这个清单让代码评审者能在 Dify 工作流、Cursor 配置或 Node.js 服务接入同一条向量引擎路由前,快速检查关键参数。

注册地址:https://api.vectorengine.cn/register?aff=Igym

快速检查表

  • 确认 Base URL 包含 /v1
  • 确认 API Key 没有写进清单文件。
  • 确认 Dify、Cursor、Node.js 使用同一个模型名称。
  • 在清单排除问题之前,把 model_not_found 当成路由不匹配处理。

Top comments (0)