dify-chat-model

N8N custom node for Dify Chat Model API with cache support - Compatible with AI Agent

Package Information

Downloads: 6 weekly / 34 monthly
Latest Version: 1.0.1
Author: Marcos Erik

Documentation

N8N Dify Chat Model Node

N8N custom node for integrating Dify Chat Model API with cache support. This node is compatible with N8N's AI Agent and allows you to use Dify's caching capabilities to reduce token costs significantly.

🎯 Features

  • Compatible with N8N AI Agent - Works seamlessly with AI Agent Chat Model output
  • Cache Support - Leverages Dify's cache to reduce token costs
  • Conversation Persistence - Supports continuing existing conversations
  • Flexible Configuration - Configurable response modes (blocking/streaming)
  • Input Variables - Support for custom input variables
  • Secure Credentials - Secure credential management

📦 Installation

Via N8N Community Nodes (Recommended)

  1. Open your N8N instance
  2. Go to SettingsCommunity Nodes
  3. Search for n8n-nodes-dify-chat-model
  4. Click Install
  5. Restart N8N if prompted

Via npm

npm install n8n-nodes-dify-chat-model

Then restart your N8N instance.

🚀 Usage

1. Configure Credentials

  1. Add the Dify Chat Model node to your workflow
  2. Click on Credential to connect with
  3. Click Create New Credential
  4. Select Dify API
  5. Fill in:
    • API Key: Your Dify API key
    • Base URL: https://api.dify.ai (or your self-hosted URL)
  6. Click Save

2. Configure the Node

  • App ID: Your Dify Application ID (required)
  • User ID: User identifier (optional, default: "n8n-user")
  • Conversation ID: To continue existing conversations (optional)
  • Response Mode: "Blocking" (recommended for AI Agent)
  • Input Variables: Additional variables as JSON object (optional)
  • Query: Automatically picks up from AI Agent output

3. Connect to AI Agent

Connect this node to the Chat Model output of your AI Agent node.

💡 Why Use This Node?

  • 💰 Cost Savings: Dify's cache significantly reduces token usage compared to direct LLM calls
  • 🔌 Compatibility: Works seamlessly with N8N's AI Agent
  • 🌐 Flexibility: Supports both cloud and self-hosted Dify instances
  • ⚡ Performance: Faster responses with cached results

📋 Requirements

  • N8N version 1.0.0 or higher
  • Dify API access (cloud or self-hosted)
  • Dify Application ID

🔧 Development

# Install dependencies
npm install

# Build the project
npm run build

# Watch mode for development
npm run dev

# Lint
npm run lint

# Format code
npm run format

📖 Documentation

🐛 Issues & Support

For issues and questions:

📝 License

MIT

🙏 Credits

Built for the N8N community to enable cost-effective AI agent workflows with Dify's caching capabilities.

Discussion