npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

n8n-nodes-modelscope

v1.1.14

Published

n8n node for ModelScope API-Inference services including LLM, Vision, and Text-to-Image models

Readme

n8n-nodes-modelscope

npm version License: MIT

这是一个用于 n8n 的 ModelScope API 集成节点包,提供双节点架构支持大语言模型、视觉模型、文生图与向量化(Embedding)模型的调用,以及 AI Agent/Chain 集成功能。

节点架构

本包提供两个互补的节点:

🔧 ModelScope 节点

传统的 API 调用节点,支持:

  • 🤖 大语言模型 (LLM): 支持对话完成,包括 Qwen、GLM、DeepSeek 等主流模型
  • 👁️ 视觉模型 (Vision): 支持图像理解和视觉问答
  • 🎨 文生图模型 (Image): 支持文本到图像的生成,包括 Qwen-Image 等模型
  • 📈 向量化模型 (Embedding): 支持文本向量生成,现已集成 Qwen/Qwen3-Embedding-8B,并支持批量输入
  • 异步处理: 支持文生图任务的异步处理和状态轮询

🔗 ModelScope Chat Model 节点

AI Agent/Chain 集成节点,专为 n8n AI 工作流设计:

  • 🤖 LangChain 集成: 基于 ChatOpenAI 的 LangChain 兼容接口
  • 🔄 AI Agent 支持: 可与 n8n AI Agent 和 AI Chain 节点无缝集成
  • ⚙️ 丰富配置: 支持温度、最大令牌数、频率惩罚等高级参数
  • 🎯 专业化: 专注于大语言模型的 AI 工作流集成

功能特性

  • 🔐 安全认证: 使用 ModelScope API Token 进行身份验证
  • 🎛️ 丰富配置: 支持温度、最大令牌数、图像尺寸等参数调节
  • 🚀 双重集成: 既支持传统 API 调用,也支持现代 AI Agent 工作流
  • 📊 完善错误处理: 包含详细的错误处理和状态反馈机制

安装

通过 npm 安装

npm install n8n-nodes-modelscope

通过 n8n 社区节点安装

  1. 在 n8n 界面中,转到 Settings > Community Nodes
  2. 点击 Install a community node
  3. 输入 n8n-nodes-modelscope
  4. 点击 Install

配置

获取 ModelScope API Token

  1. 访问 ModelScope 并注册账号
  2. 登录后,进入 个人中心 - API Token
  3. 创建新的 API Token
  4. 复制生成的 Token

在 n8n 中配置凭据

  1. 在 n8n 工作流中添加 ModelScope 节点
  2. 点击 Create New Credential
  3. 输入您的 ModelScope API Token
  4. 保存凭据

使用方法

ModelScope 节点使用

大语言模型 (LLM)

支持与大语言模型进行对话:

  • 模型选择: ZhipuAI/GLM-4.6、deepseek-ai/DeepSeek-V3.1、Qwen/Qwen3-235B-A22B-Instruct-2507 等
  • 消息模板: 自定义、代码生成、文本分析、翻译等预设模板
  • 参数配置: 温度、最大令牌数、流式输出等

示例配置:

{
  "resource": "llm",
  "operation": "chatCompletion",
  "model": "ZhipuAI/GLM-4.6",
  "messages": [
    {
      "role": "user",
      "content": "请帮我写一个 Python 函数来计算斐波那契数列"
    }
  ],
  "temperature": 0.7,
  "maxTokens": 2048
}

视觉模型 (Vision)

支持图像理解和视觉问答:

  • 模型选择: Qwen/Qwen3-VL-235B-A22B-Instruct、Qwen/Qwen3-VL-30B-A3B-Instruct 等
  • 图像输入: 支持图像 URL
  • 视觉问答: 对图像内容进行描述、分析、问答

示例配置:

{
  "resource": "vision",
  "operation": "visionChat",
  "model": "Qwen/Qwen3-VL-235B-A22B-Instruct",
  "imageUrl": "https://example.com/image.jpg",
  "prompt": "请描述这张图片的内容",
  "temperature": 0.7,
  "maxTokens": 2048
}

文生图模型 (Image)

支持根据文本描述生成图像:

  • 模型选择: Qwen/Qwen-Image 等
  • 提示词: 支持正面和负面提示词
  • 图像配置: 多种尺寸选择、生成步数调节
  • 异步处理: 自动处理异步任务和状态轮询

示例配置:

{
  "resource": "image",
  "operation": "textToImage",
  "model": "Qwen/Qwen-Image",
  "prompt": "一只可爱的小猫坐在花园里,阳光明媚,高质量,4K",
  "negativePrompt": "blurry, low quality, distorted",
  "size": "1024x1024",
  "steps": 30,
  "timeout": 5
}

向量化模型 (Embedding)

支持将文本生成向量,可用于检索/存储/RAG 等场景:

  • 模型选择: Qwen/Qwen3-Embedding-8B
  • 编码格式: float(返回数值数组,适合直接检索/入库)或 base64(压缩传输/存档)
  • 批量模式: 开启 Batch Mode 后可一次处理多条文本,输出的 data 与输入顺序一一对应

单条示例配置:

{
  "resource": "embedding",
  "operation": "createEmbedding",
  "model": "Qwen/Qwen3-Embedding-8B",
  "input": "你好",
  "encodingFormat": "float"
}

批量示例配置:

{
  "resource": "embedding",
  "operation": "createEmbedding",
  "model": "Qwen/Qwen3-Embedding-8B",
  "batch": true,
  "inputs": {
    "item": [
      { "text": "你好" },
      { "text": "世界" }
    ]
  },
  "encodingFormat": "float"
}

ModelScope Chat Model 节点使用

ModelScope Chat Model 节点专为 n8n AI 工作流设计,可与 AI Agent 和 AI Chain 节点无缝集成:

AI Agent 集成

  1. 在工作流中添加 AI Agent 节点
  2. 在 AI Agent 的 Chat Model 配置中选择 ModelScope Chat Model
  3. 配置模型参数和选项

AI Chain 集成

  1. 在工作流中添加 AI Chain 节点
  2. 在 AI Chain 的 Language Model 配置中选择 ModelScope Chat Model
  3. 配置模型参数和选项

配置选项

  • 模型选择: 支持多种大语言模型
  • 温度 (Temperature): 控制输出的随机性 (0.0-2.0)
  • 最大令牌数 (Max Tokens): 限制输出长度
  • 频率惩罚 (Frequency Penalty): 减少重复内容 (-2.0-2.0)
  • 存在惩罚 (Presence Penalty): 鼓励话题多样性 (-2.0-2.0)
  • Top P: 核采样参数 (0.0-1.0)
  • 响应格式: 文本或 JSON 格式
  • 推理努力: 控制模型推理深度 (低/中/高)

Embedding Pipeline 模式

该节点新增 Mode 选择:

  • Chat Model: 输出 Model(语言模型)
  • Embedding Pipeline: 输出 Chain(包含向量管道)

Embedding Pipeline 下:

  • Embeddings Model: 选择 Qwen/Qwen3-Embedding-8B
  • Options/Top K: 设置近邻数量(默认 5)
  • 输出 Chain 对象包含 vectorStoreembeddings,可在下游执行:
    • 入库:await chain.vectorStore.addTexts(["文本1","文本2"])
    • 检索:const hits = await chain.vectorStore.similaritySearch("查询语句", chain.topK)

支持的模型

大语言模型 (LLM)

  • ZhipuAI 系列:
    • ZhipuAI/GLM-4.6
    • ZhipuAI/GLM-4.5
  • DeepSeek 系列:
    • deepseek-ai/DeepSeek-V3.2-Exp
    • deepseek-ai/DeepSeek-V3.1
    • deepseek-ai/DeepSeek-R1-0528
  • MiniMax 系列:
    • MiniMax/MiniMax-M2
  • Qwen 系列:
    • Qwen/Qwen3-235B-A22B-Instruct-2507
    • Qwen/Qwen3-235B-A22B-Thinking-2507
    • Qwen/Qwen3-Next-80B-A3B-Instruct
    • Qwen/Qwen3-Coder-480B-A35B-Instruct
    • Qwen/Qwen3-Next-80B-A3B-Thinking
  • 更多模型持续更新中...

视觉模型 (Vision)

  • Qwen/Qwen3-VL-235B-A22B-Instruct
  • Qwen/Qwen3-VL-30B-A3B-Instruct
  • 更多模型持续更新中...

文生图模型 (Image)

  • Qwen/Qwen-Image
  • 更多模型持续更新中...

向量化模型 (Embedding)

  • Qwen/Qwen3-Embedding-8B
  • 更多模型持续更新中...

使用限制

  • 每用户每天总计 2000 次 API 调用
  • 单个模型每天不超过 500 次调用
  • 部分大模型限制 200 次/天
  • 文生图任务为异步处理,生成时间通常为 30 秒 - 5 分钟

错误处理

节点包含完善的错误处理机制:

  • 401 错误: API Token 无效或过期
  • 429 错误: 请求频率超限或配额不足
  • 400 错误: 请求参数错误
  • 500 错误: 服务器内部错误

开发

本地开发

# 克隆仓库
git clone https://github.com/xwang152-jack/n8n-nodes-modelscope.git
cd n8n-nodes-modelscope

# 安装依赖
npm install

# 构建
npm run build

# 链接到本地 n8n
npm link
cd ~/.n8n/nodes
npm link n8n-nodes-modelscope

项目结构

n8n-nodes-modelscope/
├── nodes/
│   ├── ModelScope/                     # 传统 API 调用节点
│   │   ├── ModelScope.node.ts          # 主节点文件
│   │   ├── utils/                       # 工具与常量
│   │   │   ├── apiClient.ts
│   │   │   ├── constants.ts
│   │   │   └── errorHandler.ts
│   │   └── resources/
│   │       ├── llm/                    # 大语言模型资源
│   │       ├── vision/                 # 视觉模型资源
│   │       ├── image/                  # 图像生成资源
│   │       └── embedding/              # 向量化资源
│   └── ModelScopeChain/                # AI Agent/Chain 集成节点
│       ├── ModelScopeChain.node.ts     # Chat Model 节点文件
│       └── utils/
│           └── loadModels.ts           # 模型加载工具
├── credentials/
│   └── ModelScopeApi.credentials.ts     # API 凭证配置
├── package.json                        # 项目配置
├── tsconfig.json                       # TypeScript 配置
└── README.md                          # 项目文档

贡献

欢迎提交 Issue 和 Pull Request!

许可证

MIT License - 详见 LICENSE 文件

相关链接