Skip to main content
POST
/
zrag
/
retrieval
/
retrieve
全模态知识库检索
curl --request POST \
  --url https://open.bigmodel.cn/api/zrag/retrieval/retrieve \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "multimodal": true,
  "knows": [
    {
      "id": "1234567890"
    }
  ],
  "query": "介绍一下小智",
  "multimodal_parts": [
    {
      "type": "image_url",
      "url": "https://example.com/image.png"
    }
  ],
  "top_k": 8,
  "top_n": 10,
  "recall_method": "mixed",
  "recall_ratio": 0.8,
  "messages": [
    {
      "role": "user",
      "content": "你是谁"
    },
    {
      "role": "assistant",
      "content": "我是小智,一个智能助手"
    }
  ]
}
'
import requests

url = "https://open.bigmodel.cn/api/zrag/retrieval/retrieve"

payload = {
"multimodal": True,
"knows": [{ "id": "1234567890" }],
"query": "介绍一下小智",
"multimodal_parts": [
{
"type": "image_url",
"url": "https://example.com/image.png"
}
],
"top_k": 8,
"top_n": 10,
"recall_method": "mixed",
"recall_ratio": 0.8,
"messages": [
{
"role": "user",
"content": "你是谁"
},
{
"role": "assistant",
"content": "我是小智,一个智能助手"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
multimodal: true,
knows: [{id: '1234567890'}],
query: '介绍一下小智',
multimodal_parts: [{type: 'image_url', url: 'https://example.com/image.png'}],
top_k: 8,
top_n: 10,
recall_method: 'mixed',
recall_ratio: 0.8,
messages: [{role: 'user', content: '你是谁'}, {role: 'assistant', content: '我是小智,一个智能助手'}]
})
};

fetch('https://open.bigmodel.cn/api/zrag/retrieval/retrieve', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
HttpResponse<String> response = Unirest.post("https://open.bigmodel.cn/api/zrag/retrieval/retrieve")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"multimodal\": true,\n \"knows\": [\n {\n \"id\": \"1234567890\"\n }\n ],\n \"query\": \"介绍一下小智\",\n \"multimodal_parts\": [\n {\n \"type\": \"image_url\",\n \"url\": \"https://example.com/image.png\"\n }\n ],\n \"top_k\": 8,\n \"top_n\": 10,\n \"recall_method\": \"mixed\",\n \"recall_ratio\": 0.8,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"你是谁\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"我是小智,一个智能助手\"\n }\n ]\n}")
.asString();
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://open.bigmodel.cn/api/zrag/retrieval/retrieve"

payload := strings.NewReader("{\n \"multimodal\": true,\n \"knows\": [\n {\n \"id\": \"1234567890\"\n }\n ],\n \"query\": \"介绍一下小智\",\n \"multimodal_parts\": [\n {\n \"type\": \"image_url\",\n \"url\": \"https://example.com/image.png\"\n }\n ],\n \"top_k\": 8,\n \"top_n\": 10,\n \"recall_method\": \"mixed\",\n \"recall_ratio\": 0.8,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"你是谁\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"我是小智,一个智能助手\"\n }\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://open.bigmodel.cn/api/zrag/retrieval/retrieve",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'multimodal' => true,
'knows' => [
[
'id' => '1234567890'
]
],
'query' => '介绍一下小智',
'multimodal_parts' => [
[
'type' => 'image_url',
'url' => 'https://example.com/image.png'
]
],
'top_k' => 8,
'top_n' => 10,
'recall_method' => 'mixed',
'recall_ratio' => 0.8,
'messages' => [
[
'role' => 'user',
'content' => '你是谁'
],
[
'role' => 'assistant',
'content' => '我是小智,一个智能助手'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
{
  "data": {
    "contents": [
      {
        "id": "<string>",
        "know_id": "<string>",
        "doc_id": "<string>",
        "text": "<string>",
        "medias": [
          {
            "id": "<string>",
            "url": "<string>",
            "description": "<string>"
          }
        ],
        "image_url": {
          "url": "<string>"
        },
        "video_url": {
          "url": "<string>"
        },
        "index": 123,
        "score": 123,
        "rerank_index": 123,
        "rerank_score": 123,
        "metadata": {
          "doc_type": "<string>",
          "doc_name": "<string>",
          "doc_url": "<string>",
          "index": 123,
          "page_index": 123,
          "clip_index": 123,
          "start_time": 123,
          "end_time": 123,
          "duration": 123,
          "frames": [
            "<string>"
          ]
        }
      }
    ],
    "rewritten_query": {
      "original_query": "<string>",
      "multi_queries": [
        "<string>"
      ]
    },
    "elapsed_ms": 123,
    "total_tokens": 123,
    "request_id": "<string>"
  },
  "code": 123,
  "message": "<string>"
}
{
"code": 123,
"message": "<string>"
}

Authorizations

Authorization
string
header
required

标准的 HTTP Bearer 认证方式,在 API Keys 页面获取密钥。

Body

application/json
knows
object[]
required

查询的知识库列表

multimodal
boolean
default:true

是否走多模态路径检索,默认值为true

query
string

文本查询内容,与多模态查询内容必须传入其中之一

multimodal_parts
object[]

多模态查询内容,与文本查询内容必须传入其中之一

top_k
integer
default:8

最终召回数量,默认为8

top_n
integer
default:10

初始召回数量,默认为10

recall_method
enum<string>
default:mixed

文本检索方式:embedding(向量检索)、keyword(关键词检索)、mixed(混合检索)

Available options:
embedding,
keyword,
mixed
recall_ratio
number
default:0.8

混合检索中向量检索的权重,取值范围0~1

enable_rerank
boolean
default:false

是否开启重排,默认不开启

enable_rewrite
boolean
default:false

是否开启查询重写,可配合messages参数实现多轮对话改写,默认不开启

enable_expansion
boolean
default:false

是否开启扩召,默认不开启

similarity_threshold
number
default:0.2

相似度阈值,低于该阈值的切片会被过滤

messages
object[]

当前对话消息列表,用于多轮对话改写

search_filters
object

过滤条件

Response

业务处理成功

data
object
code
integer

错误码,200为成功

message
string

错误信息