Skip to main content

Third-Party Integration

Connect the RAG Knowledge Base to Dify, Coze, n8n, LangChain, and other platforms.

The RAG Knowledge Base exposes standard APIs and the MCP protocol, so it integrates with the major AI application platforms.

Dify

Dify supports External Knowledge integration.
1

Get the API details

On the Service Channels page in the RAG console, copy the Dash API endpoint and API Key.
2

Configure Dify

Open Dify's Knowledge Base settings, pick External Knowledge, and enter:
  • API Endpoint: the DashScope retrieval endpoint URL.
  • API Key: your DashScope API Key.
  • Knowledge Base ID: the target Knowledge Base ID.
3

Use it in a workflow

In a Dify workflow or chat app, pick the external Knowledge Base as the retrieval source.

Coze

Coze supports both MCP and custom API plugins. Option 1: MCP Add an MCP tool to your Coze bot's settings:
  1. Click Add MCP Tool.
  2. Enter the MCP Server URL and auth info (from the Service Channels page in the console).
  3. Pick the retrieval / Q&A capabilities to expose.
Option 2: API plugin
  1. Create a custom plugin in Coze.
  2. Point the HTTP request at the DashScope retrieval endpoint.
  3. Map the input parameters (query, top_k) and output parameters (Chunk list).

n8n

n8n can call the RAG retrieval endpoint through its HTTP Request node:
  1. Add an HTTP Request node.
  2. Set the method to POST and the URL to https://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/indices/rag/index/retrieve.
  3. In Headers, add Authorization: Bearer <API-Key>.
  4. In Body, set the retrieval parameters (index_id, query, top_k).

LangChain

Wire it in as a custom retriever:
import requests

class DashScopeRetriever:
    def __init__(self, api_key, index_id):
        self.api_key = api_key
        self.index_id = index_id

    def get_relevant_documents(self, query):
        resp = requests.post(
            "https://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/indices/rag/index/retrieve",
            headers={
                "Authorization": f"Bearer {self.api_key}",
                "Content-Type": "application/json",
            },
            json={
                "index_id": self.index_id,
                "query": query,
                "top_k": 5,
            },
        )
        nodes = resp.json().get("data", {}).get("nodes", [])
        return [{"page_content": n["text"], "metadata": n.get("metadata", {})} for n in nodes]
The code above is illustrative — add error handling and retry logic before using it in production.
Every third-party integration is built on the DashScope API. See the API Reference for full details.