
Baidu Search
- 8 installs
- 33 repo stars
- Updated April 26, 2026
- bighardperson/computer-science-skills-collection
baidu-search is a skill that searches the web through the Baidu AI Search Engine API for live information and research.
About
This skill searches the web using the Baidu AI Search API via a bundled Python script. It accepts a query with optional result count and freshness time-range filters and returns live search results. A developer uses it for live information, documentation lookups, or research, especially for Chinese-language queries.
- Searches the web via the Baidu AI Search Engine (BDSE) API
- Supports result count (1-50) and freshness/time-range filters
- Requires a BAIDU_API_KEY configured in OpenClaw
Baidu Search by the numbers
- 8 all-time installs (skills.sh)
- Ranked #1,522 of 2,719 Automation & Workflows skills by installs in the Skillselion catalog
- Data as of Jul 30, 2026 (Skillselion catalog sync)
baidu-search capabilities & compatibility
Requires a BAIDU_API_KEY from the Baidu Qianfan console; usage is billed to that key.
- Use cases
- web search · research
- Runs
- Runs locally
- Pricing
- Bring your own API key
What baidu-search says it does
Search the web using Baidu AI Search Engine (BDSE). Use for live information, documentation, or research topics.
This skill requires a **BAIDU_API_KEY** to be configured in OpenClaw.
Number of results to return, range 1-50
npx skills add https://github.com/bighardperson/computer-science-skills-collection --skill baidu-searchAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 8 |
|---|---|
| repo stars | ★ 33 |
| Last updated | April 26, 2026 |
| Repository | bighardperson/computer-science-skills-collection ↗ |
What it does
Search the web via the Baidu AI Search API for live information, documentation, or research topics.
Who is it for?
Live web search and research via Baidu, including Chinese-language and time-filtered queries.
Skip if: Users without a Baidu Qianfan API key, since it requires a BAIDU_API_KEY.
When should I use this skill?
you need live web information, documentation, or research results via Baidu search.
By the numbers
- Result count range 1-50
- Four relative freshness windows (pd, pw, pm, py)
Files
Baidu Search
Search the web via Baidu AI Search API.
Prerequisites
API Key Configuration
This skill requires a BAIDU_API_KEY to be configured in OpenClaw.
If you don't have an API key yet, please visit: https://console.bce.baidu.com/ai-search/qianfan/ais/console/apiKey
For detailed setup instructions, see: references/apikey-fetch.md
Usage
python3 skills/baidu-search/scripts/search.py '<JSON>'Request Parameters
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
| query | str | yes | - | Search query |
| count | int | no | 10 | Number of results to return, range 1-50 |
| freshness | str | no | Null | Time range, two formats: format one is ”YYYY-MM-DDtoYYYY-MM-DD“, and format two includes pd, pw, pm, and py, representing the past 24 hours, past 7 days, past 31 days, and past 365 days respectively |
Examples
# Basic search
python3 scripts/search.py '{"query":"人工智能"}'
# Freshness first format "YYYY-MM-DDtoYYYY-MM-DD" example
python3 scripts/search.py '{
"query":"最新新闻",
"freshness":"2025-09-01to2025-09-08"
}'
# Freshness second format pd、pw、pm、py example
python3 scripts/search.py '{
"query":"最新新闻",
"freshness":"pd"
}'
# set count, the number of results to return
python3 scripts/search.py '{
"query":"旅游景点",
"count": 20,
}'Current Status
Fully functional.
{
"ownerId": "kn7akgt520t01vgs2tzx7yk6m180kt26",
"slug": "baidu-search",
"version": "1.1.3",
"publishedAt": 1773828934466
}{
"slug": "baidu-search",
"name": "Baidu Search",
"version": "1.1.3",
"installedAt": 1776152115219,
"source": "skillhub"
}Baidu API Key Setup Guide (OpenClaw)
BAIDU_API_KEY Not Configured
When the BAIDU_API_KEY environment variable is not set, follow these steps:
1. Get API Key
Visit: https://console.bce.baidu.com/ai-search/qianfan/ais/console/apiKey
- Log in to your Baidu Cloud account
- Create an application or view existing API keys
- Copy your API Key (only API Key is needed)
2. Configure OpenClaw
Edit the OpenClaw configuration file: ~/.openclaw/openclaw.json
Add or merge the following structure:
{
"skills": {
"entries": {
"baidu-search": {
"env": {
"BAIDU_API_KEY": "your_actual_api_key_here"
}
}
}
}
}Replace "your_actual_api_key_here" with your actual API key.
3. Verify Configuration
# Check JSON format
cat ~/.openclaw/openclaw.json | python -m json.tool4. Restart OpenClaw
openclaw gateway restart5. Test
cd ~/.openclaw/workspace/skills/baidu-search
python3 scripts/search.py '{"query": "test search"}'Troubleshooting
- Ensure
~/.openclaw/openclaw.jsonexists with correct JSON format - Confirm API key is valid and Baidu AI Search service is activated
- Check account balance on Baidu Cloud
- Restart OpenClaw after configuration changes
Recommended: Use OpenClaw configuration file for centralized management
import sys
import json
import requests
import os
import re
from datetime import datetime, timedelta
def baidu_search(api_key, requestBody: dict):
url = "https://qianfan.baidubce.com/v2/ai_search/web_search"
headers = {
"Authorization": "Bearer %s" % api_key,
"X-Appbuilder-From": "openclaw",
"Content-Type": "application/json"
}
# 使用POST方法发送JSON数据
response = requests.post(url, json=requestBody, headers=headers)
response.raise_for_status()
results = response.json()
if "code" in results:
raise Exception(results["message"])
datas = results["references"]
keys_to_remove = {"snippet"}
for item in datas:
for key in keys_to_remove:
if key in item:
del item[key]
return datas
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python baidu_search.py <Json>")
sys.exit(1)
query = sys.argv[1]
parse_data = {}
try:
parse_data = json.loads(query)
print(f"success parse request body: {parse_data}")
except json.JSONDecodeError as e:
print(f"JSON parse error: {e}")
if "query" not in parse_data:
print("Error: query must be present in request body.")
sys.exit(1)
count = 10
search_filter = {}
if "count" in parse_data:
count = int(parse_data["count"])
if count <= 0:
count = 10
elif count > 50:
count = 50
current_time = datetime.now()
end_date = (current_time + timedelta(days=1)).strftime("%Y-%m-%d")
pattern = r'\d{4}-\d{2}-\d{2}to\d{4}-\d{2}-\d{2}'
if "freshness" in parse_data:
if parse_data["freshness"] in ["pd", "pw", "pm", "py"]:
if parse_data["freshness"] == "pd":
start_date = (current_time - timedelta(days=1)).strftime("%Y-%m-%d")
if parse_data["freshness"] == "pw":
start_date = (current_time - timedelta(days=6)).strftime("%Y-%m-%d")
if parse_data["freshness"] == "pm":
start_date = (current_time - timedelta(days=30)).strftime("%Y-%m-%d")
if parse_data["freshness"] == "py":
start_date = (current_time - timedelta(days=364)).strftime("%Y-%m-%d")
search_filter = {"range": {"page_time": {"gte": start_date, "lt": end_date}}}
elif re.match(pattern, parse_data["freshness"]):
start_date = parse_data["freshness"].split("to")[0]
end_date = parse_data["freshness"].split("to")[1]
search_filter = {"range": {"page_time": {"gte": start_date, "lt": end_date}}}
else:
print(f"Error: freshness ({parse_data['freshness']}) must be pd, pw, pm, py, or match {pattern}.")
sys.exit(1)
# We will pass these via env vars for security
api_key = os.getenv("BAIDU_API_KEY")
if not api_key:
print("Error: BAIDU_API_KEY must be set in environment.")
sys.exit(1)
request_body = {
"messages": [
{
"content": parse_data["query"],
"role": "user"
}
],
"search_source": "baidu_search_v2",
"resource_type_filter": [{"type": "web", "top_k": count}],
"search_filter": search_filter
}
try:
results = baidu_search(api_key, request_body)
print(json.dumps(results, indent=2, ensure_ascii=False))
except Exception as e:
print(f"Error: {str(e)}")
sys.exit(1)