AI Detector API
Sapling's AI detector API computes the probability that a piece of text is AI-generated (sometimes called "AI slop"), as well as the probability that each constituent sentence and token is AI-generated. Use this AI detection API to flag machine-generated content in user submissions, marketplace listings, reviews, job applications, student work, and content pipelines — or as an AI slop detector API for identifying low-quality, machine-generated content.
The system is trained to be able to handle LLMs from different vendors, such as OpenAI's GPT family of models, Google's Gemini models, Anthropic's Claude models, and the open-release Llama and Mistral models. It is also somewhat robust to small changes and noisy text.
| AI detection API | At a glance |
|---|---|
| Endpoint | POST https://api.sapling.ai/api/v1/aidetect |
| Returns | Document score from 0 to 1, per-sentence scores, per-token probabilities, and an optional HTML heatmap |
| Input limits | Up to 200,000 characters per request; at least 300 characters recommended |
| Languages | English |
| SDKs | Python, JavaScript |
| Pricing | From $0.005 per 1,000 characters, with volume discounts — see API Pricing |
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. Please do not interpret this as conclusive belief that your text is AI slop. Depending on the application, false positives or false negatives may be less desirable. Contact us for ways to adjust for your use case.
Quickstart
- Register for a Sapling account and generate a key from your API settings dashboard. See API Access for the full walkthrough.
POSTyour text tohttps://api.sapling.ai/api/v1/aidetectwith your key, using one of the samples below.- Read
scorefrom the response — closer to1means more confidence the text is AI-generated — and usesentence_scoresortoken_probsto show where in the text that confidence comes from.
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."
}
)
if 200 <= response.status_code < 300:
pprint(response.json())
else:
print('Error: ', response.status_code, response.text)
# pip: python -m pip install sapling-py
# uv: uv add 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. Can also be supplied via the Authorization header as a bearer token; if both are provided, the key parameter takes precedence.
text: String
Text to run detection on. The limit is currently 200,000 characters.
If latency is high or requests time out, we recommend adapting
this script.
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.
Provide exactly one of text and texts.
texts: List[String]
Batch form (see Batch Requests): 1–10 texts to run detection on in one request,
each scored independently under the same options.
sent_scores: Boolean
Whether to return sentence scores. Defaults to true. If speed is of the essence,
you can disable this setting.
score_string: Boolean
Whether to return string highlighting token-level scores. Defaults to false.
This allows you to visualize which portions of the text are likely AI-generated
similar to on Sapling's AI detector page.
version: String
There are currently 3 versions of the detector available:
20240606(only available upon request)20251027(previous default; available by specifying this version)20260820(current default)
September 17, 2026 default-model upgrade
The default AI Detector model was upgraded to version 20260820 on September 17,
2026.
The upgrade brings higher precision on modern text and better recall on humanized AI text. In our internal held-out evaluations, human-text false positives fell by 60% on the modern-text set, while detection of humanized AI text improved by 3.9% absolute. We've also refreshed training data from recent ChatGPT, Claude, Gemini, DeepSeek, and Qwen models, and added Kimi coverage.
Requests that omit the version parameter use the new model. To keep using the
previous model, include "version": "20251027" in each request.
Response Parameters
The AI Detector POST endpoint returns JSON of the following format:
{
"score": 0.8016229165451867,
"sentence_scores": [
{
"score": 1.1537837352193492e-10,
"sentence": "Here is a sentence."
}
],
"text": "Here is a sentence.",
"token_probs": [
0.8062431365251541,
0.8068526238203049,
0.8062431365251541,
0.8080672174692154,
0.8062431365251541
],
"tokens": [
"Here",
" is",
" a",
" sentence",
"."
]
}
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.
If score_string is set to true, a score_string field will be provided.
The field contains an HTML string with a heatmap
of the portions of the text that are predicted to be AI-generated.
If the default score string is not what you desire, you can generate your own
using tokens and token_probs.
If the flag is set, 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.
tokens: List of tokens from backend tokenizer that can be used to token_probs to visualize the output prediction per token.
token_probs: List of probabilities that each token is AI-generated. This can be used with tokens to visualize the output prediction per token.
Batch Requests
To score many texts — a queue of submissions, a page of reviews — in one request, send texts
(a list of 1–10 strings) instead of text. The same sent_scores, score_string, and version
options apply to every item. Exactly one of text and texts must be provided, and the
combined length of all items may be up to 200,000 characters (the same cap as a single text).
curl -X POST https://api.sapling.ai/api/v1/aidetect \
-H "Content-Type: application/json" \
-d '{"key":"<api-key>", "texts": ["First submission to check.", "Second submission to check."], "sent_scores": false}'
The batch response is {"results": [...]} with one entry per input, in input order; each entry has
exactly the single-response shape above (sentence_scores, tokens, and token_probs are relative
to that item's own text):
{
"results": [
{"score": 0.93, "text": "First submission to check.", "tokens": ["..."], "token_probs": [0.9]},
{"score": 0.04, "text": "Second submission to check.", "tokens": ["..."], "token_probs": [0.1]}
]
}
Each item is scored independently and billed individually (a batch of N costs the same as N single requests, and identical items are billed once). If any item fails, the whole request returns an error and nothing is billed; items that did resolve are cached, so a retry only re-scores the rest. The batch form requires an API key.
Interpreting the score
The detector is a probability estimate, not a verdict. How you turn score into a decision
depends on which kind of mistake is more costly in your application:
- A high threshold (for example, only act above
0.9) minimizes false accusations, at the cost of letting more AI-generated text through. This is usually the right default when a flag has consequences for a person — moderation, admissions, hiring. - A lower threshold surfaces more candidates for human review. This suits content pipelines where a flag just means "route to an editor".
- Sentence scores are useful for review workflows: a document that is mostly human-written with a few AI-generated paragraphs looks different from one that is uniformly AI-generated, even when the two share an overall score.
Note that per-sentence scores are computed by a different method from the overall score, so they will not always average out to it. Contact us if you need help calibrating thresholds against your own labelled data.
Limits, quotas, and pricing
- Input length: up to 200,000 characters per request. At least 300 characters is recommended — it is possible to classify shorter text, but there is much less signal to work with.
- Free quota: new API keys get 50,000 characters/day and 250,000 characters/month. See Usage and Pricing.
- Rate limits: 120,000 characters every 2 minutes for this endpoint, plus the daily and monthly
quotas above. See Rate Limits; status code
429indicates a rate limit error. - Caching: AI detection results are cached on the entire text for 3 days, so re-sending an identical document does not incur additional usage. See API Pricing.
- Billing: usage-based, per character, starting at $0.005 per 1,000 characters with volume discounts. See API Pricing.
Tips
- Check the status code of the result and any error logs.
- Unless you're sending very large requests, the requests should rarely fail or time out, but you can follow these instructions to implement a retry mechanism.
Checking Files (PDF/DOCX)
Sometimes you may wish to send the API PDFs or DOCX files.
To do this, refer to the Files documentation to see how you can extract text from files before passing the text to the API. These endpoints are currently provided free-of-charge; however, if you plan to use them for high-volumes of text, contact us and ensure you're using one of the other endpoints or we may limit usage to reduce server load.
Other ways to use Sapling's AI detection
Beyond calling the HTTP API directly, the same detector is available through:
- JavaScript SDK — a drop-in UI that adds an AI
detection button to any
textareaorcontenteditablein your web app. - Python SDK — the
sapling-pypackage wraps the endpoint asclient.aidetect(...). - Sapling MCP Server — exposes AI detection as a tool to Claude and other MCP-compatible assistants.
- Sapling's AI content detector — the hosted web app, useful for spot checks and for comparing against your own integration.
If you are still evaluating vendors, Sapling maintains a comparison of the top AI detection APIs.
Frequently asked questions
What is an AI detection API?
An AI detection API is an HTTP endpoint that takes text as input and returns a score estimating how likely that text was generated by a large language model rather than written by a person. Sapling's AI detector API returns a document-level score from 0 to 1, plus optional per-sentence and per-token scores so you can see which passages drive the result.
Which AI models can the detector identify?
The detector is trained across LLMs from different vendors, including OpenAI's GPT family, Google's Gemini models, Anthropic's Claude models, and the open-release Llama and Mistral models. It does not name which model produced the text; it returns the probability that the text is AI-generated.
How much text does the AI detector API need?
At least 300 characters is recommended. Shorter inputs carry much less signal, so scores on them are less reliable. A single request accepts up to 200,000 characters.
How accurate is AI detection?
Every AI detection system has false positives and false negatives. Small edits to AI-generated text can keep it from being flagged, and human-written but rote text is sometimes misclassified as AI-generated. Treat the score as a signal to review rather than as proof, and contact us to tune thresholds for your use case.
Does the AI detector API support languages other than English?
The AI detector is currently trained for English only. You can use Sapling's language detection endpoint to route non-English text elsewhere in your pipeline.
Can I run AI detection on PDF or DOCX files?
Yes. Extract the text with Sapling's PDF-to-text or DOCX-to-text endpoints, then pass the extracted text to the AI detection endpoint.
Is there a free tier for the AI detection API?
Yes. A new API key comes with a free quota of 50,000 characters per day and 250,000 characters per month, which is enough to evaluate the detector before subscribing. Paid usage is billed per character with volume discounts — see API Pricing.