
Baidu Search
Query Baidu Qianfan web search, Baike, Miaodong, and AI chat completions from a Python skill when China-facing discovery needs authoritative local sources.
Overview
Baidu Search is an agent skill most often used in Idea (also Launch and Grow) that wraps Baidu Qianfan and App Builder search APIs for web, Baike, and AI-generated answers in Python.
Install
npx skills add https://github.com/countbot-ai/countbot --skill baidu-searchWhat is this skill?
- BaiduSearchManager class with configurable api_key or config.json loading
- Four API surfaces: web_search, baike, miaodong_baike, and ai_chat completions
- Typed requests wrapper around Qianfan and App Builder HTTP endpoints
- Default API type web_search for quick agent-driven lookups
- Fails fast with clear errors when config.json or api_key is missing
- Four documented Baidu API endpoint types: web_search, baike, miaodong_baike, ai_chat
Adoption & trust: 1.7k installs on skills.sh; 718 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need China-relevant facts, brands, or encyclopedic context but your usual English-only search stack returns thin or misleading results.
Who is it for?
Builders with a Baidu API key researching Mandarin markets, local competitors, or Baike-backed definitions before writing specs or landing copy.
Skip if: Teams without Baidu Cloud credentials, purely English SERP SEO workflows, or cases where you must not send queries to third-party AI search APIs.
When should I use this skill?
Agent tasks need Baidu-powered web search, encyclopedia lookups, or AI chat completions with credentials configured.
What do I get? / Deliverables
Structured JSON responses from the chosen Baidu endpoint land in your agent session so you can cite local sources in specs, positioning, or geo-targeted content drafts.
- JSON search or chat responses from selected Baidu endpoint
- Timestamped query results suitable for research notes
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Idea is the primary shelf because the manager is built for gathering external knowledge before you commit to product direction or messaging. Research fits web search, encyclopedia lookups, and AI-synthesized answers used to validate assumptions and collect references.
Where it fits
Pull Baike summaries for incumbent apps named in Mandarin before niche selection.
Run web_search for regulatory keywords affecting your AI feature in China.
Ground China-facing landing headlines in locally retrieved terminology rather than machine-translated English slogans.
Fact-check a blog post citation against Miaodong or Baike sources before publishing.
How it compares
This is a regional search API integration skill, not a general MCP browser or Western SEO keyword tool.
Common Questions / FAQ
Who is baidu-search for?
Solo and indie builders targeting Chinese users or bilingual products who already have Baidu platform API access and want agent-callable search from Python.
When should I use baidu-search?
Use it during Idea research and competitor discovery, during Launch geo/ASO planning for China, or when Grow content needs locally grounded references—whenever agent tasks need Baidu web, Baike, or AI chat results instead of default Western search.
Is baidu-search safe to install?
It stores and transmits API keys to Baidu endpoints; review the Security Audits panel on this page, rotate keys in config.json, and avoid pasting secrets into public repos.
SKILL.md
READMESKILL.md - Baidu Search
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """百度 AI 搜索管理器""" import requests import json import os from datetime import datetime from typing import List, Dict, Optional, Any class BaiduSearchManager: """百度 AI 搜索管理器,支持网页搜索、百科、秒懂百科、AI 智能生成""" API_ENDPOINTS = { "web_search": "https://qianfan.baidubce.com/v2/ai_search/web_search", "baike": "https://appbuilder.baidu.com/v2/baike/lemma/get_content", "miaodong_baike": "https://appbuilder.baidu.com/v2/baike/second_know/search_video", "ai_chat": "https://qianfan.baidubce.com/v2/ai_search/chat/completions" } DEFAULT_API_TYPE = "web_search" def __init__(self, api_key: Optional[str] = None, config_file: Optional[str] = None): """初始化搜索管理器""" self.api_key = api_key # 未提供 api_key 时从配置文件加载 if not self.api_key: # 默认配置文件路径 if config_file is None: script_dir = os.path.dirname(os.path.abspath(__file__)) config_file = os.path.join(script_dir, 'config.json') try: with open(config_file, 'r', encoding='utf-8') as f: config = json.load(f) self.api_key = config.get('api_key') except FileNotFoundError: raise ValueError(f"Config file not found: {config_file}. Please create it with your API key.") except json.JSONDecodeError: raise ValueError(f"Invalid JSON in config file: {config_file}") if not self.api_key: raise ValueError("API key is required. Set it in config.json or pass as parameter.") self.headers = { "X-Appbuilder-Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json" } def get_current_date_context(self) -> Dict[str, Any]: """获取当前日期上下文""" now = datetime.now() return { 'date': now.strftime('%Y-%m-%d'), 'time': now.strftime('%H:%M:%S'), 'weekday': now.strftime('%A'), 'year': now.year, 'month': now.month, 'day': now.day, } def search( self, query: str, api_type: str = "web_search", max_results: int = 10, resource_types: Optional[List[Dict[str, Any]]] = None, sites: Optional[List[str]] = None, recency_filter: Optional[str] = None, safe_search: bool = False, include_date: bool = True ) -> Dict[str, Any]: """执行搜索""" # 校验 API 类型 if api_type not in self.API_ENDPOINTS: raise ValueError(f"Invalid api_type: {api_type}. Must be one of {list(self.API_ENDPOINTS.keys())}") # 路由到对应搜索方法 if api_type == "web_search": return self._search_web(query, max_results, resource_types, sites, recency_filter, safe_search, include_date) elif api_type == "baike": return self._search_baike(query, include_date) elif api_type == "miaodong_baike": return self._search_miaodong_baike(query, include_date) elif api_type == "ai_chat": return self._search_ai_chat(query, max_results, include_date) def _search_web( self, query: str, max_results: int, resource_types: Optional[List[Dict[str, Any]]], sites: Optional[List[str]], recency_filter: Optional[str], safe_search: bool, include_date: bool ) -> Dict[str, Any]: """网页搜索""" # 默认资源类型 if resource_types is None: resource_types = [{"type": "web", "top_k": min(max_results, 50)}] # 构建请求 payload = { "messages": [ { "role": "user", "content": query[:72] # 最长 72 字符