Sapling Logo
AI detector quickstart

R AI Detector

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

  • HTTPS POST
  • HTTP API
  • API key required
R logo R /api/v1/aidetect

R 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.
R /api/v1/aidetect

This example uses the httr2 package.

library(httr2)

api_key <- Sys.getenv("SAPLING_API_KEY")
if (!nzchar(api_key)) {
  stop("Set SAPLING_API_KEY first.")
}

response <- request("https://api.sapling.ai/api/v1/aidetect") |>
  req_headers(Authorization = paste("Bearer", api_key)) |>
  req_body_json(list(
    text = paste(
      "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
  )) |>
  req_perform()

resp_body_json(response, simplifyVector = TRUE)
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 R

R is a programming language and environment for statistical computing, data analysis, and visualization. It is widely used by data scientists, researchers, and teams working with quantitative data.