APIドキュメント
ISO 27001SOC 2 CertifiedGDPR Compliant

AIテキスト検出API

TruthScanのAI検出APIをアプリケーションに統合するための完全なドキュメントです。

コードを書かずに試すには、以下のFastAPIエンドポイントをご利用ください: https://detect-text.truthscan.com/docs

認証

TruthScanではAPIアクセスにAPIキーを使用します。APIキーは 開発者ポータルのページ上部.

すべてのAPIリクエストにAPIキーを含める必要があります:

{
  "key": "YOUR API KEY GOES HERE"
}

YOUR API KEY GOES HERE を実際のAPIキーに置き換えてください。

WebSocketを使用する場合は、URLにOrganization IDを含める必要があります。Organization IDは 開発者ポータルのページ上部.

すべてのWebSocketリクエストにOrganization IDを含める必要があります:

wss://detect-text.truthscan.com/ws/$ORG_ID

$ORG_ID を実際のOrganization IDに置き換えてください。

AI検出

検出

このエンドポイントではテキストを送信してAI検出を行います。精度向上のため200語以上を推奨します。

POST https://detect-text.truthscan.com/detect

閾値

resultスコアは1〜100で返されます。50未満は人間、50〜60はAIの可能性、60以上はAIと判断されます。

他の検出器のスコアは参考値であり、主要なresultスコアほど正確ではありません。

改行

JSON送信時は改行を \n としてエンコードしてください。

リクエスト例

curl -X 'POST' \
  'https://detect-text.truthscan.com/detect' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "On Citizen science\nCitizen science involves the public participating in scientific research. This can take many forms, collecting data on local wildlife populations to analyzing astronomical images. Citizen science projects allow researchers to gather large amounts of data and engage the public in the process. By participating, individuals contribute to valuable research while gaining a deeper understanding of the scientific world around them.",
  "key": "YOUR-API-KEY-GOES-HERE",
  "model": "xlm_ud_detector",
  "retry_count": 0
}'

入力は30,000語未満である必要があります。

レスポンス例

{
    "id": "77565038-9e3d-4e6a-8c80-e20785be5ee9",
    "input": "Citizen science involves the public participating in scientific research. This can take many forms, collecting data on local wildlife populations to analyzing astronomical images. Citizen science projects allow researchers to gather large amounts of data and engage the public in the process. By participating, individuals contribute to valuable research while gaining a deeper understanding of the scientific world around them.",
    "model": "xlm_ud_detector",
    "result": null,
    "result_details": null,
    "status": "pending",
    "retry_count": 0
}

レスポンスにはドキュメントIDが含まれます。処理には通常2〜4秒かかります。

クエリ

ドキュメントIDを使用してステータスと検出結果を取得します。

POST https://detect-text.truthscan.com/query

リクエスト例

curl -X 'POST' \
  'https://detect-text.truthscan.com/query' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "id": "DOCUMENT-ID-GOES-HERE"
}'

レスポンス例

{
    "id": "77565038-9e3d-4e6a-8c80-e20785be5ee9",
    "model": "xlm_ud_detector",
    "result": 12.0,
    "result_details": {
        "scoreGptZero": 50.0,
        "scoreOpenAI": 0.0,
        "scoreWriter": 0.0,
        "scoreCrossPlag": 0.0,
        "scoreCopyLeaks": 50.0,
        "scoreSapling": 0.0,
        "scoreContentAtScale": 0.0,
        "scoreZeroGPT": 50.0,
        "human": 88.0
    },
    "status": "done",
    "retry_count": 0
}

result値が低いほど人間による文章である可能性が高いことを示します。

クレジット確認

APIキーで残りクレジットを取得します。

GET https://detect-text.truthscan.com/check-user-credits

リクエスト例

curl -X 'GET' \
  'https://detect-text.truthscan.com/check-user-credits' \
  -H 'apikey: YOUR API KEY GOES HERE' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json'

レスポンス例

{
    "baseCredits": 10000,
    "boostCredits": 1000,
    "credits": 11000
}

文単位AI検出

文単位検出はWebSocketベースで動作します。

必要な手順:

  • WebSocket接続
  • イベント受信
  • document_watch送信
  • document_id受信
  • 検出リクエスト送信
  • 文単位結果受信
  • 完了イベント受信

WebSocket接続

接続を確立します。

wss://detect-text.truthscan.com/ws/$ORG_ID

コード例

ws = new WebSocket("wss://detect-text.truthscan.com/ws/1722238709737x2194626580942121212");

イベント受信

イベントを監視します。

コード例

ws.addEventListener("message", (event) => {
  console.log("Message from server ", event.data);
});

document_watch送信

検出準備を行います。

コード例

ws.send(JSON.stringify({
    "event_type": "document_watch",
    "api_key": "$API_KEY",
}))

document_id受信

IDが返されます。

レスポンス例

{
  "event_type": "document_id",
  "success": true,
  "document_id": "512da191-166926922-44cb-81c6-191ae3a807aa"
}

検出リクエスト送信

IDを使って送信します。

POST https://detect-text.truthscan.com/detect

リクエスト例

curl -X 'POST' \
  'https://detect-text.truthscan.com/detect' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "Citizen science involves the public participating in scientific research. This can take many forms, collecting data on local wildlife populations to analyzing astronomical images. Citizen science projects allow researchers to gather large amounts of data and engage the public in the process. By participating, individuals contribute to valuable research while gaining a deeper understanding of the scientific world around them.",
  "key": "YOUR-API-KEY-GOES-HERE",
  "model": "xlm_ud_detector",
  "id": "512da191-166926922-44cb-81c6-191ae3a807aa"
}'

結果受信

文ごとの結果を受信します。

レスポンス例

{
    "event_type": "document_chunk",
    "document_id": "512da191-166926922-44cb-81c6-191ae3a807aa",
    "model": "xlm_ud_detector",
    "chunk": "Citizen science involves the public in scientific research.",
    "result": 0.714
}

完了イベントが送信されます。

レスポンス例

{
    "event_type": "document_done",
    "document_id": "512da191-166926922-44cb-81c6-191ae3a807aa",
    "model": "xlm_ud_detector"
}

例外処理

エラー時はイベントが送信されます。

タイムアウト例

{
    "event_type": "document_error",
    "document_id": "512da191-166926922-44cb-81c6-191ae3a807aa",
    "error_code": "REQUEST_TIMEOUT",
    "message": "Request timeout. Took 20 seconds."
}

キャンセル

処理を停止できます。

document_haltを送信

レスポンス例

{
    "event_type": "document_halt",
    "document_id": "512da191-166926922-44cb-81c6-191ae3a807aa"
}

エラー

多くのエラーは不正なリクエストによるものです。

主なエラーコード:

コード内容
400不正なリクエスト
403認証エラーまたはクレジット不足
404リソース未存在
405無効なメソッド
406非対応フォーマット
410削除済み
422リクエスト形式エラー
429リクエスト過多
500サーバーエラー
503サービス停止中

よくある問題と解決策

認証の問題

"User verification failed" (403)

原因: APIキーが無効または期限切れです

解決策:

  1. APIキーが正しいことを確認してください
  2. アカウントでAPIキーが有効か確認してください
  3. 必要に応じてAPIキーを再発行してください

"Not enough credits" (403)

原因: テキスト処理のクレジットが不足しています

解決策:

  1. /check-user-credits で残りクレジットを確認してください
  2. 必要に応じてクレジットを追加購入してください
  3. より短いテキスト入力で消費を抑えてください

入力検証の問題

"Input text cannot be empty" (400)

原因: 空または空白のみのテキストが送信されました

解決策:

  1. テキスト入力が空でないことを確認してください
  2. 先頭・末尾の空白を削除してください
  3. テキストエンコーディングが正しいか確認してください

"Input email is empty" (400)

原因: URL処理にメールアドレスが不足しています

解決策:

  1. URL送信時に有効なメールアドレスを指定してください
  2. メール形式が正しいか確認してください

処理の問題

"Request timeout" (WebSocket)

原因: ドキュメント処理が長時間(120秒超)かかりました

解決策:

  1. より短いテキストで試してください
  2. サービスの負荷が高い可能性があります
  3. リクエストを再試行してください

ドキュメントステータス "failed"

原因: さまざまな理由で処理に失敗しました

解決策:

  1. 入力テキストが最低要件を満たしているか確認してください
  2. サポートされている形式か確認してください
  3. 別のモデルで試してください
  4. 解決しない場合はサポートにお問い合わせください

WebSocket接続の問題

接続が切断される

原因: ネットワークの問題またはサーバー切断

解決策:

  1. ネットワーク接続を確認してください
  2. 再接続ロジックを実装してください
  3. WebSocketのURLが正しいか確認してください

"User not found" (WebSocket)

原因: WebSocket接続のOrganization IDが無効です

解決策:

  1. Organization IDが正しいことを確認してください
  2. ユーザーアカウントが有効か確認してください
  3. 必要に応じて再認証してください

サポート

API利用についてはお問い合わせください。

FAQ

AI検出APIに関する質問