AI 检测 API

使用 GPTZero AI 检测模型检测文本或文件中的 AI 生成内容。返回文档级别分类(human / mixed / ai)、置信度评分,以及每个句子和段落的 AI 生成概率。

POST/v1/ai-detect/*

检测文本

POST/v1/ai-detect/detect-text

提交一段文本,使用 GPTZero AI 检测模型分析其由 AI 生成的概率。返回文档级别的分类结果(human / mixed / ai)、置信度,以及每个句子和段落的 AI 生成概率。文本最多支持 50,000 个字符。

参数

参数类型必填描述
documentstring必填待检测的文本内容(最多 50,000 个字符)
multilingualboolean可选 (默认: false)启用多语言检测支持

响应

Response
{
  "success": true,
  "message": "AI detection completed successfully",
  "version": "2025-01-15-base",
  "scan_id": "abc123-def456",
  "document": {
    "average_generated_prob": 0.85,
    "completely_generated_prob": 0.78,
    "class_probabilities": {
      "ai": 0.85,
      "human": 0.1,
      "mixed": 0.05
    },
    "predicted_class": "ai",
    "document_classification": "AI_ONLY",
    "confidence_category": "high",
    "confidence_score": 0.92,
    "result_message": "Your text is likely AI-generated",
    "sentences": [
      {
        "sentence": "The development of artificial intelligence has revolutionized many fields.",
        "generated_prob": 0.95,
        "perplexity": 12,
        "highlight_sentence_for_ai": true
      }
    ],
    "paragraphs": [
      {
        "completely_generated_prob": 0.88,
        "num_sentences": 5,
        "start_sentence_index": 0
      }
    ]
  }
}

检测文件

POST/v1/ai-detect/detect-files

上传一个或多个文件(支持 .txt、.docx、.pdf),使用 GPTZero AI 检测模型分析每个文件中内容由 AI 生成的概率。最多支持 50 个文件,总大小不超过 15 MB。每个文件内容最多分析 50,000 个字符。

参数

参数类型必填描述
filesarray<file>必填待检测的文件列表(支持 .txt、.docx、.pdf,最多 50 个文件)

响应

Response
{
  "success": true,
  "message": "AI detection completed for 2 files",
  "version": "2025-01-15-base",
  "scan_id": "abc123-def456",
  "documents": [
    {
      "average_generated_prob": 0.72,
      "completely_generated_prob": 0.65,
      "overall_burstiness": 45.3,
      "class_probabilities": {
        "ai": 0.72,
        "human": 0.18,
        "mixed": 0.1
      },
      "predicted_class": "ai",
      "document_classification": "AI_ONLY",
      "confidence_category": "high",
      "confidence_score": 0.88,
      "result_message": "Your text is likely AI-generated",
      "sentences": [
        {
          "sentence": "Machine learning models have shown remarkable performance.",
          "generated_prob": 0.91,
          "perplexity": 15,
          "highlight_sentence_for_ai": true
        }
      ],
      "paragraphs": [
        {
          "completely_generated_prob": 0.8,
          "num_sentences": 4,
          "start_sentence_index": 0
        }
      ]
    }
  ]
}

响应

Response
{
  "success": true,
  "message": "AI detection completed successfully",
  "version": "2025-01-15-base",
  "scan_id": "abc123-def456",
  "document": {
    "average_generated_prob": 0.85,
    "completely_generated_prob": 0.78,
    "class_probabilities": {
      "ai": 0.85,
      "human": 0.1,
      "mixed": 0.05
    },
    "predicted_class": "ai",
    "document_classification": "AI_ONLY",
    "confidence_category": "high",
    "confidence_score": 0.92,
    "result_message": "Your text is likely AI-generated",
    "sentences": [
      {
        "sentence": "The development of artificial intelligence has revolutionized many fields.",
        "generated_prob": 0.95,
        "perplexity": 12,
        "highlight_sentence_for_ai": true
      }
    ],
    "paragraphs": [
      {
        "completely_generated_prob": 0.88,
        "num_sentences": 5,
        "start_sentence_index": 0
      }
    ]
  }
}

示例

import requests

API_KEY = "your_api_key_here"
BASE_URL = "https://api.qinyanai.com"

# Detect text AI probability
response = requests.post(
    f"{BASE_URL}/v1/ai-detect/detect-text",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={
        "document": "The development of artificial intelligence has revolutionized many fields...",
        "multilingual": False
    }
)
print(response.json())

# Detect files AI probability
with open("paper.pdf", "rb") as f:
    response = requests.post(
        f"{BASE_URL}/v1/ai-detect/detect-files",
        headers={"Authorization": f"Bearer {API_KEY}"},
        files=[("files", ("paper.pdf", f, "application/pdf"))]
    )
print(response.json())