B

Baidu API Search

CLAWHUB · Unverified

面向 Agent 的中文网页来源检索包 Skill: Baidu API Search Owner: valenovo Summary: 面向 Agent 的中文网页来源检索包 Tags: latest:1.0.3 Version history: v1.0.3 | 2026-05-16T16:02:31.386Z | user Localize the ClawHub-facing skill description, README, and agent prompt to Chinese while keeping a separate English README. v1.0.2 | 2026-05-16T15:53:24.563Z | user Add bilingual Chinese and English documentation inside the published skill package. v1.0.1 | 2026-05-16T15:48

62
Rank
84
Safety
961
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 961 downloads reported by the source. Last updated 10/12/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s179p61n385sw9fkrysksnqb8d86tm0e:baidu-api-search
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-valenovo-baidu-api-search/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

111,672 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: baidu-api-search
description: 面向 Agent 的百度 API 搜索 Skill。用于中文“查一下/搜索/联网查/最近/最新/热点”等场景,调用百度百科和百度 AI Search API,保留原始结果、去重并生成 research pack。
version: 1.0.3
homepage: https://github.com/valenovo/baidu-search-skill
metadata: {"openclaw":{"requires":{"env":["BAIDU_AI_SEARCH_API_KEYS"],"anyBins":["python3","python"]},"primaryEnv":"BAIDU_AI_SEARCH_API_KEYS","envVars":[{"name":"BAIDU_AI_SEARCH_API_KEYS","required":true,"description":"百度 AI Search / AppBuilder API Key 列表,多个 Key 用英文逗号分隔,用于失败切换和额度隔离。"}],"homepage":"https://github.com/valenovo/baidu-search-skill"}}
---

# Baidu API Search

把百度百科查询和百度 AI Search API 整理成适合 Agent 使用的中文资料检索流程。遇到中文“查一下 / 搜索 / 联网查 / 最近 / 最新 / 热点”这类请求时,优先使用本 Skill,而不是通用 `web_search`。目标是保留原始来源给 AI 分析,不是用生成式摘要替代证据。

## 工作流程

1. 先选择模式:`lookup`、`fast`、`normal` 或 `deep`。
2. 默认使用统一入口 `{baseDir}/scripts/search.py`;它会把 `lookup` 路由到百度百科,把网页搜索模式路由到自适应搜索。
3. 真实搜索必须读取 `BAIDU_AI_SEARCH_API_KEYS`,不要把 Key 写死在文件里。
4. 简单实体问题,例如“这是什么”“这个人是谁”,优先使用 `lookup`,能用百科解决就不额外搜索网页。
5. `fast` 用于快速找一批来源,`normal` 用于普通问答,`deep` 只在用户明确要求全面覆盖或首轮覆盖不足时使用。
6. 只在需要查看或手动调整搜索词时使用 `scripts/plan_queries.py`。
7. 只有用户明确要求完整跑完所有计划查询时,才使用 `scripts/run_search_plan.py`。
8. 需要刷新结果包时,使用 `scripts/dedupe_results.py` 和 `scripts/build_research_pack.py`。
9. 汇报时说明查询次数、原始结果数、去重后来源数、主要域名、覆盖缺口和下一步建议。
10. 回答事实性结论时,引用 `research_pack.md` 里的 `source_id` 加 URL 或域名;百科查询引用 `lookup_pack.md` 里的词条 URL 或 ID。

## 模式

- `lookup`:调用百度百科候选词和内容接口,通常 1-2 次 API 调用,适合实体定义和消歧。
- `fast`:只跑 1 个搜索词,`top_k=10`,默认使用百度 `lite` 搜索版本,适合快速发现来源。
- `normal`:默认模式,先跑 3 个搜索词,最多规划 12 个多角度搜索词,`top_k=20`。
- `deep`:深度模式,先跑 5 个搜索词,`top_k=30`,必要时基于已有结果继续扩展搜索词。

不要默认直接使用 `deep`。只有用户要求深度覆盖,或首轮结果明显缺少关键角度时,再提高搜索预算。

## 命令

生成搜索词计划:

```bash
python "{baseDir}/scripts/plan_queries.py" --topic "新能源汽车 口碑" --mode normal --output runs/ev-reputation/query_plan.json
```

只检查百度 API 请求体,不真正调用接口:

```bash
python "{baseDir}/scripts/baidu_web_search.py" --query "新能源汽车 口碑" --top-k 50 --dry-run
```

运行轻量百科查询:

```bash
python "{baseDir}/scripts/search.py" "量子计算" --mode lookup
```

先查百科,百科没有候选词时只回退到一次轻量网页搜索:

```bash
python "{baseDir}/scripts/search.py" "某个新产品名称" --mode lookup --fallback-search
```

设置 `BAIDU_AI_SEARCH_API_KEYS` 后运行自适应搜索:

```bash
python "{baseDir}/scripts/search.py" "新能源汽车 口碑" --mode normal
```

用户要求最近或最新信息时,限制网页结果时间范围:

```bash
python "{baseDir}/scripts/search.py" "新能源汽车 口碑" --mode normal --freshness year --no-cache
```

用户要求最新或当前信息时,强制绕过缓存:

```bash
python "{baseDir}/scripts/search.py" "新能源汽车 口碑" --mode normal --no-cache
```

只有用户要求广覆盖或压力测试时,才固定预算跑完整深度搜索:

```bash
python "{baseDir}/scripts/search.py" "新能源汽车 口碑" --mode deep --fixed --top-k 50
```

只有明确需要时,才跑完计划里的每个搜索词:

```bash
python "{baseDir}/scripts/run_search_plan.py" --plan runs/ev-reputation/query_plan.json --out-dir runs/ev-reputation --top-k 50
```

去重:

```bash
python "{baseDir}/scripts/dedupe_results.py" --input runs/ev-reputation/raw_results.jsonl --output runs/ev-reputation/deduped_sources.json
```

生成 research pack:

```bash
python "{baseDir}/scripts/build_resea

README.md

# Baidu API Search

简体中文 | [English](README.en.md)

面向 Agent 的百度 API 搜索 Skill。它调用百度 AI Search API 和百度百科 API,把中文搜索结果整理成可复查、可引用的 research pack,适合需要中文网页来源的 AI Agent 使用。

这个 Skill 不是爬虫,也不是答案生成接口。它只负责检索、去重、保留原始结果,并把来源整理给 Agent 后续分析。

## 功能

- 百度 AI Search `web_search`
- 百度百科轻量实体查询
- `lookup`、`fast`、`normal`、`deep` 四种模式
- 自动规划搜索词并根据覆盖情况提前停止
- URL 去重和近似重复合并
- 输出 `research_pack.md`、`raw_results.jsonl`、`run_summary.json`
- 支持本地缓存和多个 API Key 失败切换

## 环境要求

- Python 3.10+
- 百度 AI Search / AppBuilder API Key
- 能读取 `SKILL.md` 并运行本地 Python 脚本的 Agent 环境

脚本只使用 Python 标准库,不需要额外安装依赖。

API Key 请放在环境变量里:

```bash
export BAIDU_AI_SEARCH_API_KEYS="your-key"
```

Windows PowerShell:

```powershell
$env:BAIDU_AI_SEARCH_API_KEYS = "your-key"
```

多个 Key 用英文逗号分隔:

```bash
export BAIDU_AI_SEARCH_API_KEYS="key1,key2,key3"
```

不要把真实 Key 写进配置文件、README、Prompt、日志或 Git 提交里。

## 快速使用

```bash
python scripts/search.py "新能源汽车 口碑" --mode normal
```

简单实体查询:

```bash
python scripts/search.py "量子计算" --mode lookup
```

查询最近或当前信息:

```bash
python scripts/search.py "新能源汽车 口碑" --mode normal --freshness year --no-cache
```

## 给 Agent 的推荐指令

```text
中文网页搜索、百度百科查询、最近/最新/热点类中文问题,以及用户说“查一下”“搜索”“联网查”时,优先使用 baidu-api-search skill。回答事实性结论时引用 research_pack.md 里的 source_id 或 URL。
```

_meta.json

{
  "ownerId": "kn702h51bcntppmj04vwcpqzn982ptk8",
  "slug": "baidu-api-search",
  "version": "1.0.3",
  "publishedAt": 1778947351386
}

references/baidu-api.md

# Baidu AI Search API Notes

Use this reference before changing request/auth behavior.

## Endpoint

```text
POST https://qianfan.baidubce.com/v2/ai_search/web_search
```

This skill targets the web search endpoint because it returns raw-ish `references` suitable for downstream AI analysis. Do not replace it with generated answer endpoints when the user asks for original information.

## Request Shape

The current script builds this payload:

```json
{
  "messages": [{"role": "user", "content": "新能源汽车 口碑"}],
  "search_source": "baidu_search_v2",
  "resource_type_filter": [{"type": "web", "top_k": 50}]
}
```

For low-latency discovery, `fast` mode may add:

```json
{
  "edition": "lite"
}
```

`lite` reduces recall/reranking depth for better latency. Use `standard` for normal and deep research.

Optional filters:

```json
{
  "search_filter": {
    "match": {
      "site": ["example.com"]
    },
    "items": {
      "block_websites": ["spam.example"]
    }
  },
  "search_recency_filter": "year"
}
```

`search_recency_filter` accepts `week`, `month`, `semiyear`, or `year`. The exact advanced filter grammar should be verified with live API testing before relying on site or block filters. Basic `messages`, `search_source`, `resource_type_filter`, and optional `edition` are the core contract.

## Authentication

Do not hardcode keys. Use:

```text
BAIDU_AI_SEARCH_API_KEYS=key1,key2,key3
```

The script can send both:

```text
Authorization: Bearer <key>
X-Appbuilder-Authorization: Bearer <key>
```

If live testing shows only one header is accepted, use `--auth-header authorization` or `--auth-header x-appbuilder`.

## Limits

- `top_k` is clamped to 50.
- `edition` can be `standard` or `lite`; `standard` remains the default for research.
- There is no known offset/page/next-token for `web_search`.
- Multiple keys should not be treated as pagination for the same query.
- Repeated identical calls should use the local query cache unless the task requires current/latest results.

## Expected Response

The response should expose `references` either at the top level or under `data.references`. The scripts accept both.

Useful fields:

```text
title
url
date
content
snippet
website
type
markdown_text
rerank_score
authority_score
```

## Live Testing Checklist

When an API key is available:

1. Run `baidu_web_search.py --query "新能源汽车 口碑" --top-k 10 --output smoke.json`.
2. Confirm the response contains `references`.
3. Run `run_search_plan.py` with a tiny 2-query plan.
4. Confirm `raw_results.jsonl` has one reference per line.
5. Confirm no key is printed in logs.

## Cache Safety

The cache stores endpoint, payload, raw API response, and timestamp. It must not store API keys, Authorization headers, or full key identifiers. Cached responses should use `key_id: "cache"` in downstream raw results.

references/baike-api.md

# Baidu Baike API Notes

Use this reference before changing lightweight entity lookup behavior.

## Purpose

Baike lookup is a low-budget path for simple entity questions such as:

```text
这是什么?
量子计算是什么?
某个产品/机构/地点有没有百科词条?
```

It is not a substitute for web research, recent news, reviews, complaints, or forum discussion.

## Candidate List

```text
GET https://appbuilder.baidu.com/v2/baike/lemma/get_list_by_title
```

Query parameters:

```text
lemma_title=<term>
top_k=1..100
```

Expected useful fields:

```text
lemma_id
lemma_title
lemma_desc
is_default
url
```

Use this first when the term may be ambiguous.

## Content Lookup

```text
GET https://appbuilder.baidu.com/v2/baike/lemma/get_content
```

Query parameters:

```text
search_type=lemmaTitle|lemmaId
search_key=<title-or-id>
```

Prefer `lemmaId` when the candidate list returned an ID.

Expected useful fields:

```text
lemma_id
lemma_title
lemma_desc
url
summary
abstract_plain
abstract_html
abstract_structured
pic_url
square_pic_url
relations
```

## Authentication

Use the same key environment as web search:

```text
BAIDU_AI_SEARCH_API_KEYS=key1,key2,key3
```

Never write or print the full key. `lookup.py` defaults to the official Baike header:

```text
Authorization: Bearer <key>
```

It can also send these when compatibility testing requires it:

```text
X-Appbuilder-Authorization: Bearer <key>
```

Use `--auth-header both` or `--auth-header x-appbuilder` only if live testing shows the default `Authorization` header is not accepted in a specific environment.

## Response Compatibility

The official docs describe a `result` array for candidate lists, while the success example shows a top-level array. `lookup.py` normalizes both shapes into:

```json
{"result": [...]}
```

## Cache

Baike lookup uses `cache/baike` by default. The cache stores URL, response, and timestamp only. It must not store Authorization headers or keys.

Bypass cache with:

```bash
python scripts/search.py "<topic>" --mode lookup --no-cache
```

## Output

Lookup runs write:

```text
baike_candidates.json
baike_content.json
fallback_web_results.json
errors.jsonl
run_summary.json
lookup_pack.md
```

Use `lookup_pack.md` for agent-readable output. Use JSON files for exact raw response inspection.

## Excluded APIs

Do not add these to the default path:

- SecondKnow video
- image or video search
- Aladdin beta cards
- intelligent search generation / generated-answer endpoints

These either do not serve the text-first search-tool goal or add a generated summary layer that conflicts with preserving source evidence.

Sponsored

Ads related to Baidu API Search and adjacent AI workflows.