
🔍 🔍 🔍
📌 一、朱雀大模型检测 API 概述
📌 二、注册与认证
🔑 1. 获取 API 密钥
- 访问朱雀 AI 检测助手官网(https://matrix.tencent.com/ai-detect),点击 “开发者中心” 进行注册。
- 登录后,在个人中心申请 API 密钥。每个账号每日可免费调用 20 次文本检测和 20 次图片检测,超出部分需付费。
🔒 2. 身份认证
- 在 API 请求中,需通过 HTTP 头携带 API 密钥:
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
- 确保密钥安全,避免泄露导致滥用。
📌 三、文本检测 API 调用
📄 1. 请求参数
- 必填参数:
content
:待检测的文本内容,最大长度不超过 10000 字。type
:检测类型,固定为 “text”。
- 可选参数:
model
:指定检测模型,默认为 “zhque-ai-detect-v1”。sensitive
:敏感度调整,取值 0-1(0 为宽松,1 为严格)。
🚀 2. 代码示例(Python)
import requests
url = "https://api.matrix.tencent.com/ai-detect/text"
api_key = "YOUR_API_KEY"
text = "这是一段待检测的文本内容。"
payload = {
"content": text,
"type": "text",
"sensitive": 0.8
}
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
result = response.json()
print("AI生成概率:", result["probability"])
print("检测结果:", "AI生成" if result["is_ai"] else "人工创作")
📊 3. 响应解析
- 成功响应:
{
"code": ,
"message": "success",
"data": {
"probability": 0.92,
"is_ai": true,
"model": "gpt-4"
}
}
- 字段说明:
probability
:AI 生成概率,取值 0-1。is_ai
:是否为 AI 生成(true/false)。model
:推测的生成模型(如 gpt-4、midjourney 等)。
📌 四、图片检测 API 调用
🖼️ 1. 请求参数
- 必填参数:
image
:待检测的图片文件,支持 JPG、PNG 格式,大小不超过 5MB。type
:检测类型,固定为 “image”。
- 可选参数:
mode
:检测模式,“normal”(常规)或 “strict”(严格)。
🚀 2. 代码示例(Python)
import requests
url = "https://api.matrix.tencent.com/ai-detect/image"
api_key = "YOUR_API_KEY"
image_path = "test.jpg"
with open(image_path, "rb") as f:
files = {"image": f}
headers = {
"Authorization": f"Bearer {api_key}"
}
response = requests.post(url, files=files, headers=headers)
result = response.json()
print("AI生成概率:", result["probability"])
print("检测结果:", "AI生成" if result["is_ai"] else "人工创作")
📊 3. 响应解析
- 成功响应:
{
"code": ,
"message": "success",
"data": {
"probability": 0.86,
"is_ai": true,
"model": "midjourney-v5"
}
}
📌 五、错误处理与优化
⚠️ 1. 常见错误代码
401 Unauthorized
:API 密钥无效或未提供。429 Too Many Requests
:超出每日免费额度,需升级套餐。500 Internal Server Error
:服务器内部错误,重试或联系技术支持。
🛠️ 2. 优化技巧
- 批量检测:对于大量内容,可分批调用 API,避免超时。
- 重试机制:在代码中添加重试逻辑,处理网络波动:
import requests
from tenacity import retry, stop_after_attempt, wait_exponential
@retry(stop=stop_after_attempt(), wait=wait_exponential(multiplier=, min=, max=))
def call_api(url, payload, headers):
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
return response.json()
- 敏感度调整:根据需求调整
sensitive
参数,平衡准确性和误判率。
📌 六、应用场景与案例
🏥 1. 新闻媒体验证
📱 2. 社交媒体审核
📚 3. 学术论文筛查
📌 七、安全提示
- 数据隐私:确保用户数据传输和存储安全,遵守《生成式人工智能服务管理暂行办法》。
- 防范攻击:避免恶意调用,对请求来源进行 IP 白名单限制。
📌 八、总结
🔗立即免费注册 开始体验工具箱 - 朱雀 AI 味降低到 0%- 降 AI 去 AI 味