Perl 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.
No language-specific SDK is required. The example uses a standard or commonly used HTTP client to call Sapling's JSON API.
Perl
/api/v1/aidetect
This example uses LWP::UserAgent and JSON::MaybeXS.
use strict;
use warnings;
use HTTP::Request;
use JSON::MaybeXS qw(encode_json);
use LWP::UserAgent;
my $api_key = $ENV{SAPLING_API_KEY}
// die "Set SAPLING_API_KEY first.\n";
my $request = HTTP::Request->new(
POST => 'https://api.sapling.ai/api/v1/aidetect'
);
$request->header('Authorization' => "Bearer $api_key");
$request->header('Content-Type' => 'application/json');
$request->content(encode_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 => JSON::MaybeXS::true,
}));
my $response = LWP::UserAgent->new->request($request);
die $response->status_line . "\n" . $response->decoded_content
unless $response->is_success;
print $response->decoded_content;
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 Perl
Perl is a family of high-level interpreted scripting languages, including Perl 5 and Perl 6, which was renamed to Raku. It is popular as a scripting language because of its built-in regular expression and string parsing functionality.