跳过至正文

安装

安装 n8n

在本地使用 Ollama

  1. 在右上角,点击下拉菜单并选择 Create Credential (创建凭据)
Create a n8n Credential
  1. Add new credential (添加新凭据) 下选择 Ollama
Select Ollama under Credential
  1. 如果是在本地运行,请确认 Base URL 设置为 https://:11434;如果通过 Docker 运行,则设置为 http://host.docker.internal:11434,然后点击 Save (保存)
在不使用 Docker Desktop 的环境(例如 Linux 服务器安装)中,host.docker.internal 不会自动添加。请在 Docker 中使用 --add-host=host.docker.internal:host-gateway 运行 n8n或将以下内容添加到 docker compose 文件中:
extra_hosts:
  - "host.docker.internal:host-gateway"
你应该会看到 Connection tested successfully (连接测试成功) 消息。
  1. 创建新工作流时,选择 Add a first step (添加第一步) 并选择一个 Ollama 节点
Add a first step with Ollama node
  1. 选择你心仪的模型(例如 qwen3-coder
Set up Ollama credentials

连接到 ollama.com

  1. ollama.com 上创建一个 API 密钥
  2. 在 n8n 中,点击 Create Credential (创建凭据) 并选择 Ollama
  3. API URL 设置为 https://ollama.ac.cn
  4. 输入您的 API Key (API 密钥) 并点击 Save (保存)