> ## 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.

# Image

> Analyze an **image**.
This endpoint can run multiple reports on an image simultanously. By default, it runs `ai_generated`, `deepfake`, `nsfw`, and `quality` reports. You can select which reports to run by using the `only` and `excluding` parameters. Please note that `ai_generated` and `deepfake` reports both have their own costs.

**Limitations:**
- **Maximum file size:** 50MB
- **Supported formats:** jpg, jpeg, png, webp, heic, heif, tiff



## OpenAPI

````yaml api-reference/openapi.yaml post /v2/image/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/image/sync:
    post:
      tags:
        - Reports by Modality
      summary: Image
      description: >-
        Analyze an **image**.

        This endpoint can run multiple reports on an image simultanously. By
        default, it runs `ai_generated`, `deepfake`, `nsfw`, and `quality`
        reports. You can select which reports to run by using the `only` and
        `excluding` parameters. Please note that `ai_generated` and `deepfake`
        reports both have their own costs.


        **Limitations:**

        - **Maximum file size:** 50MB

        - **Supported formats:** jpg, jpeg, png, webp, heic, heif, tiff
      operationId: get_image_report_image_sync_post
      parameters:
        - name: only
          in: query
          description: >-
            Array of analysis types to include. Valid values are `ai_generated`,
            `deepfake`, `nsfw`, `quality`, `reverse_search`.
          required: false
          schema:
            type: array
            items:
              type: string
              enum:
                - ai_generated
                - deepfake
                - nsfw
                - quality
                - reverse_search
        - name: excluding
          in: query
          description: >-
            Array of analysis types to exclude. Valid values are `ai_generated`,
            `deepfake`, `nsfw`, `quality`, `reverse_search`.
          required: false
          schema:
            type: array
            items:
              type: string
              enum:
                - ai_generated
                - deepfake
                - nsfw
                - quality
                - reverse_search
        - name: external_id
          in: query
          description: An optional external identifier for tracking this image analysis.
          required: false
          schema:
            type: string
            nullable: true
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                image:
                  type: string
                  format: binary
                  title: Image
                  description: |-
                    The image file to analyze.
                     - Supported formats: jpg, jpeg, png, webp, heic, heif, tiff.
                    - Max file size: 10MB
              required:
                - image
            encoding:
              image:
                contentType: image/*
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2ImageReportResponse'
        '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")
            IMAGE_ENDPOINT = "https://api.aiornot.com/v2/image/sync"

            # By default, ai_generated, deepfake, nsfw, and quality reports run.
            # Use 'only' and 'excluding' parameters to select subsets.
            # Note: ai_generated and deepfake have their own costs.

            with open("image.jpeg", "rb") as f:
                resp = requests.post(
                    IMAGE_ENDPOINT,
                    headers={"Authorization": f"Bearer {API_KEY}"},
                    files={"image": f},
                    params={
                        "external_id": "my-tracking-id"  # Optional
                        # Example: only run reverse_search:
                        # "only": ["reverse_search"]
                        # Example: run all defaults except deepfake:
                        # "excluding": ["deepfake"]
                    }
                )
                resp.raise_for_status()
                print(resp.json())
        - lang: curl
          label: cURL
          source: >
            # By default, ai_generated, deepfake, nsfw, and quality reports run.

            # Use 'only' and 'excluding' parameters to select subsets.

            # Note: ai_generated and deepfake have their own costs.


            curl --request POST \
              --url https://api.aiornot.com/v2/image/sync \
              --header 'Authorization: Bearer $AIORNOT_API_KEY' \
              --form 'image=@image.jpeg'

            # Example: only run reverse_search

            # curl --request POST \

            #   --url
            'https://api.aiornot.com/v2/image/sync?only=reverse_search' \

            #   --header 'Authorization: Bearer $AIORNOT_API_KEY' \

            #   --form 'image=@image.jpeg'


            # Example: run all defaults except deepfake

            # curl --request POST \

            #   --url 'https://api.aiornot.com/v2/image/sync?excluding=deepfake'
            \

            #   --header 'Authorization: Bearer $AIORNOT_API_KEY' \

            #   --form 'image=@image.jpeg'
        - lang: javascript
          label: JavaScript
          source: >
            // By default, ai_generated, deepfake, nsfw, and quality reports
            run.

            // Use 'only' and 'excluding' parameters to select subsets.

            // Note: ai_generated and deepfake have their own costs.


            const fs = require('fs');

            const FormData = require('form-data');

            const fetch = require('node-fetch');


            const API_KEY = process.env.AIORNOT_API_KEY;

            const IMAGE_ENDPOINT = 'https://api.aiornot.com/v2/image/sync';


            const form = new FormData();

            form.append('image', fs.createReadStream('image.jpeg'));


            const params = new URLSearchParams({
              external_id: 'my-tracking-id'  // Optional
              // Example: only run reverse_search:
              // only: 'reverse_search'
              // Example: run all defaults except deepfake:
              // excluding: 'deepfake'
            });


            fetch(`${IMAGE_ENDPOINT}?${params}`, {
              method: 'POST',
              headers: {
                'Authorization': `Bearer ${API_KEY}`,
                ...form.getHeaders()
              },
              body: form
            })
              .then(response => {
                if (!response.ok) {
                  throw new Error(`Failed to analyze image: ${response.status} ${response.statusText}`);
                }
                return response.json();
              })
              .then(data => console.log(data))
              .catch(error => console.error('Error:', error));
        - lang: php
          label: PHP
          source: >
            <?php

            // By default, ai_generated, deepfake, nsfw, and quality reports
            run.

            // Use 'only' and 'excluding' parameters to select subsets.

            // Note: ai_generated and deepfake have their own costs.


            $API_KEY = getenv('AIORNOT_API_KEY');

            $IMAGE_ENDPOINT = 'https://api.aiornot.com/v2/image/sync';


            $curl = curl_init();


            $imageFile = new CURLFile('image.jpeg', 'image/jpeg', 'image');


            $query_params = http_build_query([
              'external_id' => 'my-tracking-id'  // Optional
              // Example: only run reverse_search:
              // 'only' => ['reverse_search']
              // Example: run all defaults except deepfake:
              // 'excluding' => ['deepfake']
            ]);


            curl_setopt_array($curl, [
              CURLOPT_URL => $IMAGE_ENDPOINT . '?' . $query_params,
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_POST => true,
              CURLOPT_POSTFIELDS => [
                'image' => $imageFile
              ],
              CURLOPT_HTTPHEADER => [
                "Authorization: Bearer $API_KEY"
              ],
            ]);


            $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 image: HTTP $httpCode - $response";
            } else {
              $data = json_decode($response, true);
              print_r($data);
            }
        - lang: go
          label: Go
          source: >
            // By default, ai_generated, deepfake, nsfw, and quality reports
            run.

            // Use 'only' and 'excluding' parameters to select subsets.

            // Note: ai_generated and deepfake have their own costs.


            package main


            import (
              "bytes"
              "fmt"
              "io"
              "io/ioutil"
              "mime/multipart"
              "net/http"
              "net/url"
              "os"
            )


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

              file, err := os.Open("image.jpeg")
              if err != nil {
                panic(err)
              }
              defer file.Close()

              var requestBody bytes.Buffer
              writer := multipart.NewWriter(&requestBody)

              part, err := writer.CreateFormFile("image", "image.jpeg")
              if err != nil {
                panic(err)
              }

              _, err = io.Copy(part, file)
              if err != nil {
                panic(err)
              }

              err = writer.Close()
              if err != nil {
                panic(err)
              }

              params := url.Values{}
              params.Set("external_id", "my-tracking-id")  // Optional
              // Example: only run reverse_search:
              // params.Set("only", "reverse_search")
              // Example: run all defaults except deepfake:
              // params.Set("excluding", "deepfake")

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

              req, err := http.NewRequest("POST", fullURL, &requestBody)
              if err != nil {
                panic(err)
              }

              req.Header.Set("Authorization", "Bearer "+APIKey)
              req.Header.Set("Content-Type", writer.FormDataContentType())

              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 image: %d %s\n", resp.StatusCode, string(body))
                return
              }

              fmt.Println(string(body))
            }
        - lang: java
          label: Java
          source: >
            // By default, ai_generated, deepfake, nsfw, and quality reports
            run.

            // Use 'only' and 'excluding' parameters to select subsets.

            // Note: ai_generated and deepfake have their own costs.


            import java.io.File;

            import java.io.IOException;

            import okhttp3.*;


            public class ImageAnalysis {
                public static void main(String[] args) {
                    String apiKey = System.getenv("AIORNOT_API_KEY");
                    String imageEndpoint = "https://api.aiornot.com/v2/image/sync";

                    OkHttpClient client = new OkHttpClient();

                    File imageFile = new File("image.jpeg");

                    RequestBody requestBody = new MultipartBody.Builder()
                        .setType(MultipartBody.FORM)
                        .addFormDataPart("image", imageFile.getName(),
                            RequestBody.create(MediaType.parse("image/jpeg"), imageFile))
                        .build();

                    HttpUrl url = HttpUrl.parse(imageEndpoint).newBuilder()
                        .addQueryParameter("external_id", "my-tracking-id")  // Optional
                        // Example: only run reverse_search:
                        // .addQueryParameter("only", "reverse_search")
                        // Example: run all defaults except deepfake:
                        // .addQueryParameter("excluding", "deepfake")
                        .build();
                    
                    Request request = new Request.Builder()
                        .url(url)
                        .header("Authorization", "Bearer " + apiKey)
                        .post(requestBody)
                        .build();
                    
                    try {
                        Response response = client.newCall(request).execute();
                        if (!response.isSuccessful()) {
                            System.err.println("Failed to analyze image: " + response.code() + " " + response.body().string());
                        } else {
                            System.out.println(response.body().string());
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
components:
  schemas:
    V2ImageReportResponse:
      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_generated:
              $ref: '#/components/schemas/AIONReportScheme'
            deepfake:
              anyOf:
                - $ref: '#/components/schemas/DeepFakeReportScheme'
                - type: 'null'
            nsfw:
              anyOf:
                - $ref: '#/components/schemas/NSFWReportScheme'
                - type: 'null'
            quality:
              anyOf:
                - $ref: '#/components/schemas/QualityReportScheme'
                - type: 'null'
            reverse_search:
              anyOf:
                - $ref: '#/components/schemas/ReverseSearchReportScheme'
                - type: 'null'
            meta:
              $ref: '#/components/schemas/ImageMetadata'
          required:
            - meta
        external_id:
          type: string
          nullable: true
          title: External Id
          description: The external identifier provided in the request, if any.
      type: object
      required:
        - id
        - report
      title: V2ImageReportResponse
    HTTPValidationError:
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
      type: object
      title: HTTPValidationError
    AIONReportScheme:
      properties:
        verdict:
          title: Verdict
          description: >-
            The predicted class of the uploaded image.


            This is the most important field in the response. This field is more
            reliable than directly using the confidence score yourself, as the
            confidence score may drift over time for new models.
          enum:
            - ai
            - human
            - unknown
        ai:
          $ref: '#/components/schemas/AIONPredictionBase'
          example:
            is_detected: true
            confidence: 0.95
        human:
          $ref: '#/components/schemas/AIONPredictionBase'
          example:
            is_detected: false
            confidence: 0.05
        generator:
          $ref: '#/components/schemas/AIONGeneratorScheme'
      type: object
      required:
        - verdict
        - ai
        - human
        - generator
      title: AIONReportScheme
    DeepFakeReportScheme:
      properties:
        is_detected:
          type: boolean
          title: Is Detected
          example: true
        confidence:
          type: number
          title: Confidence
          example: 0.95
          minimum: 0
          maximum: 1
        rois:
          items:
            $ref: '#/components/schemas/RoisReportScheme'
          type: array
          title: Rois
      type: object
      required:
        - is_detected
        - confidence
        - rois
      title: DeepFakeReportScheme
    NSFWReportScheme:
      properties:
        version:
          type: string
          title: Version
          default: 1.0.0
        is_detected:
          type: boolean
          title: Is Detected
          description: >-
            True if NSFW content found in the image. Please note that for us,
            the mere presence of a child is enough to trigger this flag. We
            offer a more granular NSFW report for clients who need it. Please
            contact us if this describes you.
      type: object
      required:
        - is_detected
      title: NSFWReportScheme
    QualityReportScheme:
      properties:
        is_detected:
          type: boolean
          title: Is Detected
          description: >-
            Indicates whether the image is of high quality. **Low quality
            (`false`) is not a asthetic judgement.** It merely means that there
            are artifacts present that indicate things like excessive
            compression or blurring which degrades the performance of other
            classifiers (e.g. ai image detection).
      type: object
      required:
        - is_detected
      title: QualityReportScheme
    ReverseSearchReportScheme:
      properties:
        was_found:
          type: boolean
          title: Was Found
          description: Indicates whether matching images were found on the web
          example: true
        matches:
          items:
            $ref: '#/components/schemas/ReverseSearchMatch'
          type: array
          title: Matches
          description: List of matching images found on the web
      type: object
      required:
        - was_found
        - matches
      title: ReverseSearchReportScheme
    ImageMetadata:
      properties:
        width:
          anyOf:
            - type: integer
            - type: 'null'
          title: Width
          example: 640
        height:
          anyOf:
            - type: integer
            - type: 'null'
          title: Height
          example: 480
        format:
          anyOf:
            - type: string
            - type: 'null'
          title: Format
          example: jpeg
        size_bytes:
          anyOf:
            - type: integer
            - type: 'null'
          title: Size Bytes
          example: 102400
        md5:
          anyOf:
            - type: string
            - type: 'null'
          title: Md5
          example: a1b2c3d4e5f6789012345678901234567
        processing_status:
          additionalProperties:
            $ref: '#/components/schemas/ReportStatus'
          propertyNames:
            $ref: '#/components/schemas/ImageReportType'
          type: object
          title: Processing Status
          example:
            ai_generated: processed
            deepfake: processed
            nsfw: processed
            quality: processed
      type: object
      required:
        - width
        - height
        - format
        - size_bytes
        - md5
        - processing_status
      title: ImageMetadata
    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
    AIONPredictionBase:
      properties:
        is_detected:
          type: boolean
          title: Is Detected
          description: Indicates whether the particular class was detected.
        confidence:
          type: number
          title: Confidence
          minimum: 0
          maximum: 1
          example: 0.95
          description: Confidence score for the particular class.
      type: object
      required:
        - is_detected
        - confidence
      title: AIONPredictionBase
    AIONGeneratorScheme:
      properties:
        midjourney:
          $ref: '#/components/schemas/AIONPredictionBase'
          example: 0.95
        dall_e:
          $ref: '#/components/schemas/AIONPredictionBase'
          example: 0.95
        stable_diffusion:
          $ref: '#/components/schemas/AIONPredictionBase'
          example: 0.95
        this_person_does_not_exist:
          $ref: '#/components/schemas/AIONPredictionBase'
          example: 0.95
        adobe_firefly:
          $ref: '#/components/schemas/AIONPredictionBase'
          example: 0.95
        flux:
          $ref: '#/components/schemas/AIONPredictionBase'
          example: 0.95
        four_o:
          $ref: '#/components/schemas/AIONPredictionBase'
          example: 0.95
      type: object
      required:
        - midjourney
        - dall_e
        - stable_diffusion
        - this_person_does_not_exist
        - adobe_firefly
        - flux
        - four_o
      title: AIONGeneratorScheme
      description: >-
        A map of generator names to their prediction base.Please note that

        - This list is not exhaustive. We have trained on more generators than
        appear here.

        - We may add new generators at any time, so please make sure your
        integration allows for field addition without error.
    RoisReportScheme:
      properties:
        is_detected:
          type: boolean
          title: Is Detected
          example: true
        confidence:
          type: number
          title: Confidence
          example: 0.95
          minimum: 0
          maximum: 1
        bbox:
          $ref: '#/components/schemas/BBoxScheme'
      type: object
      required:
        - is_detected
        - confidence
        - bbox
      title: RoisReportScheme
    ReverseSearchMatch:
      properties:
        domain:
          type: string
          title: Domain
          description: The domain where the matching image was found
          example: cnet.com
        image_url:
          type: string
          title: Image URL
          description: URL of the matching image
          example: >-
            https://img.tineye.com/result/59752e592ddca832cb36bf200135b4f30f6fadca2ea4acc7c63f8dd231463c72-43
        width:
          type: integer
          title: Width
          description: Width of the matching image in pixels
          example: 196
        height:
          type: integer
          title: Height
          description: Height of the matching image in pixels
          example: 147
        earliest_crawl_date:
          type: string
          title: Earliest Crawl Date
          description: The earliest date this image was crawled (YYYY-MM-DD format)
          example: '2021-03-26'
        earliest_backlink:
          type: string
          title: Earliest Backlink
          description: URL of the earliest page where this image was found
          example: https://www.cnet.com/topics/internet-culture/2/
      type: object
      required:
        - domain
        - image_url
        - width
        - height
        - earliest_crawl_date
        - earliest_backlink
      title: ReverseSearchMatch
    ReportStatus:
      type: string
      enum:
        - processed
        - rejected
        - errored
      title: ReportStatus
    BBoxScheme:
      properties:
        x1:
          type: integer
          title: X1
          example: 120
        y1:
          type: integer
          title: Y1
          example: 85
        x2:
          type: integer
          title: X2
          example: 380
        y2:
          type: integer
          title: Y2
          example: 295
      type: object
      required:
        - x1
        - y1
        - x2
        - y2
      title: BBoxScheme
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer
      description: >-
        Your [API key](https://www.aiornot.com/dashboard/api) as the `Bearer`
        token in the `Authorization` header.

````