> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aiornot.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Text

> Analyze **text** to determine if it was generated by AI.

This endpoint analyzes text content and returns confidence scores for AI detection.

**Text Processing Limits:**
- **Minimum Text Length:** 250 characters
- **Maximum Text Length:** 500,000 characters (500KB)
- **Minimum Words**: Approximately 64 words



## OpenAPI

````yaml api-reference/openapi.yaml post /v2/text/sync
openapi: 3.1.0
info:
  title: AIORNOT API
  summary: |2-

            Welcome to AI or Not`s documentation, the developer guide to discerning digital authenticity!
            
  termsOfService: https://aiornot.com/terms-of-service
  contact:
    name: AIORNOT
    url: https://aiornot.com/
    email: support@aiornot.com
  version: 5.0.2
servers:
  - url: https://api.aiornot.com
    description: Production environment
security: []
paths:
  /v2/text/sync:
    post:
      tags:
        - Reports by Modality
      summary: Text
      description: >-
        Analyze **text** to determine if it was generated by AI.


        This endpoint analyzes text content and returns confidence scores for AI
        detection.


        **Text Processing Limits:**

        - **Minimum Text Length:** 250 characters

        - **Maximum Text Length:** 500,000 characters (500KB)

        - **Minimum Words**: Approximately 64 words
      operationId: get_text_report_text_sync_post
      parameters:
        - name: external_id
          in: query
          description: An optional external identifier for tracking this text analysis
          required: false
          schema:
            type: string
            nullable: true
        - name: include_annotations
          in: query
          description: Include block-level AI detection annotations in the response
          required: false
          schema:
            type: boolean
            default: false
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                text:
                  type: string
                  title: Text
                  description: >-
                    The text content to analyze for AI generation (minimum 250
                    characters, maximum 500,000 characters)
                  minLength: 250
                  maxLength: 500000
              required:
                - text
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TextReportResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
      x-codeSamples:
        - lang: python
          label: Python
          source: |
            import os, requests


            # Set API key ENV variable or replace with your own API key
            API_KEY = os.getenv("AIORNOT_API_KEY")
            TEXT_ENDPOINT = "https://api.aiornot.com/v2/text/sync"

            data = {
                "text": "Your text content to analyze goes here..."
            }

            resp = requests.post(
                TEXT_ENDPOINT,
                headers={"Authorization": f"Bearer {API_KEY}"},
                data=data,
                params={
                    "include_annotations": True,  # Optional: Include block-level annotations
                    "external_id": "my-tracking-id"  # Optional: External tracking ID
                }
            )
            resp.raise_for_status()
            print(resp.json())
        - lang: curl
          label: cURL
          source: |
            curl --request POST \
              --url 'https://api.aiornot.com/v2/text/sync?include_annotations=true&external_id=my-tracking-id' \
              --header 'Authorization: Bearer $AIORNOT_API_KEY' \
              --header 'Content-Type: application/x-www-form-urlencoded' \
              --data 'text=Your text content to analyze goes here...'
        - lang: javascript
          label: JavaScript
          source: |
            const fetch = require('node-fetch');
            const querystring = require('querystring');

            const API_KEY = process.env.AIORNOT_API_KEY;
            const TEXT_ENDPOINT = 'https://api.aiornot.com/v2/text/sync';

            const data = querystring.stringify({
              text: 'Your text content to analyze goes here...'
            });

            const params = new URLSearchParams({
              include_annotations: 'true',  // Optional: Include block-level annotations
              external_id: 'my-tracking-id'  // Optional: External tracking ID
            });

            fetch(`${TEXT_ENDPOINT}?${params}`, {
              method: 'POST',
              headers: {
                'Authorization': `Bearer ${API_KEY}`,
                'Content-Type': 'application/x-www-form-urlencoded'
              },
              body: data
            })
              .then(response => {
                if (!response.ok) {
                  throw new Error(`Failed to analyze text: ${response.status} ${response.statusText}`);
                }
                return response.json();
              })
              .then(data => console.log(data))
              .catch(error => console.error('Error:', error));
        - lang: php
          label: PHP
          source: |
            <?php

            $API_KEY = getenv('AIORNOT_API_KEY');
            $TEXT_ENDPOINT = 'https://api.aiornot.com/v2/text/sync';

            $curl = curl_init();

            $data = [
              'text' => 'Your text content to analyze goes here...'
            ];

            $query_params = http_build_query([
              'include_annotations' => 'true',  // Optional: Include block-level annotations
              'external_id' => 'my-tracking-id'  // Optional: External tracking ID
            ]);

            curl_setopt_array($curl, [
              CURLOPT_URL => $TEXT_ENDPOINT . '?' . $query_params,
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_POST => true,
              CURLOPT_POSTFIELDS => http_build_query($data),
              CURLOPT_HTTPHEADER => [
                "Authorization: Bearer $API_KEY",
                "Content-Type: application/x-www-form-urlencoded"
              ],
            ]);

            $response = curl_exec($curl);
            $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
            $err = curl_error($curl);

            curl_close($curl);

            if ($err) {
              echo "cURL Error #:" . $err;
            } elseif ($httpCode !== 200) {
              echo "Failed to analyze text: HTTP $httpCode - $response";
            } else {
              $data = json_decode($response, true);
              print_r($data);
            }
        - lang: go
          label: Go
          source: |
            package main

            import (
              "fmt"
              "io/ioutil"
              "net/http"
              "net/url"
              "os"
              "strings"
            )

            func main() {
              APIKey := os.Getenv("AIORNOT_API_KEY")
              textEndpoint := "https://api.aiornot.com/v2/text/sync"

              data := url.Values{}
              data.Set("text", "Your text content to analyze goes here...")

              params := url.Values{}
              params.Set("include_annotations", "true")  // Optional: Include block-level annotations
              params.Set("external_id", "my-tracking-id")  // Optional: External tracking ID

              fullURL := textEndpoint + "?" + params.Encode()

              req, err := http.NewRequest("POST", fullURL, strings.NewReader(data.Encode()))
              if err != nil {
                panic(err)
              }

              req.Header.Set("Authorization", "Bearer "+APIKey)
              req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

              client := &http.Client{}
              resp, err := client.Do(req)
              if err != nil {
                panic(err)
              }
              defer resp.Body.Close()

              body, err := ioutil.ReadAll(resp.Body)
              if err != nil {
                panic(err)
              }

              if resp.StatusCode != 200 {
                fmt.Printf("Failed to analyze text: %d %s\n", resp.StatusCode, string(body))
                return
              }

              fmt.Println(string(body))
            }
        - lang: java
          label: Java
          source: |
            import java.io.IOException;
            import okhttp3.*;

            public class TextAnalysis {
                public static void main(String[] args) {
                    String apiKey = System.getenv("AIORNOT_API_KEY");
                    String textEndpoint = "https://api.aiornot.com/v2/text/sync";
                    
                    OkHttpClient client = new OkHttpClient();
                    
                    RequestBody formBody = new FormBody.Builder()
                        .add("text", "Your text content to analyze goes here...")
                        .build();
                    
                    HttpUrl url = HttpUrl.parse(textEndpoint).newBuilder()
                        .addQueryParameter("include_annotations", "true")  // Optional: Include block-level annotations
                        .addQueryParameter("external_id", "my-tracking-id")  // Optional: External tracking ID
                        .build();
                    
                    Request request = new Request.Builder()
                        .url(url)
                        .header("Authorization", "Bearer " + apiKey)
                        .post(formBody)
                        .build();
                    
                    try {
                        Response response = client.newCall(request).execute();
                        if (!response.isSuccessful()) {
                            System.err.println("Failed to analyze text: " + response.code() + " " + response.body().string());
                        } else {
                            System.out.println(response.body().string());
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
components:
  schemas:
    TextReportResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
          description: Unique identifier associated with the request
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Date and time of request processing
        report:
          type: object
          properties:
            ai_text:
              $ref: '#/components/schemas/AITextReportScheme'
          required:
            - ai_text
        metadata:
          $ref: '#/components/schemas/TextMetadata'
        external_id:
          type: string
          nullable: true
          title: External Id
          description: The external identifier provided in the request, if any
      type: object
      required:
        - id
        - report
        - metadata
      title: TextReportResponse
    HTTPValidationError:
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
      type: object
      title: HTTPValidationError
    AITextReportScheme:
      properties:
        confidence:
          type: number
          title: Confidence
          description: Confidence score for AI-generated text detection
          minimum: 0
          maximum: 1
          example: 0.95
        is_detected:
          type: boolean
          title: Is Detected
          description: Whether AI-generated text was detected
        annotations:
          type: array
          title: Annotations
          description: >-
            Block-level AI detection results (only included when
            include_annotations=true)
          items:
            type: array
            minItems: 2
            maxItems: 2
            items:
              - type: string
                description: Text block
              - type: number
                description: Confidence score for this block
                minimum: 0
                maximum: 1
          example:
            - - This is the first block of text.
              - 0.9999
            - - This is the second block of text.
              - 0.0012
      type: object
      required:
        - confidence
        - is_detected
      title: AITextReportScheme
    TextMetadata:
      properties:
        word_count:
          type: integer
          title: Word Count
          description: Number of words in the analyzed text
          example: 150
        character_count:
          type: integer
          title: Character Count
          description: Number of characters in the analyzed text
          example: 750
        token_count:
          type: integer
          title: Token Count
          description: Number of tokens in the analyzed text
          example: 200
        md5:
          type: string
          title: MD5
          description: MD5 hash of the analyzed text
          example: ebe5836f4d7dddc3f9a957eff565be21
      type: object
      required:
        - word_count
        - character_count
        - token_count
        - md5
      title: TextMetadata
    ValidationError:
      properties:
        loc:
          type: array
          items:
            oneOf:
              - type: string
              - type: integer
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer
      description: >-
        Your [API key](https://www.aiornot.com/dashboard/api) as the `Bearer`
        token in the `Authorization` header.

````