集合 API

在集合中搜索

查看 Markdown

搜索 collections 的基础 URL 与 REST API 共用:https://api.x.ai。你必须使用 xAI API 密钥,并通过 Authorization: Bearer <your xAI API key> 请求头完成身份验证。



搜索集合内容

/v1/documents/search

在指定集合中搜索与查询相关的内容。

Request Body

querystring

要搜索的 query,会使用与 source 相同的 embedding model 生成 embedding。

sourceobject

DocumentsSource,定义要搜索的文档来源。

Response Body

matchesarray<object>

搜索匹配项。

Exampletext

text

{
  "query": "What is the revenue in the last quarter?",
  "source": {
    "collection_ids": [
      "collection_80100614-300c-4609-959b-a138fa90f542"
    ]
  },
  "filter": "document_type = \"financial_report\" AND year > 2020"
}
Exampletext

text

{
  "matches": [
    {
      "file_id": "file_ac3c5728-7399-41fc-bd62-0fef0042de9c",
      "chunk_id": "0199717c-511b-7a80-bab3-dfe9a27f82ab",
      "chunk_content": ", deferred revenue related to such customer payments amounted to $2.10 billion and $1.77 billion, respectively, mainly due to contractual payment terms. Revenue recognized from the deferred revenue balances as of December 31, 2024 and 2023 was $944 million and $873 million for the six months ended June 30, 2025 and 2024, respectively. We have elected the practical expedient to omit disclosure of the amount of the transaction price allocated to remaining performance obligations for contracts with an original expected contract length of one year or less. As of June 30, 2025, total transaction price allocated to performance obligations that were unsatisfied or partially unsatisfied for contracts with an original expected length of more than one year was $10.38 billion. Of this amount, we expect to recognize $5.47 billion in the next 12 months and the rest over the remaining performance obligation period. Changes in government and economic incentives or tariffs may impact the transaction price or our ability to e",
      "score": 1.1447691,
      "collection_ids": [
        "collection_80100614-300c-4609-959b-a138fa90f542"
      ]
    }
  ]
}

最后更新:2026 年 2 月 13 日