Dify
English
English
  • Getting Started
    • Welcome to Dify
      • Features and Specifications
      • List of Model Providers
    • Dify Community
      • Deploy with Docker Compose
      • Start with Local Source Code
      • Deploy with aaPanel
      • Start Frontend Docker Container Separately
      • Environment Variables Explanation
      • FAQs
    • Dify Cloud
    • Dify Premium on AWS
    • Dify for Education
  • Guides
    • Model
      • Add New Provider
      • Predefined Model Integration
      • Custom Model Integration
      • Interfaces
      • Schema
      • Load Balancing
    • Application Orchestration
      • Create Application
      • Chatbot Application
        • Multiple Model Debugging
      • Agent
      • Application Toolkits
        • Moderation Tool
    • Workflow
      • Key Concepts
      • Variables
      • Node Description
        • Start
        • End
        • Answer
        • LLM
        • Knowledge Retrieval
        • Question Classifier
        • Conditional Branch IF/ELSE
        • Code Execution
        • Template
        • Doc Extractor
        • List Operator
        • Variable Aggregator
        • Variable Assigner
        • Iteration
        • Parameter Extraction
        • HTTP Request
        • Agent
        • Tools
        • Loop
      • Shortcut Key
      • Orchestrate Node
      • File Upload
      • Error Handling
        • Predefined Error Handling Logic
        • Error Type
      • Additional Features
      • Debug and Preview
        • Preview and Run
        • Step Run
        • Conversation/Run Logs
        • Checklist
        • Run History
      • Application Publishing
      • Structured Outputs
      • Bulletin: Image Upload Replaced by File Upload
    • Knowledge
      • Create Knowledge
        • 1. Import Text Data
          • 1.1 Import Data from Notion
          • 1.2 Import Data from Website
        • 2. Choose a Chunk Mode
        • 3. Select the Indexing Method and Retrieval Setting
      • Manage Knowledge
        • Maintain Documents
        • Maintain Knowledge via API
      • Metadata
      • Integrate Knowledge Base within Application
      • Retrieval Test / Citation and Attributions
      • Knowledge Request Rate Limit
      • Connect to an External Knowledge Base
      • External Knowledge API
    • Tools
      • Quick Tool Integration
      • Advanced Tool Integration
      • Tool Configuration
        • Google
        • Bing
        • SearchApi
        • StableDiffusion
        • Dall-e
        • Perplexity Search
        • AlphaVantage
        • Youtube
        • SearXNG
        • Serper
        • SiliconFlow (Flux AI Supported)
        • ComfyUI
    • Publishing
      • Publish as a Single-page Web App
        • Web App Settings
        • Text Generator Application
        • Conversation Application
      • Embedding In Websites
      • Developing with APIs
      • Re-develop Based on Frontend Templates
    • Annotation
      • Logs and Annotation
      • Annotation Reply
    • Monitoring
      • Data Analysis
      • Integrate External Ops Tools
        • Integrate LangSmith
        • Integrate Langfuse
        • Integrate Opik
    • Extension
      • API-Based Extension
        • External Data Tool
        • Deploy API Tools with Cloudflare Workers
        • Moderation
      • Code-Based Extension
        • External Data Tool
        • Moderation
    • Collaboration
      • Discover
      • Invite and Manage Members
    • Management
      • App Management
      • Team Members Management
      • Personal Account Management
      • Subscription Management
      • Version Control
  • Workshop
    • Basic
      • How to Build an AI Image Generation App
    • Intermediate
      • Build An Article Reader Using File Upload
      • Building a Smart Customer Service Bot Using a Knowledge Base
      • Generating analysis of Twitter account using Chatflow Agent
  • Community
    • Seek Support
    • Become a Contributor
    • Contributing to Dify Documentation
  • Plugins
    • Introduction
    • Quick Start
      • Install and Use Plugins
      • Develop Plugins
        • Initialize Development Tools
        • Tool Plugin
        • Model Plugin
          • Create Model Providers
          • Integrate the Predefined Model
          • Integrate the Customizable Model
        • Agent Strategy Plugin
        • Extension Plugin
        • Bundle
      • Debug Plugin
    • Manage Plugins
    • Schema Specification
      • Manifest
      • Endpoint
      • Tool
      • Agent
      • Model
        • Model Designing Rules
        • Model Schema
      • General Specifications
      • Persistent Storage
      • Reverse Invocation of the Dify Service
        • App
        • Model
        • Tool
        • Node
    • Best Practice
      • Develop a Slack Bot Plugin
      • Dify MCP Plugin Guide: Connect Zapier and Automate Email Delivery with Ease
    • Publish Plugins
      • Publish Plugins Automatically
      • Publish to Dify Marketplace
        • Plugin Developer Guidelines
        • Plugin Privacy Protection Guidelines
      • Publish to Your Personal GitHub Repository
      • Package the Plugin File and Publish it
      • Signing Plugins for Third-Party Signature Verification
    • FAQ
  • Development
    • Backend
      • DifySandbox
        • Contribution Guide
    • Models Integration
      • Integrate Open Source Models from Hugging Face
      • Integrate Open Source Models from Replicate
      • Integrate Local Models Deployed by Xinference
      • Integrate Local Models Deployed by OpenLLM
      • Integrate Local Models Deployed by LocalAI
      • Integrate Local Models Deployed by Ollama
      • Integrate Models on LiteLLM Proxy
      • Integrating with GPUStack for Local Model Deployment
      • Integrating AWS Bedrock Models (DeepSeek)
    • Migration
      • Migrating Community Edition to v1.0.0
  • Learn More
    • Use Cases
      • DeepSeek & Dify Integration Guide: Building AI Applications with Multi-Turn Reasoning
      • Private Deployment of Ollama + DeepSeek + Dify: Build Your Own AI Assistant
      • Build a Notion AI Assistant
      • Create a MidJourney Prompt Bot with Dify
      • Create an AI Chatbot with Business Data in Minutes
      • Integrating Dify Chatbot into Your Wix Website
      • How to connect with AWS Bedrock Knowledge Base?
      • Building the Dify Scheduler
      • Building an AI Thesis Slack Bot on Dify
    • Extended Reading
      • What is LLMOps?
      • Retrieval-Augmented Generation (RAG)
        • Hybrid Search
        • Re-ranking
        • Retrieval Modes
      • How to Use JSON Schema Output in Dify?
    • FAQ
      • Self-Host
      • LLM Configuration and Usage
      • Plugins
  • Policies
    • Open Source License
    • User Agreement
      • Terms of Service
      • Privacy Policy
      • Get Compliance Report
  • Features
    • Workflow
Powered by GitBook
On this page
  • Functional Introduction
  • 1. Create a Compliant External Knowledge Base API
  • 2. Add External Knowledge API
  • 3. Connect to the External Knowledge Base
  • 4. Test External Knowledge Base and Retrieval Results
  • 5. Integrating External Knowledge base in Applications
  • 6. Manage External Knowledge
  • Connection Examples
  • FAQ
  1. Guides
  2. Knowledge

Connect to an External Knowledge Base

PreviousKnowledge Request Rate LimitNextExternal Knowledge API

Last updated 2 months ago

To make a distinction, knowledge bases independent of the Dify platform are collectively referred to as "external knowledge bases" in this article.

Functional Introduction

For developers with advanced content retrieval requirements, the built-in knowledge base functionality and text retrieval mechanisms of the Dify platform may have limitations, particularly in terms of customizing recall results.

Due to the requirement of higher accuracy of text retrieval and recall, as well as the need to manage internal materials, some developer teams choose to independently develop RAG algorithms and independently maintain text retrieval systems, or uniformly host content to cloud vendors' knowledge base services (such as ).

As a neutral platform for LLM application development, Dify is committed to providing developers with a wider range of options.

The Connect to External Knowledge Base feature enables integration between the Dify platform and external knowledge bases. Through API services, AI applications can access a broader range of information sources. This capability offers two key advantages:

  • The Dify platform can directly obtain the text content hosted in the cloud service provider's knowledge base, so that developers do not need to repeatedly move the content to the knowledge base in Dify;

  • The Dify platform can directly obtain the text content processed by algorithms in the self-built knowledge base. Developers only need to focus on the information retrieval mechanism of the self-built knowledge base and continuously optimize and improve the accuracy of information retrieval.

Here are the detailed steps for connecting to external knowledge:

1. Create a Compliant External Knowledge Base API

2. Add External Knowledge API

Currently, when connecting to external knowledge bases, Dify only supports retrieval permissions and does not support optimization or modification of external knowledge bases. Developers need to maintain external knowledge bases themselves.

Navigate to the "Knowledge" page, click "External Knowledge API" in the upper right corner, then click "Add External Knowledge API". Follow the page prompts to fill in the following information:

  • Name Customizable name to distinguish different external knowledge APIs;

3. Connect to the External Knowledge Base

Go to the "Knowledge" page, click "Connect to an External Knowledge Base" under the Add Knowledge Base card to direct to the parameter configuration page.

Fill in the following parameters:

  • Knowledge base name & description

  • External Knowledge API

    Select the external knowledge base API associated in step 2; Dify will call the text content stored in the external knowledge base through the API connection method.

  • External knowledge ID

    Specify the particular external knowledge base ID to be associated, refer to the external knowledge base API definition for detailed instructions.

  • Retrieval Setting

    Top K: When a user sends a question, it will request the external knowledge API to obtain highly relevant content chunks. This parameter is used to filter text chunks with high similarity to the user's question. The default value is 3; the higher the value, the more text chunks with relevant similarities will be retrieval.

    Score Threshold: The similarity threshold for text chunk filtering, only retrievaling text chunks that exceed the set score. The default value is 0.5. A higher value indicates a higher requirement for similarity between the text and the question, expecting fewer retrievaled text chunks, and the results will be relatively more precise.

4. Test External Knowledge Base and Retrieval Results

After connected with the external knowledge base, developers can simulate possible question keywords in the "Retrieval Testing" to preview text chunks that might be retrieval. If you are unsatisfied with the retrieval results, try modifying the External Knowledge Base Settings or adjusting the retrieval strategy of the external knowledge base.

5. Integrating External Knowledge base in Applications

  • Chatbot / Agent type application

    Associate the external knowledge base in the orchestration page within Chatbot / Agent type applications.

  • Chatflow / Workflow type application

    Add a "Knowledge Retrieval" node and select the external knowledge base.

6. Manage External Knowledge

Navigate to the "Knowledge" page, external knowledge base cards will list an EXTERNAL label in the upper right corner. Select the knowledge base needs to be modified, click "Settings" to modify the following information:

  • Knowledge base name and description

  • Permissions

    Provide "Only me", "All team members", and "Partial team members" permission scope. Those without permission will not be able to access the knowledge base. If you choose to make the knowledge base public to other members, it means that other members also have the rights to view, edit, and delete the knowledge base.

  • Retrieval Setting

    Top K: When a user sends a question, it will request the external knowledge API to obtain highly relevant content segments. This parameter is used to filter text chunks with high similarity to the user's question. The default value is 3; the higher the value, the more text chunks with relevant similarities will be retrievaled.

    Score threshold: The similarity threshold for text chunk filtering, only retrievaling text chunks that exceed the set score. The default value is 0.5. A higher value indicates a higher requirement for similarity between the text and the question, expecting fewer retrievaled text chunks, and the results will be relatively more precise.

The "External Knowledge API" and "External Knowledge ID" associated with the external knowledge base do not support modification. If modification is needed, please associate a new "External Knowledge API" and reset it.

Connection Examples

AWS Bedrock

How to connect with AWS Bedrock Knowledge Base?

LlamaCloud

Dify provides an official LlamaCloud plugin that helps you quickly connect to LlamaCloud knowledge bases.

Plugin Installation

  1. Install and configure the LlamaCloud plugin according to the instructions

  2. Enable the plugin in the Dify platform

  3. Fill in the LlamaCloud API key and other necessary information following the plugin configuration wizard

  4. After configuration is complete, you can see the connected external knowledge base in your knowledge base list

With the LlamaCloud plugin, you can directly use LlamaCloud's powerful retrieval capabilities in the Dify platform without writing custom APIs.

Video Tutorial

The following video demonstrates in detail how to use the LlamaCloud plugin to connect to external knowledge bases:

FAQ

How to Fix the Errors Occurring When Connecting to External Knowledge API?

Solutions corresponding to each error code in the return information:

Error Code
Result
Solutions

1001

Invalid Authorization header format

Please check the Authorization header format of the request

1002

Authorization failed

Please check whether the API Key you entered is correct.

2001

The knowledge is not exist

Please check the external repository

Create a compliant External Knowledge Base API before setting up the API service, please refer to Dify's specifications to ensure successful integration between your external knowledge base and Dify.

API Endpoint The URL of the external knowledge base API endpoint, e.g., api-endpoint/retrieval; refer to the for detailed instructions;

API Key Connection key for the external knowledge, refer to the for detailed instructions.

Visit the Dify and search for LlamaCloud

For more information about how it works, please refer to the plugin's .

External Knowledge Base API
External Knowledge API
External Knowledge API
Marketplace
GitHub repository
AWS Bedrock
Principle of external knowledge base connection
Associate External Knowledge API
Connect to the external knowledge base
Test external knowledge base connection and retrieval
Chatbot / Agent
Chatflow / Workflow