Sapling Logo
AI detector quickstart

Python AI Detector

Analyze text from a Python application and receive document- and sentence-level AI detection scores.

  • HTTPS POST
  • SDK + HTTP
  • API key required
POST Python logo Python /api/v1/aidetect

Python AI detector quickstart

Send at least 150 characters for a more reliable signal. The response score ranges from 0 (more likely human-written) to 1 (more likely AI-generated); use it as evidence, not proof.

Sapling provides an SDK for this stack. The direct HTTP example below remains useful for server-side integrations; see the SDK overview for the higher-level client.
Python /api/v1/aidetect
import os
from pprint import pprint

import requests

api_key = os.environ["SAPLING_API_KEY"]
response = requests.post(
    "https://api.sapling.ai/api/v1/aidetect",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
        "text": (
            "I am an artificial intelligence system designed to help people solve complex problems. "
            "My capabilities include natural language processing, machine learning, and predictive analytics."
        ),
        "sent_scores": True,
    },
    timeout=30,
)
response.raise_for_status()
pprint(response.json())
Example response application/json
{
  "score": 0.9989,
  "sentence_scores": [
    {
      "score": 0.9764,
      "sentence": "I am an artificial intelligence system designed to help people solve complex problems."
    },
    {
      "score": 0.9812,
      "sentence": "My capabilities include natural language processing, machine learning, and predictive analytics."
    }
  ],
  "text": "I am an artificial intelligence system designed to help people solve complex problems. My capabilities include natural language processing, machine learning, and predictive analytics."
}

The overall score and sentence scores use different methods and may not match exactly. Choose thresholds based on the false-positive and false-negative costs of your use case.

About Python

Python is a high-level interpreted general-purpose scripting language that ranks as one of the most popular programming languages. It is designed to be readable and uses indentation as part of its syntax. The reference implementation, CPython is written in both C and Python, which provides the performance characteristics of C for computationally expensive number-crunching tasks.