> For the complete documentation index, see [llms.txt](https://api-docs.speechace.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api-docs.speechace.com/interpreting-results/detecting-ai-generated-responses.md).

# Detecting AI-generated Responses

{% hint style="info" %}
AI Content Detection is under restricted preview\
AI Content Detection incurs additional billing charges. See [API Request rates](https://api-docs.speechace.com/resources/faqs.md#what-are-the-api-request-rates).
{% endhint %}

Set `detect_ai_response_content=1` on a request and Speechace estimates whether the response was written by the learner, generated by an AI tool, or a mix of both. Use it to flag answers for review in assessments and practice activities.

The feature is designed and trained for spoken and written responses by **non-native English learners**. It looks for the difference between how learners write and speak and how AI tools write.&#x20;

### How it works

* **Classify the whole response.** The response is labelled `human`, `ai`, or `mixed`, with a probability that the response is AI-generated.
* **Identify AI sentences.** For `ai` and `mixed` responses, the API lists the sentences that drive the AI estimate: the sentences whose removal lowers the probability. For an `ai` response this is usually most or all of the sentences.
* **No impact on scoring.** Every score is the same as in a request made without the flag. The flag only adds information.

The flag is optional and off by default. When it is not set, the response is unchanged.

### What the flag adds

With `detect_ai_response_content=1`, the response gains a `detected_ai_response_content` object:

<table><thead><tr><th width="224">Field</th><th width="110">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>response_class</code></td><td>String</td><td><code>human</code>, <code>ai</code>, or <code>mixed</code>.</td></tr><tr><td><code>probability_ai_response</code></td><td>Number</td><td>Estimated probability, from 0 to 1, that the response is AI-generated. Higher means more likely.</td></tr><tr><td><code>confidence_interval</code></td><td>Number</td><td>Confidence of the classification, from 0 to 100.</td></tr><tr><td><code>ai_sentences</code></td><td>Array</td><td>One <code>{"extent": [start, end], "text": "..."}</code> entry per sentence that drives the AI estimate. Offsets are zero-based character positions, both <strong>inclusive</strong>, into the response text (see the table below). Entries are not in reading order; sort by <code>extent[0]</code> if you need it. Empty when <code>response_class</code> is <code>human</code>.</td></tr></tbody></table>

### Endpoints

<table><thead><tr><th width="190">Endpoint</th><th>detected_ai_response_content object</th><th>Response text (offsets index into this)</th></tr></thead><tbody><tr><td><a href="https://api-docs.speechace.com/api-reference/score-speech.md">Score Speech</a></td><td><code>speech_score.detected_ai_response_content</code></td><td><code>speech_score.transcript</code></td></tr><tr><td><a href="https://api-docs.speechace.com/api-reference/score-task.md">Score Task</a></td><td><code>task_score.detected_ai_response_content</code></td><td><code>task_score.transcript</code> (the recognized audio, or <code>user_audio_text</code>)</td></tr><tr><td><a href="https://api-docs.speechace.com/api-reference/score-writing.md">Score Writing</a></td><td><code>detected_ai_response_content</code> (top level)</td><td><code>answer</code> (top level)</td></tr></tbody></table>

Spoken responses are assessed from the transcript.

### Short responses

Detection needs at least **25 words**. For a shorter response the `detected_ai_response_content` object is omitted, scoring still runs, and a warning is added to the endpoint's `score_issue_list` (top level for Score Writing, `task_score.score_issue_list` for Score Task):

{% code overflow="wrap" lineNumbers="true" expandable="true" collapsedlinecount="10" %}

```json
{
  "source": "ai_response_content_detection",
  "status": "warning",
  "short_message": "response_too_short",
  "detail_message": "The response is too short to trigger AI Answer detection."
}
```

{% endcode %}

Check for this warning rather than only for the object, so you can tell "too short to check" apart from "not requested". See [Scoring errors & warnings](https://api-docs.speechace.com/interpreting-results/scoring-errors-and-warnings.md).

### Supported dialects

English only: `en-us` and `en-gb`. Do not set the flag on requests in other dialects. Depending on the endpoint and dialect, such a request either fails with `error_feature_unavailable` or returns without the object.

### Using the result

* **Treat it as a signal for review** (especially when response\_class is `mixed` or `ai`)**.** Do not fail a candidate or reject an answer on this result alone. Route flagged responses along with overall scores and results for human review, or combine the result with other evidence such as the response's timing or the learner's earlier work.
* **Use the probability to set your own threshold.** `response_class` is a convenient summary; `probability_ai_response` lets you choose how sensitive your review queue should be.
* **Use `ai_sentences` to focus the review.** In a `mixed` response, start with the listed sentences.
* **Stay within the intended population.** Results are most meaningful on responses from non-native English learners, in English, of at least 25 words.

### Request Format

Send the request to the endpoint you already use, with one extra body parameter. The endpoint depends on the [region](https://api-docs.speechace.com/getting-started/api-regions-and-endpoints.md) of your subscription. For US West the base URL is <https://api.speechace.co>.

`POST` [`https://api.speechace.co/api/scoring/speech/v9/json`](https://api.speechace.co/api/scoring/speech/v9/json)

`POST` [`https://api.speechace.co/api/scoring/task/v9/json`](https://api.speechace.co/api/scoring/task/v9/json)

`POST` [`https://api.speechace.co/api/scoring/writing/v9/json`](https://api.speechace.co/api/scoring/writing/v9/json)

`key`, `dialect` and the other query parameters stay as documented on each endpoint's page. The only addition is a form body field:

<table><thead><tr><th width="250">Parameter</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td>detect_ai_response_content</td><td>String</td><td><code>0</code> | <code>1</code><br><em><strong>Optional</strong>: Set to <code>1</code> to detect AI-generated content in the response. Default <code>0</code>.</em></td></tr></tbody></table>

### Request Examples

All four examples use [Score Writing](https://api-docs.speechace.com/api-reference/score-writing.md). The same flag works on Score Speech and Score Task.

<table><thead><tr><th width="160">Example</th><th width="420">Request Parameters</th><th>When to use</th></tr></thead><tbody><tr><td>A. AI-generated</td><td>Query: <code>task_type=short-writing</code><br><code>prompt="Describe how technology has changed your daily life."</code><br><code>answer="Technology has fundamentally reshaped the way we live, work, and connect with one another. In the workplace, automation and digital tools have increased productivity and allowed people to collaborate across great distances. In education, students now have access to vast resources that were once confined to libraries. However, this transformation is not without drawbacks: overreliance on devices can weaken face-to-face communication and shorten attention spans. On balance, technology is a powerful force for progress, but its benefits depend on how thoughtfully and responsibly we choose to use it in our daily lives."</code><br><code>detect_ai_response_content="1"</code></td><td><em>An answer written by an AI tool. Returns <code>ai</code> and lists its sentences.</em></td></tr><tr><td>B. Learner</td><td>Query: <code>task_type=short-writing</code><br><code>prompt="Describe how technology has changed your daily life."</code><br><code>answer="I think technology change my life very much. Before, I go to the bank for pay the bills but now I do everything with my phone. Also I talk with my family in my country every day on video call, it is cheap and easy. But sometimes I spend too much time on social media and I sleep late. My teacher say we must use technology in a good way, and I agree with her. In the future I want to learn programming because it is useful for find a good job."</code><br><code>detect_ai_response_content="1"</code></td><td><em>An answer written by a learner. Returns <code>human</code> with no sentences.</em></td></tr><tr><td>C. Mixed</td><td>Query: <code>task_type=short-writing</code><br><code>prompt="Describe how technology has changed your daily life."</code><br><code>answer="I think technology change my life very much. Before, I go to the bank for pay the bills but now I do everything with my phone. Moreover, digital platforms have fundamentally reshaped how we communicate, enabling seamless connection across vast distances. These advancements have also streamlined countless everyday tasks, significantly improving both efficiency and convenience. Also I talk with my family in my country every day on video call, it is cheap and easy. But sometimes I spend too much time on social media and I sleep late, my mother is not happy about it."</code><br><code>detect_ai_response_content="1"</code></td><td><em>A learner answer with two AI-written sentences added. Returns <code>mixed</code> and lists the sentences that drive the estimate.</em></td></tr><tr><td>D. Too short</td><td>Query: <code>task_type=short-writing</code><br><code>prompt="Describe how technology has changed your daily life."</code><br><code>answer="Technology helps me every day because I use my phone for work, study and talking with friends."</code><br><code>detect_ai_response_content="1"</code></td><td><em>An answer under 25 words. The object is omitted and <code>response_too_short</code> is added to <code>score_issue_list</code>.</em></td></tr></tbody></table>

### Response Examples

The examples below were generated by the live API.

{% tabs %}
{% tab title="A. AI-generated" %}
{% code overflow="wrap" lineNumbers="true" expandable="true" collapsedlinecount="10" %}

```json
{
  "status": "success",
  "task_type": "short-writing",
  "task_version": "0.1",
  "answer": "Technology has fundamentally reshaped the way we live, work, and connect with one another. In the workplace, automation and digital tools have increased productivity and allowed people to collaborate across great distances. In education, students now have access to vast resources that were once confined to libraries. However, this transformation is not without drawbacks: overreliance on devices can weaken face-to-face communication and shorten attention spans. On balance, technology is a powerful force for progress, but its benefits depend on how thoughtfully and responsibly we choose to use it in our daily lives.",
  "char_count": 621,
  "writing_score": {
    "speechace": {
      "task_response": 50,
      "vocab": 78,
      "coherence": 83,
      "grammar": 83,
      "overall": 72
    },
    "ielts": {
      "task_response": 4.5,
      "vocab": 7,
      "coherence": 7.5,
      "grammar": 7.5,
      "overall": 6.5
    },
    "cefr": {
      "task_response": "B1",
      "vocab": "B2+",
      "coherence": "C1",
      "grammar": "C1",
      "overall": "B2"
    },
    "pte": {
      "task_response": 22,
      "vocab": 73,
      "coherence": 80,
      "grammar": 80,
      "overall": 64
    },
    "toeic": {
      "task_response": 80,
      "vocab": 160,
      "coherence": 170,
      "grammar": 170,
      "overall": 140
    }
  },
  "detected_ai_response_content": {
    "response_class": "ai",
    "probability_ai_response": 1,
    "confidence_interval": 98,
    "ai_sentences": [
      {
        "extent": [
          0,
          89
        ],
        "text": "Technology has fundamentally reshaped the way we live, work, and connect with one another."
      },
      {
        "extent": [
          319,
          463
        ],
        "text": "However, this transformation is not without drawbacks: overreliance on devices can weaken face-to-face communication and shorten attention spans."
      },
      {
        "extent": [
          224,
          317
        ],
        "text": "In education, students now have access to vast resources that were once confined to libraries."
      },
      {
        "extent": [
          91,
          222
        ],
        "text": "In the workplace, automation and digital tools have increased productivity and allowed people to collaborate across great distances."
      },
      {
        "extent": [
          465,
          620
        ],
        "text": "On balance, technology is a powerful force for progress, but its benefits depend on how thoughtfully and responsibly we choose to use it in our daily lives."
      }
    ]
  },
  "version": "9.20"
}
```

{% endcode %}
{% endtab %}

{% tab title="B. Learner" %}
{% code overflow="wrap" lineNumbers="true" expandable="true" collapsedlinecount="10" %}

```json
{
  "status": "success",
  "task_type": "short-writing",
  "task_version": "0.1",
  "answer": "I think technology change my life very much. Before, I go to the bank for pay the bills but now I do everything with my phone. Also I talk with my family in my country every day on video call, it is cheap and easy. But sometimes I spend too much time on social media and I sleep late. My teacher say we must use technology in a good way, and I agree with her. In the future I want to learn programming because it is useful for find a good job.",
  "char_count": 443,
  "writing_score": {
    "speechace": {
      "task_response": 78,
      "vocab": 56,
      "coherence": 56,
      "grammar": 50,
      "overall": 61
    },
    "ielts": {
      "task_response": 7,
      "vocab": 5,
      "coherence": 5,
      "grammar": 4.5,
      "overall": 5.5
    },
    "cefr": {
      "task_response": "B2+",
      "vocab": "B1",
      "coherence": "B1",
      "grammar": "B1",
      "overall": "B1+"
    },
    "pte": {
      "task_response": 73,
      "vocab": 35,
      "coherence": 35,
      "grammar": 22,
      "overall": 45
    },
    "toeic": {
      "task_response": 160,
      "vocab": 90,
      "coherence": 90,
      "grammar": 80,
      "overall": 110
    }
  },
  "detected_ai_response_content": {
    "response_class": "human",
    "probability_ai_response": 0.004919431172311306,
    "confidence_interval": 98,
    "ai_sentences": []
  },
  "version": "9.20"
}
```

{% endcode %}
{% endtab %}

{% tab title="C. Mixed" %}
{% code overflow="wrap" lineNumbers="true" expandable="true" collapsedlinecount="10" %}

```json
{
  "status": "success",
  "task_type": "short-writing",
  "task_version": "0.1",
  "answer": "I think technology change my life very much. Before, I go to the bank for pay the bills but now I do everything with my phone. Moreover, digital platforms have fundamentally reshaped how we communicate, enabling seamless connection across vast distances. These advancements have also streamlined countless everyday tasks, significantly improving both efficiency and convenience. Also I talk with my family in my country every day on video call, it is cheap and easy. But sometimes I spend too much time on social media and I sleep late, my mother is not happy about it.",
  "char_count": 569,
  "writing_score": {
    "speechace": {
      "task_response": 78,
      "vocab": 67,
      "coherence": 61,
      "grammar": 61,
      "overall": 67
    },
    "ielts": {
      "task_response": 7,
      "vocab": 6,
      "coherence": 5.5,
      "grammar": 5.5,
      "overall": 6
    },
    "cefr": {
      "task_response": "B2+",
      "vocab": "B2",
      "coherence": "B1+",
      "grammar": "B1+",
      "overall": "B2"
    },
    "pte": {
      "task_response": 73,
      "vocab": 55,
      "coherence": 45,
      "grammar": 45,
      "overall": 55
    },
    "toeic": {
      "task_response": 160,
      "vocab": 120,
      "coherence": 110,
      "grammar": 110,
      "overall": 120
    }
  },
  "detected_ai_response_content": {
    "response_class": "mixed",
    "probability_ai_response": 0.8681920766830444,
    "confidence_interval": 50,
    "ai_sentences": [
      {
        "extent": [
          127,
          253
        ],
        "text": "Moreover, digital platforms have fundamentally reshaped how we communicate, enabling seamless connection across vast distances."
      },
      {
        "extent": [
          0,
          43
        ],
        "text": "I think technology change my life very much."
      },
      {
        "extent": [
          255,
          377
        ],
        "text": "These advancements have also streamlined countless everyday tasks, significantly improving both efficiency and convenience."
      }
    ]
  },
  "version": "9.20"
}
```

{% endcode %}
{% endtab %}

{% tab title="D. Too short" %}
{% code overflow="wrap" lineNumbers="true" expandable="true" collapsedlinecount="10" %}

```json
{
  "status": "success",
  "task_type": "short-writing",
  "task_version": "0.1",
  "answer": "Technology helps me every day because I use my phone for work, study and talking with friends.",
  "char_count": 94,
  "writing_score": {
    "speechace": {
      "task_response": 28,
      "vocab": 56,
      "coherence": 56,
      "grammar": 61,
      "overall": 50
    },
    "ielts": {
      "task_response": 2.5,
      "vocab": 5,
      "coherence": 5,
      "grammar": 5.5,
      "overall": 4.5
    },
    "cefr": {
      "task_response": "A2",
      "vocab": "B1",
      "coherence": "B1",
      "grammar": "B1+",
      "overall": "B1"
    },
    "pte": {
      "task_response": 15,
      "vocab": 35,
      "coherence": 35,
      "grammar": 45,
      "overall": 22
    },
    "toeic": {
      "task_response": 40,
      "vocab": 90,
      "coherence": 90,
      "grammar": 110,
      "overall": 80
    }
  },
  "score_issue_list": [
    {
      "source": "answer content",
      "status": "warning",
      "short_message": "error_word_count",
      "detail_message": "The answer contains 17 word(s) while the expected word count for answer is 50 to 100 words"
    },
    {
      "source": "ai_response_content_detection",
      "status": "warning",
      "short_message": "response_too_short",
      "detail_message": "The response is too short to trigger AI Answer detection."
    }
  ],
  "version": "9.20"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
