> ## Documentation Index
> Fetch the complete documentation index at: https://docs.querying.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ChatGPT API：回答、来源与搜索词

> 向 ChatGPT 提问，获取回答、引用来源、搜索词、商品以及追问对话。

`CHATGPT` 在开启网页搜索的情况下向 ChatGPT 提问，返回回答、它找到的每个来源、它执行的搜索，以及它绘制的商品和地点卡片。

| | |
| - | - |
| taskType | `CHATGPT` |
| 读取 | `prompt`（回退到 `query`） |
| 积分 | 每个回答 1 |
| 国家 | 可选，默认 `US`。`CN` 和 `HK` 从新加坡出口提问，并使用当地的设备位置。 |
| 位置 | 接受 `payload.location`。见[地区与位置](/zh/engines/capacity.md)。 |

## 请求

```bash theme={"theme":"css-variables"}
curl -X POST https://api.querying.ai/v1/async/task \
  -H "Authorization: Bearer $QUERYING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "taskType": "CHATGPT", "payload": { "prompt": "best CRM for a small team", "country": "US" } }'
```

## 响应

| 字段 | 类型 | 说明 |
| - | - | - |
| `text` | string | 纯文本回答。 |
| `markdown` | string | Markdown 格式的回答，图片位于各自卡片的位置。默认开启。 |
| `model` | string | ChatGPT 回答所用的模型。 |
| `sources` | array | 每个来源：`position`、`url`、`label`、`footnote`、`datePublished`、`searchQueries`、`cited`、`citedText`。 |
| `searchQueries` | string\[] | ChatGPT 执行的网页搜索。默认开启。 |
| `shoppingCards`、`inlineProducts` | array | 商品卡片和回答中带链接的商品名称。默认开启（`include.shopping`）。 |
| `ads` | array | 回答中的赞助内容。默认开启（`include.ads`）。 |
| `entities` | array | 卡片中提到的地点和商品，每项带有其 `type`（例如 `local_business` 或 `product`）和 `name`。 |
| `entityDetails` | array | 每张卡片的详情面板。仅在设置 `include.entityDetails` 时返回。见[卡片详情](#卡片详情)。 |
| `map` | array | 卡片中显示的地点：地址、坐标、电话、评分，以及 ChatGPT 标记地点所用的 `icon` 表情。`provider` 是记录所来自的数据源（`serp` 和 `bright-feed` 为 Google 地图，`yelp-feed` 为 Yelp，`tripadvisor-feed` 为 Tripadvisor），`placeId` 和 `providerUrl` 是该地点在此数据源中的 ID 和页面。`resolvedBy: "address"` 标记 ChatGPT 按模型写出的地址找到的地点。`localName` 是记录的另一个名称，例如韩国店铺的韩文名，`closed` 为 `permanently` 或 `temporarily`。 |
| `citationPills` | array | 每个内联引用标签背后的来源。 |
| `layout` | object | ChatGPT 以卡片形式绘制回答时的卡片布局。见下文。 |
| `forms` | array | 回答中的追问表单（如有）。见[对话](#稍后继续对话)。 |
| `conversation` | object | 回答所属对话的 `id`、`turn` 和 `expiresAt`。 |
| `html` | object | ChatGPT 显示的画面。仅在设置 `include.html` 时返回。 |
| `rawResponse` | array | 解析后的流事件。仅在设置 `include.rawResponse` 时返回。 |

例如，一个精简后的响应：

```json theme={"theme":"css-variables"}
{
  "text": "For a small team, HubSpot CRM and Pipedrive are the usual picks ...",
  "markdown": "For a small team, **HubSpot CRM** and **Pipedrive** are the usual picks ...",
  "model": "gpt-5-3",
  "sources": [
    {
      "position": 1,
      "url": "https://www.example.com/best-crm-small-business",
      "label": "The best CRM software for small businesses",
      "searchQueries": ["best CRM for small teams"],
      "cited": true,
      "citedText": ["HubSpot CRM and Pipedrive are the usual picks"]
    }
  ],
  "searchQueries": ["best CRM for small teams"],
  "conversation": { "id": "8f6c1d2e-...", "turn": 1, "expiresAt": "2026-10-19T12:00:00.000Z" }
}
```

每个来源带有 `searchQueries`（结果中包含该来源的搜索）、`cited`（回答正文是否内联引用了它）和 `citedText`（每处引用所支撑的回答文字）。商品等不是由搜索返回的来源没有 `searchQueries`。

### 卡片布局

ChatGPT 以卡片形式绘制回答时会返回 `layout`。其中的 `nodes` 与 ChatGPT 显示的顺序一致：

| 节点 | 内容 |
| - | - |
| `row`、`box` | 卡片分组。 |
| `title`、`text`、`badge` | 卡片文字。 |
| `image` | 图片：`images[].url`、`thumbnailUrl` 和 `pageUrl`。 |
| `markdown` | 其余回答正文。 |
| `map` | 在 `places` 中列出它显示的每个地点的 `position`。 |
| `form` | 让你选择追问问题的表单。其 `choice` 节点包含选项和初始选中的值；`button` 节点包含 ChatGPT 接下来会发送的问题（`prompt`）。表单不放入 `text` 和 `markdown`。 |

## Include 标志

`CHATGPT` 支持所有响应标志。除 `rawResponse` 和 `html` 外均默认开启；发送 `false` 即可关闭。

| 标志 | 默认 | 效果 |
| - | - | - |
| `markdown` | `true` | 添加 `markdown`。 |
| `searchQueries` | `true` | 添加 `searchQueries`。 |
| `shopping` | `true` | 添加商品卡片。 |
| `ads` | `true` | 添加 `ads`。 |
| `rawResponse` | `false` | 添加 `rawResponse`。见 [Markdown 与原始响应](/zh/engines/response-options.md)。 |
| `html` | `false` | 添加 `html`，页面保存成功时收取 0.25 积分。与 `location`、`CN`、`HK` 或 `continueFrom` 一起发送时以 `422 EVIDENCE_UNSUPPORTED` 拒绝。见 [HTML 页面](/zh/engines/html-pages.md)。 |
| `analysis` | `false` | 添加 `analysis`，1 积分。见[回答分析](/zh/engines/answer-analysis.md)。 |
| `citationAnalysis` | `false` | 对回答运行[Citation Analysis](/zh/research/citation-analysis.md)。 |
| `entityDetails` | `false` | 添加 `entityDetails`，不额外收取积分。见[卡片详情](#卡片详情)。 |

## 卡片详情

开启 `include.entityDetails` 后，回答中的每张卡片（商品、地点、应用、品牌）都会附带读者点击卡片时 ChatGPT 打开的详情面板：介绍、规格、评价及其依据页面。面板会引用自己的页面，因此能看到回答正文之外的来源。

| 字段 | 说明 |
| - | - |
| `name`、`category`、`query` | 回答中显示的卡片名称、类型（`product`、`local_business`、`software`、`organization`）以及 ChatGPT 查找时使用的名称。 |
| `status` | `ok`，或带 `error` 的 `failed`。 |
| `markdown` | 面板的 Markdown，引用标签的写法与回答相同。 |
| `sources` | 每个被引用的页面按首次引用顺序出现一次：`position`、`url`、`label`、`site`、`description`。 |
| `products` | 商品面板顶部的购物卡片：`title`、`price`、`merchant`、`rating`、`num_reviews`、`url` 和 `offers`，结构与 `shoppingCards[].products` 相同。仅当面板显示卡片时返回。 |
| `images` | 面板中的图片。 |
| `complete` | ChatGPT 提前停止写面板时为 `false`，包含截至当时的正文和来源。 |

`error` 在详情请求失败时为 `ENTITY_DETAIL_FAILED`，详情没有正文时为 `ENTITY_DETAIL_EMPTY`，缺少打开详情所需的会话或轮次凭证时为 `ENTITY_DETAIL_UNAVAILABLE`。`payload.location`、`CN`、`HK`、备用路径的回答和 `include.html` 均支持卡片详情。

ChatGPT 之前写过的面板约 1 秒返回，按请求新写的面板需要 10 到 30 秒，同时最多打开 4 个。每个回答最多打开 20 张卡片。面板不额外收取积分，每个追问的回答也各自获得面板。

```json theme={"theme":"css-variables"}
"entityDetails": [
  {
    "name": "Brooks Adrenaline GTS 25",
    "category": "product",
    "query": "Brooks Adrenaline GTS 25",
    "status": "ok",
    "markdown": "## Brooks Adrenaline GTS 25\n\nThe **Brooks Adrenaline GTS 25** is a **stability road running shoe** ... ([Brooks Running](https://www.brooksrunning.com/...))\n\n### Key specifications\n\n| Feature | Details |\n| --- | --- |\n| Heel-to-toe drop | 10 mm |\n...",
    "sources": [
      { "position": 1, "url": "https://www.brooksrunning.com/...", "label": "Men's Adrenaline GTS 25 Running Shoes | Brooks Running", "site": "Brooks Running" },
      { "position": 2, "url": "https://www.rei.com/product/249691/...", "label": "Brooks Adrenaline GTS 25 Road-Running Shoes - Men's | REI Co-op", "site": "REI" }
    ],
    "images": ["https://images.openai.com/..."],
    "complete": true
  }
]
```

## 追问

`payload.followUps` 在第一个回答之后，于同一对话中按顺序再提问最多 4 次。每一项是以下之一：

* `{ "prompt": "..." }`：你自己写的问题。
* `{ "select": { "button": 0, "choices": { "budget": "Under $100" } } }`：按下上一个回答中追问表单的按钮。

`button` 从 0 开始数回答中的按钮，默认是第一个。`choices` 按每个 `choice` 节点的 `name` 选择选项，也可以按表单顺序写成数组；所选的值是选项的 `value` 或 `label`，或从 0 开始的位置。未选择的项保留 ChatGPT 预选的选项，因此 `{ "select": {} }` 会发送按钮自身的 `prompt`。

```json theme={"theme":"css-variables"}
{
  "taskType": "CHATGPT",
  "payload": {
    "prompt": "best CRM for a small team",
    "country": "US",
    "followUps": [{ "prompt": "Which of these has the best free plan?" }]
  }
}
```

顶层字段仍是第一个回答。响应中的 `followUps` 列出后续每个回答，包含实际发送的问题（`prompt`）、`select` 按下的内容（`selection`：按钮的 `label` 和每个选项的值），以及与第一个回答相同的字段。

`select` 无法按下时，其余追问不再提问，`followUpsStopped` 给出该追问的 `index`、`code` 和 `message`：

| 代码 | 含义 |
| - | - |
| `NO_FOLLOW_UP_FORM` | 上一个回答没有显示表单。 |
| `BUTTON_NOT_FOUND` | 该索引处没有按钮。 |
| `CHOICE_NOT_FOUND` | 没有该名称的选项组。 |
| `OPTION_NOT_FOUND` | 没有与所选值匹配的选项。 |
| `PROMPT_UNAVAILABLE` | 按钮没有可发送的问题。 |

任务仍会带着已获得的回答完成。每个回答 1 积分：任务为每个追问预留积分，只对返回的回答扣费。`include.analysis`、`include.citationAnalysis` 和 `include.html` 只作用于第一个回答。其他引擎会以 `400 VALIDATION_ERROR` 拒绝 `followUps`。

## 稍后继续对话

如果要先看回答再决定下一个问题，请发送一个新的 `CHATGPT` 任务，把 `payload.continueFrom` 设为一个已完成任务的 id，并同时发送 `prompt`，或按下该任务最后一个回答中表单的 `select`（规则与 `followUps` 相同）。

```json theme={"theme":"css-variables"}
{
  "taskType": "CHATGPT",
  "payload": {
    "continueFrom": "8f6c1d2e-...",
    "select": { "button": 0 }
  }
}
```

* 显示表单的回答会附带 `forms`：每个表单的 `buttons`（其顺序即 `select.button`），以及 `choices`，包含 `name`、初始选中的选项和 `options`。
* `conversation.id` 是开启对话的任务，`turn` 是目前的回答数，`expiresAt` 是还能继续的最后时间，即第一个回答之后 3 小时。
* 继续提问会接在所指定任务的最后一个回答之下，所以两次指定同一个任务会让对话分叉。
* 沿用原来的 `country` 和 `location`。请省略它们或发送相同的值。
* 其他账户或引擎的任务、尚未完成的任务或无效的 `select` 会以 `400 VALIDATION_ERROR` 拒绝。已过期的对话以 `400 CONVERSATION_EXPIRED` 拒绝。两者都不收费。
* 继续提问的费用与任何 ChatGPT 任务相同。

## 相关内容

* [ChatGPT 产品页](https://querying.ai/zh/engines/chatgpt)
* [引擎概览](/zh/engines/overview.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.