# ai-text-detector (https://reapi.ai/docs/ai-text-detector)

> `ai-text-detector` is a single async endpoint that scores text 0–100 for how likely
> it is AI-generated, aggregating several third-party detection engines into one
> result plus per-engine sub-scores. See current pricing on the
> [model page](https://reapi.ai/models/ai-text-detector).

## Quick example

### cURL

    ```bash
    curl https://api.reapi.ai/v1/detect \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "ai-text-detector",
        "text": "Citizen science involves the public participating in scientific research. This can take many forms, from collecting data on local wildlife populations to analyzing astronomical images."
      }'
    ```

### Python

    ```python
    import requests

    resp = requests.post(
        "https://api.reapi.ai/v1/detect",
        headers={
            "Authorization": "Bearer YOUR_API_KEY",
            "Content-Type": "application/json",
        },
        json={
            "model": "ai-text-detector",
            "text": "Citizen science involves the public participating in scientific research. This can take many forms, from collecting data on local wildlife populations to analyzing astronomical images.",
        },
        timeout=30,
    )
    print(resp.json())
    ```

### Node.js

    ```js
    const r = await fetch("https://api.reapi.ai/v1/detect", {
      method: "POST",
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        model: "ai-text-detector",
        text: "Citizen science involves the public participating in scientific research. This can take many forms, from collecting data on local wildlife populations to analyzing astronomical images.",
      }),
    });
    console.log(await r.json());
    ```

### Go

    ```go
    package main

    import (
        "bytes"
        "encoding/json"
        "fmt"
        "io"
        "net/http"
    )

    func main() {
        body, _ := json.Marshal(map[string]any{
            "model": "ai-text-detector",
            "text":  "Citizen science involves the public participating in scientific research. This can take many forms, from collecting data on local wildlife populations to analyzing astronomical images.",
        })
        req, _ := http.NewRequest("POST",
            "https://api.reapi.ai/v1/detect", bytes.NewReader(body))
        req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
        req.Header.Set("Content-Type", "application/json")

        resp, _ := http.DefaultClient.Do(req)
        defer resp.Body.Close()
        out, _ := io.ReadAll(resp.Body)
        fmt.Println(string(out))
    }
    ```

### Submit response

```json
{
  "id": "task_018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e",
  "model": "ai-text-detector",
  "status": "processing",
  "created_at": 1735000000
}
```

Poll `GET /api/v1/tasks/{id}` until `status === "completed"`. A check usually
finishes in a few seconds.

***

## Authentication

Every call needs a Bearer token. Generate keys at
[reapi.ai/settings/apikeys](https://reapi.ai/settings/apikeys).

```http
Authorization: Bearer YOUR_API_KEY
```

***

## Endpoint

```http
POST /api/v1/detect
GET  /api/v1/tasks/{id}
```

Submission is async. The POST returns immediately with a `task_id`; polling
the task endpoint returns the same envelope until completion. Polling does
not consume credits.

***

## Request body

### `model` — required

Always `"ai-text-detector"`.

### `text` — required (string)

The text to check for AI authorship.

* **Maximum:** under **30,000 words** per request.
* **Recommended:** at least \~200 words. Short snippets carry less signal,
  though the detector still returns a result.
* Encode line breaks inside the JSON string as `\n`.

***

## Output

```json
{
  "id": "task_018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e",
  "model": "ai-text-detector",
  "status": "completed",
  "created_at": 1735000000,
  "output": {
    "detection": {
      "result": 12.0,
      "human": 88.0,
      "detectors": {
        "scoreGptZero": 50.0,
        "scoreOpenAI": 0.0,
        "scoreWriter": 0.0,
        "scoreCrossPlag": 0.0,
        "scoreCopyLeaks": 50.0,
        "scoreSapling": 0.0,
        "scoreContentAtScale": 0.0,
        "scoreZeroGPT": 50.0
      }
    }
  },
  "error": null
}
```

### Interpreting the score

`result` is the headline **AI-likelihood**, 0–100:

| Range    | Reading               |
| -------- | --------------------- |
| under 50 | Likely human-written. |
| 50 – 60  | Possible AI.          |
| over 60  | Likely AI-generated.  |

`human` is the complementary human-likelihood. `detectors` carries each
third-party engine's sub-score so you can see whether the engines agree or
split. The headline `result` is the most accurate signal; treat the sub-scores
as supporting detail.

***

## Pricing

Billed **per word** of the `text` you submit, with a **50-word floor**. AI
detection is priced at one-tenth the per-word rate of text humanization.
Polling does not add any charge. Failed requests are refunded automatically.

`1 credit = $0.001 USD`. See the live banner on the
[model page](https://reapi.ai/models/ai-text-detector) for the current
per-1,000-words rate in credits.

***

## Errors

Standard envelope:

```json
{
  "error": {
    "code": 20002,
    "message": "text is required",
    "request_id": "req_..."
  }
}
```

Common cases:

| Code    | When                                                                       |
| ------- | -------------------------------------------------------------------------- |
| `20002` | `text` missing.                                                            |
| `20003` | `text` empty or at/over the 30,000-word cap.                               |
| `30001` | Insufficient credits for the submitted word count.                         |
| `80001` | Provider rejected the submission — includes insufficient upstream credits. |
| `80003` | Provider failed while processing the detection.                            |

***

## Related

* [AI Humanizer](/docs/humanize) — rewrite AI text to read human. Pair it with
  `ai-text-detector` for a detect → rewrite → detect QA loop.