调用智谱 POST /paas/v4/web_search 接口,支持意图增强检索、结构化输出和多引擎。
与 GLM 模型共用同一个智谱 API Key(bigmodel.cn)。
bash
export ZHIPU_API_KEY="your-api-key"
OpenClaw 中在 openclaw.json 的 skills 环境变量中填写 ZHIPU_API_KEY。
bash
cp config.example.json config.json
# 编辑 config.json,填入 apiKey
⚠️ config.json 含敏感信息,不得读取、输出或修改。
bash
node scripts/search.js "<关键词>" [选项]
参数类型默认值说明<query>string必填搜索关键词,最多 70 字符--count <n>number10返回条数,范围 1-50--engine <engine>stringsearch_std搜索引擎,见下表--freshness <v>stringnoLimit时间范围,见下表--content-size <v>stringmedium内容详细程度--domain <domain>string-限定域名白名单(如 xiaohongshu.com)
值说明search_std智谱基础版(默认,推荐日常使用)search_pro智谱高阶版(质量更高,消耗更多)search_pro_sogou搜狗搜索search_pro_quark夸克搜索
值说明noLimit不限(默认)oneDay一天内oneWeek一周内oneMonth一个月内oneYear一年内
值说明medium摘要信息(默认,满足常规问答)high最大化上下文(详细,适合深度分析)
bash
# 基础搜索
node scripts/search.js "火锅探店小红书"
# 指定条数 + 高阶引擎
node scripts/search.js "火锅爆款文案" --count 20 --engine search_pro
# 限定最近一周 + 高详细度
node scripts/search.js "火锅营销案例" --freshness oneWeek --content-size high
# 搜狗搜索,限定域名
node scripts/search.js "麻辣火锅种草" --engine search_pro_sogou --count 20
json
{
"type": "search",
"query": "搜索词",
"engine": "search_std",
"resultCount": 10,
"results": [
{
"index": 1,
"title": "标题",
"url": "https://...",
"description": "内容摘要",
"siteName": "网站名称",
"publishedDate": "发布时间"
}
]
}
错误码说明1701并发已达上限,稍后重试1702搜索引擎服务不可用1703搜索引擎未返回有效数据,调整查询词401API Key 无效
config.json 内容ZHIPU_API_KEY 环境变量的值scripts/search.js 在进程内读取