AI Detector
The endpoint computes the probability that a piece of text is AI-generated, as well as the probability that each constituent sentence and token is AI-generated.
All AI detection systems have false positives and false negatives. In some cases, small modifications to AI-generated text can cause that text to no longer be flagged as AI-generated. In other cases, human-written (but perhaps rote) text can be misclassified as AI-generated. Depending on the application, false positives or false negatives may be less desirable. Contact us for ways to adjust for your use case.
Sample Code
- cURL
- JavaScript
- Python
- Python SDK
curl -X POST https://api.sapling.ai/api/v1/aidetect \
-H "Content-Type: application/json" \
-d '{"key":"<api-key>", "text":"This is sample text."}'
import axios from 'axios';
async function run(text) {
try {
const response = await axios.post(
'https://api.sapling.ai/api/v1/aidetect',
{
key: '<api-key>',
text,
},
);
const {status, data} = response;
console.log({status});
console.log(JSON.stringify(data, null, 4));
} catch (err) {
const { msg } = err.response.data;
console.log({err: msg});
}
}
run('This is sample text'); // replace with the text you want to analyze
import requests
from pprint import pprint
response = requests.post(
"https://api.sapling.ai/api/v1/aidetect",
json={
"key": "<api-key>",
"text": "This is sample text."
}
)
pprint(response.json())
# python -m pip install sapling-py
from sapling import SaplingClient
from pprint import pprint
api_key ='<api-key>'
client = SaplingClient(api_key=api_key)
detection_scores = client.aidetect('This is sample text.', sent_scores=True)
pprint(detection_scores)
Sapling's Javascript SDK provides a complete end-to-end UI integration for AI content detection capabilities. Head over to our AI Detect JavaScript Quickstart for more details.
AI Detector POST
Request Parameters
https://api.sapling.ai/api/v1/aidetect
HTTP method: POST
The AI Detector API POST endpoint takes JSON parameters documented below:
key: String
32-character API key.
text: String
Text to run detection on. The limit is currently 8000 characters. Please contact
us if you need to run the system on longer inputs.
We can also provide suggestions on how to chunk your text into smaller pieces
and then combine detection results.
sent_scores: Boolean
Whether to return sentence scores. Defaults to true
. If speed is of the essence,
you can disable this setting.
version: String
There are currently 2 versions of the detector available
20231024
(default)20230317
While we have found the default to be more performant, you may wish to use the older version to ensure consistency in your application.
Response Parameters
A score
from 0 to 1 be returned, with 0 indicating the maximum
confidence that the text is human-written, and 1 indicating the maximum confidence that the text is AI-generated.
A field sentence_scores
containing scores for each sentence will also be returned.
The per-sentence scores may not correlate with the overall score
field as they're computed using a different method from the overall score.
The AI Detector POST endpoint returns JSON of the following format:
{
"score": 0.98,
"sentence_scores": [
{
"sentence": "Here is a sentence.",
"score": 0.999
}
]
}