cURL
Perform federated semantic search across multiple knowledge bases and return slices ranked by relevance. The search strategy is pre-configured in the console for an agent instance and published. Callers provide the search intent (
The request surface is kept minimal. All parameters are categorized into two groups by role:
Examples of Category A parameters:
The
The response
On failure,
query / images) and agent_id. Additionally, they may specify document/tag filtering conditions per knowledge base via kb_search_configs.
Before calling this API, you must first publish the Knowledge Search service (agent) in the console; otherwise, an “Agent not published” error will be returned.
Parameter Categories
The request surface is kept minimal. All parameters are categorized into two groups by role:
| Category | Meaning | Belongs to | Included in Request? |
|---|---|---|---|
| Category A · Agent Strategy | Search strategies defined as agent properties | Locked in agent_config, configured and published in the console | No |
| Category B · Invocation Intent | Inputs known only at call time | Request body | Yes |
dense_similarity_top_k, sparse_similarity_top_k, rerank, rerank_top_n, rerank_min_score, hybrid_rerank, enable_kb_router, kb_search_configs[].weight, enable_rewrite, enable_nl2sql, etc. All are managed exclusively within agent_config and cannot be overridden in the request.
Examples of Category B parameters: query, images, kb_search_configs[].id, kb_search_configs[].search_filters.
kb_search_configs
The kb_search_configs field allows specifying document/tag filtering conditions per knowledge base at runtime, enabling dynamic filtering. This field is an array where each element corresponds to one knowledge base.
kb_search_configs[].idmust be a knowledge base ID already bound to the agent in offline configuration; querying unbound knowledge bases is not allowed.- Within the same request,
idvalues must be unique. - Each
kb_search_configselement must include theidfield. - Total byte size of
search_filtersmust not exceed 80,000 bytes. For unstructured knowledge bases, onlytagsandmetakeys are permitted, and their arrays must not exceed 1,000 elements. - Filterable fields must have been declared in
index_config.fieldsduring knowledge base ingestion; otherwise, filtering has no effect.
Response
The response data includes total (total number of matched slices), nodes (list of results), and cost_time (execution time in milliseconds). Each node contains score, text, and metadata; see the parameter table above for details.
Metadata fields prefixed with
_ are internal scoring fields whose names may change across versions—do not rely on them in business logic. Tabular knowledge bases also return additional business fields from the user-defined table schema (field names vary depending on table structure).Error Handling
On failure, success is false, status is ERROR, status_code is the corresponding semantic code, code is the error code string, message is the description, and request_id is always present. Always check success, not just the HTTP status code; when troubleshooting, provide the request_id.
| Scenario | Error Code | Error Message |
|---|---|---|
agent_id missing | InvalidParameter | agent_id is required |
query missing | InvalidParameter | query is required |
kb_id not bound to the agent | InvalidParameter | kb not bound to agent: {id} |
Duplicate kb_id in kb_search_configs | InvalidParameter | duplicate kb id in kb_search_configs: {id} |
kb_search_configs[{i}].id empty | InvalidParameter | kb_search_configs[{i}].id is required |
search_filters total byte size exceeds limit | InvalidParameter | search_filters total bytes must less than 80000 |
Unstructured search_filters contains invalid key | InvalidParameter | search_filters[{i}] contains invalid key '{key}'. Only 'tags' and 'meta' are allowed for unstructured data |
Unstructured tags/meta array exceeds size limit | InvalidParameter | search_filters[{i}].tags array size must not exceed 1000 |
Authorizations
string
header
required
DashScope API Key,在控制台 API Key 页面 获取。
Body
application/jsonstring
required
知识检索服务(agent)实例 ID。服务端据此加载已发布的 agent_config(含全部 A 类检索策略)。在控制台知识检索页面创建并发布后获取。
string
default""
文本检索意图。与 images 至少传入一个;纯图搜时可传空串;非纯图搜场景(未传 images)下必填,否则返回 InvalidParameter。
string[]
default[]
图片检索意图,元素为图片 URL(须公网可访问)。与 query 至少传入一个,可同时传入实现多模态检索。
string
agent 版本。标准接口仅暴露 agent_id / agent_version / query / images / kb_search_configs,其余检索策略一律走 agent_config,不在请求中暴露。
object[]
知识库过滤配置数组。每个元素对应一个知识库,可指定文档/标签过滤条件。id 必须属于 agent 已绑定的知识库,同一请求中不可重复。