智谱搜索:实时网页搜索智能体技能 - Openclaw Skills

作者:互联网

2026-04-16

AI教程

什么是 智谱搜索技能?

智谱搜索技能使 AI 编程智能体能够使用智谱大模型 API 直接从互联网获取实时信息、最新新闻和当前数据。通过利用这一 Openclaw Skills 集成,开发者可以赋予其智能体回答超出训练数据范围问题的能力,确保时效性查询的准确性。

该技能在构建时充分考虑了安全性,使用 TLS 1.2+ 等工业标准协议,并使用 jq 对输入进行清理以防止注入攻击。对于研究密集型工作流以及构建需要紧跟快速发展的技术领域动态的智能体来说,这是一个必不可少的工具。

下载入口:https://github.com/openclaw/skills/tree/main/skills/honestqiao/zhipu-search

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install zhipu-search

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 zhipu-search。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

智谱搜索技能 应用场景

  • 为用户查询获取最新新闻或时事。
  • 为库文档或 API 更新执行实时技术研究。
  • 在实时网页上验证事实或查找特定信息。
  • 使用来自最新互联网数据的上下文增强智能体响应。
智谱搜索技能 工作原理
  1. AI 智能体根据用户与搜索相关的提示词识别对外部信息的需求。
  2. 该技能构建一个指向智谱聊天补全端点的 POST 请求,包括搜索工具定义。
  3. 使用 jq 对输入数据进行转义,以确保对特殊字符的安全处理。
  4. 智谱 API 处理搜索查询并返回相关的互联网结果。
  5. 智能体解析 JSON 响应并将发现的结果整合到其最终输出中。

智谱搜索技能 配置指南

# 从智谱获取您的 API 密钥 (https://www.bigmodel.cn/usercenter/proj-mgmt/apikeys)
# 直接在终端中设置环境变量
export ZHIPU_API_KEY="your_api_key_here"

# 运行搜索命令
curl -s -X POST "https://open.bigmodel.cn/api/paas/v4/chat/completions" r
  -H "Authorization: Bearer $ZHIPU_API_KEY" r
  -H "Content-Type: application/json" r
  -d '{
    "model": "glm-4-flash",
    "messages": [{"role": "user", "content": "搜索: YOUR_QUERY"}],
    "tools": [{"type": "web_search", "web_search": {"search_query": "YOUR_QUERY"}}]
  }' | jq -r '.choices[0].message.content'

智谱搜索技能 数据架构与分类体系

组件 描述
模型 glm-4-flash (默认,为速度优化)
工具类型 web_search
安全性 TLS 1.2+, 通过 jq 进行 JSON 转义
认证 通过 ZHIPU_API_KEY 环境变量使用 Bearer Token
超时 30 秒 curl 超时以确保可靠性
name: zhipu-search
description: Use Zhipu (智谱) web search API for searching the internet. Use when user asks for web search, latest news, or needs current information.
allowed-tools: Bash(curl:*) Bash(jq:*)
env:
  - ZHIPU_API_KEY

Use Zhipu's web search API to search the internet.

?? Security Requirements

This skill requires ZHIPU_API_KEY environment variable to be set before use.

Security Best Practices:

  1. DO NOT store API keys in ~/.bashrc - keys can be leaked
  2. DO NOT source shell configuration files - prevents arbitrary code execution
  3. Set environment variable directly when running the script
  4. Be aware API key will be visible in process list (ps aux)

Setup

# Set API key as environment variable
export ZHIPU_API_KEY="your_api_key"

Get your API key from: https://www.bigmodel.cn/usercenter/proj-mgmt/apikeys

Usage

export ZHIPU_API_KEY="your_key"

curl -s -X POST "https://open.bigmodel.cn/api/paas/v4/chat/completions" r
  -H "Authorization: Bearer $ZHIPU_API_KEY" r
  -H "Content-Type: application/json" r
  -d '{
    "model": "glm-4-flash",
    "messages": [{"role": "user", "content": "搜索: YOUR_QUERY"}],
    "tools": [{"type": "web_search", "web_search": {"search_query": "YOUR_QUERY"}}]
  }' | jq -r '.choices[0].message.content'

Using the Script

export ZHIPU_API_KEY="your_key"
./search.sh "搜索内容"

Security Analysis

? What's Safe:

  • No sourcing of ~/.bashrc or shell config files
  • Uses jq for JSON escaping (prevents injection)
  • Uses HTTPS with TLS 1.2+
  • API key via environment variable (not hardcoded)
  • Proper error handling - sensitive info not leaked
  • Input validation (query length limit)
  • Generic error messages (no path/file hints)

?? Considerations:

  • Process list visibility: API key visible in ps aux
    • Use in trusted environments only
  • Endpoint: https://open.bigmodel.cn (official Zhipu API)

Safety Features

Feature Implementation
JSON escaping jq --arg prevents injection
Input validation Query length ≤500 chars
TLS Force TLS 1.2+
Error handling Generic messages, no leaks
Timeout 30 second curl timeout

When to Use

  • User says "search for", "look up", "find information about"
  • User asks "what's the latest news about"
  • User needs current information from the web

API Endpoint

Official: https://open.bigmodel.cn/api/paas/v4/chat/completions

相关推荐