Connect to a custom database
Tongyi Deep Search applications can connect to both Alibaba Cloud Model Studio knowledge bases and your own custom knowledge bases. This document describes the API specifications for connecting to a custom knowledge base.
Request description
API
Protocol: HTTP POST
API: Custom
Description: This API allows Tongyi Deep Search applications to perform complex text queries, sorting, and paging operations on your provided endpoint.
Request headers
Parameter | Type | Description | Required |
|---|---|---|---|
Authorization | string | Authentication information | Yes |
Content-Type | string | Static value: application/json | Yes |
Request body
Parameter | Type | Description | Required |
|---|---|---|---|
rid | string | Request ID | Yes |
query | string | Query text | Yes |
num | int | Number of items to retrieve. The value must be between 1 and 100. | Yes |
page | int | Page number. The value must be between 1 and 100. | No |
debug | bool | Debug mode. The default value is false. | No |
Request example
curl --location 'https://xxx' \
--header 'Authorization: Bearer lm-***' \
--header 'Content-Type: application/json' \
--data '{
"rid": "10c96b02-4207-4991-820c-f8a855d1dc42",
"query": "Alibaba Cloud Model Studio",
"num": 10,
"debug": false
}'
Response description
Response parameters
Parameter | Type | Description | Required |
|---|---|---|---|
rid | string | Request ID | Yes |
status | int | Status code. 0 indicates success. | Yes |
message | string | Status message | Yes |
data | object | Response data | Yes |
data.total | int | Total Retrievals | No |
data.docs | array<object> | List of retrieved data. The fields are extensible. | Yes |
data.docs.[].id | string | Page ID | Yes |
data.docs.[].title | string | Title | Yes |
data.docs.[].url | string | Webpage URL | Yes |
data.docs.[].snippet | string | Summary | Yes |
data.docs.[].content | string | Original webpage content | No |
data.docs.[].timestamp_format | string | Webpage publication time | No |
data.docs.[].timestamp | long | Webpage publication timestamp | No |
data.docs.[].hostname | string | Website name | No |
data.docs.[].hostlogo | string | Website logo | No |
debug | object | Debug data | No |
Response example
{
"rid": "10c96b02-4207-4991-820c-f8a855d1dc42",
"status": 0,
"message": "success",
"data": {
"total": 10,
"docs": [
{
"id": "cid-98cc77b09",
"snippet": "Alibaba Cloud Model Studio is a service platform from Alibaba Cloud. Developers can use drag-and-drop tools to create a large model application in 5 minutes, ***",
"title": "Alibaba Cloud Model Studio Platform - Baidu Baike",
"url": "https://baike.baidu.com/item/***",
"timestamp_format": "2025-09-02 00:00:00",
"timestamp": 1756742400,
"hostname": "Baidu Baike",
"hostlogo": "https://cdn.sm.cn/temp/***",
},
{...}
]
},
"debug": {...}
}
Notes
Timeout: 3000 ms
A successful response is indicated when the HTTP status code is 200 and the 'status' field in the response data is 0.
Your custom data is isolated by account and application. This data is used only for model planning and generation and is not stored.