跳到正文
DEV Community· Stephen Harmston·· 4 天前AI 評分48

AI Aware detection API:用一個 API 檢測文字、圖片、影片及音訊是否由 AI 生成

Checking text, images, video and audio for AI with one API

AI 導讀

AI Aware detection API 以一個 API 檢測文字、圖片、影片及音訊是否由 AI 生成。最新測試中,圖片及影片檢測準確率為 99.4%,文字為 98.6%,音訊為 97.6%。檢測以非同步方式執行,提交內容後會即時取得工作 ID,並可輪詢結果。

正文

Stephen Harmston

If your product takes in content from users, sooner or later someone asks: was this made by AI? Essays, CVs, profile photos, voice notes, video clips. Most detection tools only cover one of these, so you end up wiring together three or four services.

We built the AI Aware detection API so one key covers all four. It runs the same detectors as our website: text, images, video and audio.

How it works

Every check is asynchronous. You submit the content, get a job ID straight back, then poll until the result is ready. Most text checks finish within seconds, while long documents and videos can take a few minutes.

curl -s https://aidetector.aiaware.io/api/v1/public/text \
  -H "X-API-Key: $AIAWARE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Paste the text you want to check here."}'

The same thing in Python:

import os, time, requests

BASE = "https://aidetector.aiaware.io/api/v1/public"
HEADERS = {"X-API-Key": os.environ["AIAWARE_API_KEY"]}

def check_text(text, timeout=600):
    r = requests.post(f"{BASE}/text", json={"text": text}, headers=HEADERS)
    r.raise_for_status()
    job = r.json()
    deadline = time.time() + timeout
    while time.time() < deadline:
        body = requests.get(job["poll_url"], headers=HEADERS).json()
        if body["status"] != "processing":
            return body
        time.sleep(3)
    raise TimeoutError(job["job_id"])

result = check_text(open("essay.txt").read())
print(result["result"]["verdict"], result["result"]["ai_share"])

What you get back

For text, you get more than a single score. The result marks which passages look AI-written, as character offsets into the text. That matters, because a lot of real documents are mixed: a person writes most of it and pastes in one AI paragraph. A max_segment_score field flags documents with a single suspicious passage.

Images, video and audio go to one /media endpoint, as a file upload or a public URL. Each comes back with a score from 0 to 100 and a verdict. For video, you can check the picture and the sound together in one call.

How accurate is it?

On our latest tests the detectors scored 99.4% on images and video, 98.6% on text and 97.6% on audio. The full method and results are published here: AI detector accuracy: technical results

Try it

Keys, prices, limits and error codes are all on the API page: AI Aware detection API

We'd like to hear what developers need from an API like this.

來源:DEV Community · dev.to