Multiple integration methods: API / MCP / CLI / Skill, etc.
After knowledge retrieval and Q&A services are published, they can be integrated into your applications through various channels. On the console's Application Integration → Service Channels page, you can view integration information and sample code for each channel.
All retrieval and Q&A capabilities are provided via the DashScope API, with service endpoint: https://{workspaceId}.cn-beijing.maas.aliyuncs.com.Authentication:
Copy
Authorization: Bearer <API-Key>
API Keys are created on the console API Key page. The system automatically routes requests to the corresponding workspace based on the API Key.Key Endpoints:
Endpoint
Method
Path
Description
Knowledge Search
POST
/api/v1/indices/knowledge/search
Application-level hybrid search, driven by knowledge retrieval service configuration; caller only needs to pass query and agent_id
Knowledge Q&A
POST
/api/v2/apps/knowledge/chat
Streaming Q&A, returning SSE events
Low-level Retrieval
POST
/api/v1/indices/rag/index/retrieve
Single-knowledge-base retrieval, directly returning vector + keyword recall results — no re-ranking performed at this layer
Example: Knowledge Search API (as provided on the console's Service Channels page):
The search scope and strategy (e.g., multi-repo weights, routing, hybrid ranking) are governed by the knowledge retrieval service configuration associated with agent_id. Callers do not need to repeat these parameters in the request.Example: Low-level Retrieval API (specifying knowledge base ID directly):
Copy
curl -X POST https://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/indices/rag/index/retrieve \ -H "Authorization: Bearer $DASHSCOPE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "index_id": "<KnowledgeBaseID>", "query": "How do I configure chunking strategies?", "top_k": 5 }'
The low-level single-knowledge-base retrieval API returns raw vector + keyword recall results without re-ranking. To enable Rerank-based fine-grained ranking, configure a hybrid ranking model when creating the retrieval service and invoke it via the Knowledge Search API (agent_id).
For the full list of endpoints, see the API Reference.
MCP (Model Context Protocol) is an open standard enabling AI coding assistants and agent frameworks to directly invoke external tools. After integrating the RAG MCP Server, your AI assistant can retrieve content from knowledge bases during conversations.
The sum of DenseSimilarityTopK and SparseSimilarityTopK must be greater than 1. Using only one retrieval method (e.g., Dense=1, Sparse=0) will result in an error.
The RerankMode, RerankMinScore, RerankTopN, and RerankInstruct parameters in the Rerank object are not supported in the current version and will cause errors if provided. To control re-ranking behavior, use only EnableReranking and Rerank.ModelName.
bailian-cli is a command-line tool for interacting with knowledge bases. No coding required — perform retrieval instantly from your terminal. Ideal for local debugging, script integration, and CI/CD pipelines. Installation commands and usage examples are available on the console's Service Channels page.
Beyond knowledge retrieval, bailian-cli wraps 10+ capabilities including image/video generation, speech, vision understanding, and long-term memory. See Use the CLI for the full capability set and installation guide.
Set API KeyStore your API Key as an environment variable — subsequent commands will read it automatically:
Copy
export DASHSCOPE_API_KEY="sk-xxxxxxxxxxxxxxxx"
Get Knowledge Base IDNavigate to the console's Data Ingestion → Knowledge Management page, click your target knowledge base, and copy its ID (e.g., r0t4r2c4ig).
Run Your First RetrievalNo installation needed — run directly using npx:
Run npx bailian-cli knowledge retrieve --help to view all parameter details.
CLI also supports legacy AK/SK authentication (--access-key-id + --access-key-secret + --workspace-id), but --api-key is recommended. When both are provided, --api-key takes precedence.
Integrate your knowledge base as a skill package into AI coding tools like Qoder or Claude Code. Install URL: https://skills.aliyun.com/skills/alibabacloud-bailian-rag-knowledgebase. You can obtain this link on the console's Service Channels → Agent Skill page.Once installed, AI coding tools automatically detect and load knowledge base retrieval capabilities — no manual configuration required.
KnowledgeStudio knowledge bases can be integrated as external capabilities into Alibaba Cloud Bailian agent applications, supporting two binding methods:
Suitable for new-generation agent applications (Agent 2.0). The knowledge base functions as one of the agent's skills, invoked autonomously by the agent according to task planning — unified scheduling with other tools (e.g., MCP).
In the Bailian console: Create Application → Agent Application → Agent 2.0
Under the "Knowledge Base" section, select "External Knowledge Base → KnowledgeStudio"
Paste your API Key and knowledge base ID, then publish
Suitable for Bailian workflow applications. Break down complex tasks into ordered nodes (e.g., LLM node, intent classification node, end node), and use KnowledgeStudio as a "Knowledge Base Retrieval Node" within the workflow.
In the Bailian console: Create Application → Workflow Application
Drag a "Knowledge Base Retrieval" node onto the canvas and select "KnowledgeStudio" as the source
Connect start / LLM / end nodes, then publish as an application
Tasks are dynamic, require multi-step reasoning, and benefit from autonomous agent decision-making. E.g., enterprise intelligent Q&A, complex research tasks
Workflow Binding
Processes are fixed and require strict execution order control. E.g., report generation, customer service routing, diagnostic assistance
If your application is built on third-party platforms like Dify or Coze, refer to Integration with Third-Party Platforms for detailed configuration guidance.