> ## 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.

# 百度文心 Baidu Wenxin API：百度中国 AI 聊天的回答与来源

> 向百度的中国 AI 聊天文心提问，获取回答、它读取的网页和搜索词。

`BAIDU_WENXIN` 以访客身份向百度文心聊天（wenxin.baidu.com）提问。回答前会联网搜索，不使用账号，也不需要登录。

| | |
| - | - |
| taskType | `BAIDU_WENXIN` |
| 读取 | `prompt`（回退到 `query`） |
| 积分 | 1.25 |
| 国家 | **忽略。** 每个任务都从中国大陆提问。 |

## 请求

文心只回答来自中国大陆的访客，因此每个任务都从中国大陆出口发出，`country` 不会改变这一点。可以省略。

```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": "BAIDU_WENXIN", "payload": { "prompt": "上海有哪些适合周末去的博物馆" } }'
```

## 响应

| 字段 | 类型 | 说明 |
| - | - | - |
| `text` | string | 回答。 |
| `markdown` | string | Markdown 格式的回答。无需任何标志即返回。 |
| `searchQueries` | string\[] | 文心回答前执行的搜索。 |
| `sources` | array | 文心读取的网页：`position`、`url`、`label`、`source`（站点名称）。 |
| `rawResponse` | object | 随回答展示的卡片（地点、商品、图片），位于 `components`。仅在 `include.rawResponse` 时返回。 |

回答正文不带引用标记：`sources` 列出的是文心读取的网页，而不是它引用的网页。一个回答通常读取约 30 个网页。

示例：

```json theme={"theme":"css-variables"}
{
  "text": "上海适合周末去的博物馆有上海博物馆东馆 ...",
  "markdown": "上海适合周末去的博物馆有**上海博物馆东馆** ...",
  "searchQueries": ["上海 周末 博物馆 推荐"],
  "sources": [{ "position": 1, "url": "https://www.example.com/shanghai-museums", "label": "上海博物馆推荐", "source": "example.com" }]
}
```

## include 标志

| 标志 | 效果 |
| - | - |
| `rawResponse` | 添加 `rawResponse`。 |

`markdown` 和 `searchQueries` 无需标志。`ads` 和 `shopping` 无效。`analysis` 以 `422 VALIDATION_ERROR` 拒绝，`citationAnalysis` 以 `400 VALIDATION_ERROR` 拒绝，`html` 以 `422 EVIDENCE_UNSUPPORTED` 拒绝。参见 [Markdown 与原始响应](https://docs.querying.ai/zh/engines/response-options.md)。

## 相关文档

* [百度文心产品页](https://querying.ai/zh/engines/baidu-wenxin)
* [Doubao](https://docs.querying.ai/zh/engines/doubao.md)
* [引擎概览](https://docs.querying.ai/zh/engines/overview.md)


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