Sapling Logo
AI detector quickstart

Erlang AI Detector

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

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

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

This example uses OTP's httpc client and the jsx JSON library.

inets:start(),
ssl:start(),

ApiKey = os:getenv("SAPLING_API_KEY"),
true = ApiKey =/= false,

Url = "https://api.sapling.ai/api/v1/aidetect",
Headers = [
  {"Authorization", "Bearer " ++ ApiKey},
  {"Accept", "application/json"}
],
Body = jsx:encode(#{
  <<"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
}),

{ok, {{_Version, Status, _Reason}, _ResponseHeaders, ResponseBody}} =
  httpc:request(post, {Url, Headers, "application/json", Body}, [], []),
true = Status >= 200 andalso Status < 300,
io:format("~s~n", [ResponseBody]).
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 Erlang

Erlang is a programming language for the Erlang virtual machine. It is designed for distributed, fault-tolerant, and highly concurrent/parallelizable systems. Applications of Erlang include WhatsApp and telephony switches.