← Back to Skills Marketplace
heke-uestc

Baidu Content Censor

by HeKe-UESTC · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
151
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install baidu-content-censor
Description
提供文本和图像内容安全检测,自动识别类型并返回详细审核结果,支持本地图片路径和图片 URL 输入。
README (SKILL.md)

百度内容审核 (baidu-content-censor)

概述

本 Skill 提供文本审核和图像审核两个 API 接口,用于内容安全检测。

触发方式

当用户请求以下操作时,自动调用此 Skill:

  • 文本审核 / 内容审核 / 文字审核
  • 图片审核 / 图像审核 / 图片检测
  • 内容安全检测
  • 敏感词检测 / 违规内容检测
  • 审核这段文字 / 审核这张图片
  • "帮我审核..." / "请审核..." / "检测一下..."

执行指令

当触发此 Skill 时:

  1. 识别用户是要审核文本还是图片
  2. 如果是文本审核:调用 api_client.text_censor(text="...")
  3. 如果是图片审核:
    • 如果用户提供的是本地图片路径,调用 api_client.image_censor(image="/path/to/image.jpg")
    • 如果用户提供的是图片 URL,调用 api_client.image_censor(img_url="https://...")
  4. 解析返回的 JSON 结果,以友好的方式展示给用户
  5. access_token 会自动从 AK/SK 获取并缓存,无需手动处理

接口地址

  • 文本审核: https://aip.baidubce.com/rest/2.0/solution/v1/text_censor/v2/user_defined
  • 图像审核: https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined

环境变量

变量名 必填 说明
BCE_SINAN_AK 百度云 API Key
BCE_SINAN_SK 百度云 Secret Key

设置方式:

export BCE_SINAN_AK="你的AK"
export BCE_SINAN_SK="你的SK"

Token 缓存机制

  • Access Token 会自动从百度云 API 获取
  • 缓存文件位置:~/.claude/skills/baidu-content-censor/token_cache.json
  • 缓存过期时间:提前 5 分钟自动刷新
  • 如果 API 返回 110(access_token 无效)或 111(access_token 过期),会自动刷新并重试

API 使用方法

1. 文本审核

from baidu-content-censor import text_censor

# 审核文本
result = text_censor(text="待审核的文本内容")

# 也可以指定 appid
result = text_censor(text="待审核的文本内容", appid=123456)

2. 图像审核

from baidu-content-censor import image_censor

# 方式一:通过图片 URL 审核
result = image_censor(img_url="https://example.com/image.jpg")

# 方式二:通过本地图片路径审核(自动转为 Base64)
result = image_censor(image="/path/to/image.jpg")

# 也可以指定 appid
result = image_censor(img_url="https://example.com/image.jpg", appid=123456)

3. 通用接口(自动识别类型)

from baidu-content-censor import censor

# 自动识别为文本
result = censor("待审核的文本内容")

# 自动识别为图片(URL)
result = censor("https://example.com/image.jpg")

# 自动识别为图片(本地路径)
result = censor("/path/to/image.jpg")

# 手动指定类型
result = censor("待审核的文本内容", content_type="text")
result = censor("/path/to/image.jpg", content_type="image")

4. 强制刷新 Token

from baidu-content-censor import refresh_access_token

# 强制刷新 access_token(清除缓存并重新获取)
new_token = refresh_access_token()

返回结果

接口返回完整的 JSON 审核结果,包含以下常见字段:

字段 类型 说明
logId long 请求唯一标识
conclusion string 审核结论(如:合规、不合规、疑似)
conclusionType int 结论类型(1:合规, 2:不合规, 3:疑似, 4:审核失败)
data array 详细审核数据

注意事项

  1. imageimg_url 只能传其中一个,不能同时传递
  2. 文本审核内容不能超过 2 万字节
  3. 所有请求都会自动添加 isFromSkill=true 参数用于埋点
  4. 本地图片路径会自动转换为 Base64,无需手动处理
  5. Access Token 缓存机制确保性能最优,不会频繁请求百度云获取 token
Usage Guidance
This skill appears to do what it says: it calls Baidu's OAuth endpoint and the Baidu content-censor APIs and requires your Baidu AK/SK. Before installing: 1) only provide AK/SK you intend to use with Baidu; don't use broader or unrelated credentials; 2) be aware that any local file path you pass will be read and uploaded (Base64) to Baidu — avoid passing sensitive local files; 3) ensure your runtime has Python and the 'requests' library (the skill's metadata does not declare dependencies); 4) note the skill writes a token cache to ~/.claude/skills/... — if you prefer no on-disk caching, inspect/modify the code; 5) the package source/homepage is unknown — if you need stronger assurance, review the included code yourself or run it in a sandbox before granting credentials or using on sensitive data.
Capability Analysis
Type: OpenClaw Skill Name: baidu-content-censor Version: 1.0.0 The skill is a legitimate implementation of Baidu's content censorship API for text and image moderation. It correctly handles OAuth2 authentication, implements a local token caching mechanism in `api_client.py`, and provides clear instructions in `SKILL.md` for the AI agent. No evidence of data exfiltration, malicious execution, or intentional prompt injection was found; the code's behavior is entirely consistent with its stated purpose of auditing content via Baidu's official endpoints.
Capability Assessment
Purpose & Capability
Name/description (Baidu content censor) match the actual behavior: the code calls Baidu OAuth and the Baidu text/image censor endpoints and requires Baidu AK/SK environment variables. No unrelated services or credentials are requested.
Instruction Scope
SKILL.md and the code instruct the agent to read environment variables for AK/SK, obtain an access token, and POST text or image data to Baidu endpoints. The skill will read local files when given a local image path and convert them to Base64 for upload — this is expected for image auditing but is a privacy consideration (local files are uploaded to Baidu). The code also adds an isFromSkill=true param to all requests for tracking. Instructions are otherwise narrowly scoped to the censorship task.
Install Mechanism
No install specification is provided (instruction-only install), but code files are included. The Python client imports the third-party 'requests' package yet the registry metadata does not declare dependencies; the runtime environment must have Python and requests available. No external download URLs or archive extraction are used.
Credentials
Only BCE_SINAN_AK and BCE_SINAN_SK are required, which is appropriate for obtaining Baidu access tokens. No other secrets, unrelated credentials, or broad system config paths are requested.
Persistence & Privilege
The skill caches the access token to a file under ~/.claude/skills/baidu-content-censor/token_cache.json and will create that directory if missing — this is reasonable for token caching but means the skill will write into the user's home directory. always is false and the skill does not modify other skills or global agent settings.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install baidu-content-censor
  3. After installation, invoke the skill by name or use /baidu-content-censor
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
baidu-content-censor 1.0.0 - Initial release with API support for both text and image content moderation using Baidu Cloud. - Supports automatic trigger on various user audit requests (text/image/content/security). - Provides Python API for text_censor, image_censor, universal censor, and manual access_token refresh. - Implements automatic access_token management and caching for optimal performance. - Returns detailed JSON audit results, including compliance conclusions and data. - Requires setting Baidu API Key and Secret Key via environment variables.
Metadata
Slug baidu-content-censor
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Baidu Content Censor?

提供文本和图像内容安全检测,自动识别类型并返回详细审核结果,支持本地图片路径和图片 URL 输入。 It is an AI Agent Skill for Claude Code / OpenClaw, with 151 downloads so far.

How do I install Baidu Content Censor?

Run "/install baidu-content-censor" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Baidu Content Censor free?

Yes, Baidu Content Censor is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Baidu Content Censor support?

Baidu Content Censor is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Baidu Content Censor?

It is built and maintained by HeKe-UESTC (@heke-uestc); the current version is v1.0.0.

💬 Comments