# AI Text Detector

> Differentiate between human-written and AI-written text.

<RequestExample>

```bash title="cURL" icon="terminal"
curl --request POST \
  --url https://api.copyleaks.com/v2/writer-detector/my-scan-123/check \
  --header 'Authorization: Bearer YOUR_LOGIN_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "text": "Copyleaks is a comprehensive plagiarism detection platform...",
    "sandbox": false,
    "explain": true,
    "sensitivity": 2
  }'
```

```python title="Python" icon="python"
from copyleaks.copyleaks import Copyleaks
from copyleaks.models.submit.ai_detection_document import NaturalLanguageDocument

auth_token = Copyleaks.login("your@email.address", "YOUR_API_KEY")

submission = NaturalLanguageDocument("Copyleaks is a comprehensive plagiarism detection platform...")
submission.set_sandbox(False)
submission.set_explain(True)
submission.set_sensitivity(2)

response = Copyleaks.AiDetectionClient.submit_natural_language(auth_token, "my-scan-123", submission)
print(response)
```

```javascript title="JavaScript" icon="square-js"
const { Copyleaks, CopyleaksNaturalLanguageSubmissionModel } = require('plagiarism-checker');

const copyleaks = new Copyleaks();
const auth = await copyleaks.loginAsync('YOUR_EMAIL', 'YOUR_API_KEY');

const submission = new CopyleaksNaturalLanguageSubmissionModel(
  'Copyleaks is a comprehensive plagiarism detection platform...'
);
submission.sandbox = false;
submission.explain = true;
submission.sensitivity = 2;

await copyleaks.aiDetectionClient.submitNaturalTextAsync(auth, 'my-scan-123', submission);
```

```java title="Java" icon="java"
import classes.Copyleaks;
import models.submissions.aidetection.CopyleaksNaturalLanguageSubmissionModel;

String authToken = Copyleaks.login("your@email", "API_KEY");

CopyleaksNaturalLanguageSubmissionModel sub = new CopyleaksNaturalLanguageSubmissionModel(
  "Copyleaks is a comprehensive plagiarism detection platform..."
);
sub.setSandbox(false);
sub.setExplain(true);
sub.setSensitivity(2);

Copyleaks.writerDetectorClient.submitNaturalLanguage(authToken, "my-scan-123", sub);
```

</RequestExample>

<ResponseExample>

```json 200 OK
{
  "modelVersion": "v5",
  "results": [
    {
      "classification": 2,
      "probability": 1,
      "matches": [
        {
          "text": {
            "chars": { "starts": [0], "lengths": [1509] },
            "words": { "starts": [0], "lengths": [221] }
          }
        }
      ]
    }
  ],
  "summary": { "human": 0, "ai": 1 },
  "scannedDocument": {
    "scanId": "my-scan-123",
    "totalWords": 221,
    "actualCredits": 1,
    "expectedCredits": 1,
    "creationTime": "2023-01-10T10:07:58.9459512Z"
  }
}
```

</ResponseExample>

Use Copyleaks AI Content Detection to differentiate between human-written and AI-written text.

This endpoint will receive submitted text to be checked. At the end of the processing stage, the result will be shown as classifications. Text classification is divided into sections. Each section may have a different classification.

<Warning>
**Authentication Required.** You need to login with a user and API key in order to access this method. Add this HTTP header to your request:

**Authorization: Bearer &lt;Your-Login-Token&gt;**
</Warning>

## Request

### Path Parameters

<ParamField path="scanId" type="string" required>
  A unique scan id provided by you. We recommend you use the same id in your database to represent the scan in the Copyleaks database. Learn more about [the criteria for creating a Scan ID](/concepts/management/choosing-scan-id).

  `>= 3 characters` `<= 36 characters`
</ParamField>

### Headers

```http
Content-Type: application/json
Authorization: Bearer YOUR_LOGIN_TOKEN
```

### Request Body

<ParamField body="text" type="string" required>
  A text string.
  `>= 255 characters` `<= 100000 characters`
</ParamField>
<ParamField body="sandbox" type="boolean" default="false">
  Use sandbox mode to test your integration with the Copyleaks API for free.
</ParamField>
<ParamField body="language" type="string">
  The language code of your content in ISO-639-1 format. See the full [list of supported languages](/reference/actions/miscellaneous/ai-detection-supported-languages).
  If the `language` field is not supplied, our system will automatically detect the language of the content.
  Example: `"en"`
</ParamField>
<ParamField body="explain" type="boolean" default="false">
  Enable AI Logic feature for AI detection. For further information, please check the [AI Logic](/concepts/features/ai-logic) for a detailed breakdown of its structure and usage, and for full AI Detection response please check the [AI Detection Response](/reference/data-types/authenticity/results/ai-detection).
</ParamField>
<ParamField body="sensitivity" type="integer" default="2">
  Control the behavior of the AI detection.
  - Detecting content copied directly from an LLM, like ChatGPT or Gemini, without edits.
  - Detecting content from an LLM with minor changes, like tense adjustments or added words.
  - Detecting content from an LLM that has been heavily modified using tools or manual edits.

  `>= 1` `<= 3`
</ParamField>

## Responses

<Tabs>
  <Tab title="200">
    <Check>**200 OK** - The command was executed.</Check>

    ```json
    {
      "modelVersion": "v5",
      "results": [
        {
          "classification": 2,
          "probability": 1,
          "matches": [
            {
              "text": {
                "chars": { "starts": [0], "lengths": [1509] },
                "words": { "starts": [0], "lengths": [221] }
              }
            }
          ]
        }
      ],
      "summary": { "human": 0, "ai": 1 }
    }
    ```
  </Tab>
  <Tab title="400">
    <Warning>**400 Bad Request** - Bad request.</Warning>
  </Tab>
  <Tab title="401">
    <Warning>**401 Unauthorized** - Authorization has been denied for this request.</Warning>
  </Tab>
  <Tab title="429">
    <Warning>**429 Too Many Requests** - Too many requests have been sent. The request has been rejected.</Warning>
  </Tab>
</Tabs>

## Next Steps

<CardGroup cols={2}>
  <Card title="Detect AI-Generated Text" icon="robot" href="/guides/ai-detector/ai-text-detection/">Learn how to use the AI Detection API to check if content was written by a human or generated by an AI.</Card>
  <Card title="AI Logic" icon="robot" href="/concepts/features/ai-logic/">Understand how AI logic can help you interpret the results of AI text detection.</Card>
  <Card title="AI Detection Webhook" icon="plug" href="/reference/data-types/authenticity/results/ai-detection/">Learn about the webhook that delivers AI detection results.</Card>
</CardGroup>
