DEV Community

Jia
Jia

Posted on

Build a Vector Engine Health Check CLI for Dify, Cursor, and Node.js

When a team connects several LLM tools at the same time, a broken request can hide in plain sight. Dify may use one Base URL, Cursor may keep an old API Key, and a Node.js service may still call a model name that was renamed in the provider console. A small health check CLI gives the team a repeatable way to test the provider contract before debugging the application itself.

This tutorial uses Vector Engine as an OpenAI-compatible API gateway and as an LLM API provider layer. The goal is not to build a large observability system. The goal is to verify four fields every time: Base URL, API Key, model name, and the error path for model_not_found.

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

What the health check should prove

A useful check should answer a few simple questions:

Check Expected evidence
Base URL The client is using https://api.vectorengine.cn/v1
API Key The key belongs to the current environment
model name The model ID is enabled for the account
request shape The SDK or HTTP client appends the right endpoint path
failure path model_not_found is handled as a configuration issue

Keep this check separate from Dify workflows, Cursor settings, and production Node.js routes. If the CLI fails, the tool integration is not the main suspect yet.

Environment variables

Create a local .env pattern or export variables in your shell:

VECTOR_ENGINE_BASE_URL=https://api.vectorengine.cn/v1
VECTOR_ENGINE_API_KEY=replace-with-your-key
VECTOR_ENGINE_MODEL=replace-with-enabled-model-id
Enter fullscreen mode Exit fullscreen mode

Use a service key for the health check, not a personal Cursor key. Separate keys make later usage review and rotation easier.

Node.js health check script

Install the OpenAI SDK in your project, then create check-vector-engine.mjs:

import OpenAI from "openai";

const baseURL = process.env.VECTOR_ENGINE_BASE_URL || "https://api.vectorengine.cn/v1";
const apiKey = process.env.VECTOR_ENGINE_API_KEY;
const model = process.env.VECTOR_ENGINE_MODEL;

if (!apiKey || !model) {
  console.error("Missing VECTOR_ENGINE_API_KEY or VECTOR_ENGINE_MODEL");
  process.exit(1);
}

const client = new OpenAI({ apiKey, baseURL });

try {
  const response = await client.chat.completions.create({
    model,
    messages: [
      { role: "system", content: "Reply with one short sentence." },
      { role: "user", content: "Confirm the provider route is working." },
    ],
    temperature: 0.1,
  });

  console.log("Vector Engine route OK");
  console.log(response.choices[0]?.message?.content ?? "");
} catch (error) {
  const message = error?.message || String(error);
  console.error("Vector Engine route failed");
  console.error(message);

  if (message.includes("model_not_found")) {
    console.error("Check the model name, account permission, and tool-specific model mapping.");
  }

  process.exit(1);
}
Enter fullscreen mode Exit fullscreen mode

Run it before wiring the same provider values into more tools:

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

Dify setup checklist

After the CLI succeeds, configure Dify with the same provider contract:

Dify field Value
Provider type OpenAI-compatible provider
Base URL https://api.vectorengine.cn/v1
API Key A Vector Engine key dedicated to Dify
Model The same enabled model ID used in the CLI

Test with a short prompt before adding retrieval, tools, or long workflows. If Dify returns model_not_found while the CLI works, compare the exact model string and confirm whether Dify is sending requests to the same Base URL.

Cursor setup checklist

Cursor should use a separate API Key so coding-assistant traffic can be reviewed independently:

Provider: OpenAI-compatible custom endpoint
Base URL: https://api.vectorengine.cn/v1
API Key: VECTOR_ENGINE_CURSOR_KEY
Model: enabled model ID for coding work
Enter fullscreen mode Exit fullscreen mode

If Cursor fails while the CLI and Dify work, inspect Cursor-specific settings rather than changing the provider layer for every tool.

Put the check in deployment notes

For a production Node.js service, keep the same fields in deployment documentation:

VECTOR_ENGINE_BASE_URL=https://api.vectorengine.cn/v1
VECTOR_ENGINE_API_KEY=service-key-owned-by-the-app
VECTOR_ENGINE_MODEL=approved-model-id
Enter fullscreen mode Exit fullscreen mode

A health check like this also creates a clean handoff for incidents. When a developer reports that a feature is broken, the team can run one provider check before opening a wider application investigation.


为 Dify、Cursor 和 Node.js 构建向量引擎健康检查 CLI

当团队同时接入多个 LLM 工具时,一个失败请求很容易被误判。Dify 可能使用一个 Base URL,Cursor 里可能还保留旧的 API Key,而 Node.js 服务可能仍在调用一个已经不适用的 model name。一个小型健康检查 CLI 可以让团队先验证 provider contract,再去排查业务代码。

本文把向量引擎作为 OpenAI-compatible API gateway 和 LLM API provider layer 来使用,也就是常说的向量引擎API中转站。目标不是搭建庞大的监控系统,而是每次都验证四个字段:Base URL、API Key、model name,以及 model_not_found 的错误路径。

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

健康检查要证明什么

一个实用检查应回答这些问题:

检查项 预期证据
Base URL 客户端使用 https://api.vectorengine.cn/v1
API Key Key 属于当前环境
model name 模型 ID 已在账号中启用
request shape SDK 或 HTTP client 正确追加 endpoint path
failure path model_not_found 被当作配置问题处理

建议把这个检查独立于 Dify workflow、Cursor 设置和生产 Node.js route。CLI 如果失败,先不要急着改工具集成,应该先检查向量引擎中转站这一层的配置。

环境变量

可以在本地 .env 或 shell 中准备这些变量:

VECTOR_ENGINE_BASE_URL=https://api.vectorengine.cn/v1
VECTOR_ENGINE_API_KEY=replace-with-your-key
VECTOR_ENGINE_MODEL=replace-with-enabled-model-id
Enter fullscreen mode Exit fullscreen mode

健康检查建议使用服务级 Key,不要直接复用个人 Cursor Key。按工具拆分 Key,更利于后续用量审查和轮换。

Node.js 健康检查脚本

在项目中安装 OpenAI SDK 后,创建 check-vector-engine.mjs

import OpenAI from "openai";

const baseURL = process.env.VECTOR_ENGINE_BASE_URL || "https://api.vectorengine.cn/v1";
const apiKey = process.env.VECTOR_ENGINE_API_KEY;
const model = process.env.VECTOR_ENGINE_MODEL;

if (!apiKey || !model) {
  console.error("Missing VECTOR_ENGINE_API_KEY or VECTOR_ENGINE_MODEL");
  process.exit(1);
}

const client = new OpenAI({ apiKey, baseURL });

try {
  const response = await client.chat.completions.create({
    model,
    messages: [
      { role: "system", content: "Reply with one short sentence." },
      { role: "user", content: "Confirm the provider route is working." },
    ],
    temperature: 0.1,
  });

  console.log("Vector Engine route OK");
  console.log(response.choices[0]?.message?.content ?? "");
} catch (error) {
  const message = error?.message || String(error);
  console.error("Vector Engine route failed");
  console.error(message);

  if (message.includes("model_not_found")) {
    console.error("Check the model name, account permission, and tool-specific model mapping.");
  }

  process.exit(1);
}
Enter fullscreen mode Exit fullscreen mode

在把相同配置写入更多工具之前,先运行:

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

Dify 配置清单

CLI 成功后,再把同一套 provider contract 写入 Dify:

Dify 字段 配置值
Provider type OpenAI-compatible provider
Base URL https://api.vectorengine.cn/v1
API Key 专供 Dify 使用的向量引擎 Key
Model 与 CLI 相同的已启用模型 ID

在加入检索、工具调用或长 workflow 之前,先用短 prompt 测试。如果 CLI 正常但 Dify 返回 model_not_found,应比对模型字符串,并确认 Dify 是否真的发往同一个 Base URL。

Cursor 配置清单

Cursor 应使用单独 API Key,便于独立审查编码助手流量:

Provider: OpenAI-compatible custom endpoint
Base URL: https://api.vectorengine.cn/v1
API Key: VECTOR_ENGINE_CURSOR_KEY
Model: enabled model ID for coding work
Enter fullscreen mode Exit fullscreen mode

如果 Cursor 失败,而 CLI 和 Dify 正常,就优先排查 Cursor 专属设置,不要直接改动整个 API中转站配置。

把检查写进部署说明

生产 Node.js 服务也应该保留同样字段:

VECTOR_ENGINE_BASE_URL=https://api.vectorengine.cn/v1
VECTOR_ENGINE_API_KEY=service-key-owned-by-the-app
VECTOR_ENGINE_MODEL=approved-model-id
Enter fullscreen mode Exit fullscreen mode

这样的健康检查也方便故障交接。开发者报告功能异常时,团队可以先运行一次向量引擎 provider 检查,再决定是否进入更大的应用排查。

Top comments (0)