Web Search API
中文exp-2842未验证
Web Search API 是一个专给大模型用的搜索引擎,在传统搜索引擎网页读取、排序的能力基础上,增强了意图识别能力,返回更适合大模型处理的结果(网页标题、网页 URL、网页摘要、网站名称、网站图标等)。
意图增强检索 :支持智能识别用户查询意图,自动判断是否需要网页检索 结构化输出 :返回适合 LLM 处理的数据格式(含标题/URL/摘要/网站名/图标等) 多引擎支持 :整合智谱自研引擎及主流搜索引擎(搜狗/夸克) 支持指定范围搜索 :可自定义返回的搜索结果数量、域名、时间范围等指定搜索,并可调整网页摘要的字数,帮助实现搜索行为的精细化管控 可灵活控制输出结果时间 :响应参数可设置网页发布时间字段,便于时效性分析和排序
接口调用
接口文档: Web Search API 场景示例:搜索财经新闻
Python Java 响应示例 安装 SDK # 安装最新版本 pip install zai-sdk # 或指定版本 pip install zai-sdk== 0.2.3 验证安装 import zai print (zai. __version__ ) from zai import ZhipuAiClient client = ZhipuAiClient( api_key = "YOUR_API_KEY" ) response = client.web_search.web_search( search_engine = "search_pro" , search_query = "搜索2025年4月的财经新闻" , count = 15 , # 返回结果的条数,范围1-50,默认10 search_domain_filter = "www.sohu.com" , # 只访问指定域名的内容 search_recency_filter = "noLimit" , # 搜索指定日期范围内的内容 content_size = "high" # 控制网页摘要的字数,默认medium ) print (response) 安装 SDK Maven < dependency > < groupId > ai.z.openapi </ groupId > < artifactId > zai-sdk </ artifactId > < version > 0.3.5 </ version > </ dependency > Gradle (Groovy) implementation 'ai.z.openapi:zai-sdk:0.3.5' import ai.z.openapi.ZhipuAiClient; import ai.z.openapi.service.web_search.WebSearchService; import ai.z.openapi.service.web_search.WebSearchRequest; import ai.z.openapi.service.web_search.WebSearchResponse; public static void main ( String [] args) { ZhipuAiClient client = ZhipuAiClient . builder (). ofZHIPU (). build ();; WebSearchService webSearchService = client . webSearch (); WebSearchRequest request = WebSearchRequest . builder () . searchEngine ( "search_pro" ) . searchQuery ( "搜索2025年4月的财经新闻" ) . count ( 15 ) // 返回结果的条数,范围1-50,默认10 . searchDomainFilter ( "www.sohu.com" ) // 只访问指定域名的内容 . searchRecencyFilter ( "noLimit" ) // 搜索指定日期范围内的内容 . contentSize ( "high" ) // 控制网页摘要的字数,默认medium . build (); WebSearchResponse response = webSearchService . createWebSearch (request); System . out . println (response); } WebSearchResp( { "created" : 1748261757 , "id" : "20250526201557dda85ca6801b467b" , "request_id" : "20250526201557dda85ca6801b467b" , "search_intent" : [ { "intent" : "SEARCH_ALL" , "keywords" : "2025年4月 财经新闻" , "query" : "搜索2025年4月的财经新闻" } ], "search_result" : [ { "content" : "一、1-4月我国对外直接投资575.4亿美元,同比增长7.5%。以旧换新成效持续显现,家电类商品零售额连续8个月保持两位数增长。" , "icon" : "https://sfile.chatglm.cn/searchImage/sohu_icon_new.jpg" , "link" : "https://www.sohu.com/a/897879632_121123890" , "media" : "搜狐" , "publish_date" : "2025-05-23" , "refer" : "ref_1" , "title" : "2025年5月23日财经早资讯" } ] } )
MCP Server
访问 官方MCP文档 了解更多关于该协议的信息。
MCP Server 配置指南 安装指南 使用支持MCP协议的客户端,如Cursor和Cherry Studio。 从智谱开放平台获取 API 密钥 。 在Cursor中使用 Cursor 0.45.6包含MCP功能。Cursor 作为 MCP 服务客户端,可以通过简单配置连接到 MCP 服务。 导航路径:Cursor设置 → [功能] → [MCP服务器] 配置 MCP 服务器 { "mcpServers" : { "zhipu-web-search-sse" : { "url" : "https://open.bigmodel.cn/api/mcp-broker/proxy/web-search/mcp?Authorization=Your Zhipu API Key" } } } Cursor MCP 使用方法 Cursor MCP 需在 Composer 的 Agent 模式下使用。
复制后粘贴到 AI 对话框发送,本次对话全程生效
出处:智谱 GLM 官方提示词教程 · docs.bigmodel.cn/cn/guide/tools/web-search · 可信度 S · 标签:中文 / 提示词工程 / 长上下文 / 框架 / 少样本 怎么用(对话型)复制后粘贴到对话框发送,本次对话全程生效。想长期用:支持自定义指令的产品(设置→个性化)可设为默认。