ChatPDF API
    ChatPDF API
    • 简介
    • 在 ChatPDF.com 上手动添加 PDF
    • 通过 URL 添加 PDF
      POST
    • 通过文件上传添加 PDF
      POST
    • Chat with PDF 与 PDF 聊天
      POST
    • 删除 PDF
      POST

      Chat with PDF 与 PDF 聊天

      开发环境
      开发环境
      POST
      /v1/chats/message
      使用源 ID 将聊天消息发送到 PDF 文件。
      提出一个问题:提出后续问题:您最多可以在一个请求中包含 6 条消息。如果这些消息中的 OpenAI 令牌总数超过 2,500,则较旧的消息将被忽略,直到不再超出该限制。
      参考来源#
      ChatPDF 可以包含对生成响应所用的 PDF 页面的引用。为此,请在请求正文中包含 referenceSources: true 字段:
      {
        "referenceSources": true,
        "sourceId": "src_xxxxxx",
        "messages": [
          {
            "role": "user",
            "content": "how much is the world?"
          }
        ]
      }
      ChatPDF 可以包含对用于生成响应的 PDF 页面的引用。为此,请在请求正文中包含 referenceSources: true 字段:响应将包含 [P] 形式的内联引用,例如[P2]、[P234] 和附加字段参考:
      {
        "content": "The world is 10 dollars [P2] and can be bought at the supermarket [P5].",
        "references": [
          { "pageNumber": 2 },
          { "pageNumber": 5 }
        ]
      }
      流响应#
      您可以选择逐字流式传输响应。为此,请在请求正文中包含 stream: true 字段:
      {
        "stream": true,
        "sourceId": "src_xxxxxx",
        "messages": [
          {
            "role": "user",
            "content": "how much is the world?"
          }
        ]
      }
      请求示例请求示例
      Shell
      JavaScript
      Java
      Swift
      curl --location --request POST 'http://dev-cn.your-api-server.com/v1/chats/message' \
      --header 'x-api-key: sec_xxxxxx' \
      --header 'Content-Type: application/json' \
      --data-raw '{"sourceId": "src_xxxxxx", "messages": [{"role": "user", "content": "Who wrote the consitution?"}]}'
      响应示例响应示例
      {
        "content": "The world is 10 dollars."
      }

      请求参数

      Header 参数
      x-api-key
      string 
      必需
      示例值:
      sec_xxxxxx
      Content-Type
      string 
      必需
      示例值:
      application/json
      Body 参数application/json
      sourceId
      string 
      必需
      messages
      array [object {2}] 
      必需
      role
      string 
      可选
      content
      string 
      可选
      示例

      返回响应

      🟢200成功
      application/json
      Body
      content
      string 
      必需
      修改于 2023-12-13 06:29:12
      上一页
      通过文件上传添加 PDF
      下一页
      删除 PDF
      Built with