Rust 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.
This example uses reqwest with its blocking and json features.
use reqwest::blocking::Client;
use serde_json::json;
use std::{env, error::Error};
fn main() -> Result<(), Box<dyn Error>> {
let api_key = env::var("SAPLING_API_KEY")?;
let response = Client::new()
.post("https://api.sapling.ai/api/v1/aidetect")
.bearer_auth(api_key)
.json(&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
}))
.send()?
.error_for_status()?
.text()?;
println!("{response}");
Ok(())
}
{
"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 Rust
Rust is a programming language designed with comparable performance to C or C++, but with additional emphasis on code safety. Rust compilers do additional object reference and thread safety checks to prevent references to invalid memory or concurrency issues.