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

# A Complete Example

> Showing how to use the AI or Not API to analyze an image

Assuming,

1. You followed the [setup](/setup) guide; and,
2. You have an image file named `image.jpeg` that is less than 10mb in the current working directory

you can use the following example to analyze an image in python.

```python theme={null}
import os
import json
import 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"

with open("image.jpeg", "rb") as image_file:
    files = {"image": image_file}
    resp = requests.post(
        IMAGE_ENDPOINT, 
        headers={"Authorization": f"Bearer {API_KEY}"},
        files=files
    )
    if resp.status_code != 200:
        raise Exception(f"Failed to analyze image: {resp.status_code} {resp.text}")

print(json.dumps(resp.json(), indent=2))
```

which produces the following response,

```json theme={null}
{
  "id": "43929c9e-b937-4264-af1a-61a9716cfdbf",
  "created_at": "2025-07-14T18:48:03.157216",
  "report": {
    "ai_generated": {
      "verdict": "ai",
      "ai": {
        "is_detected": true,
        "confidence": 0.9448609948158264
      },
      "human": {
        "is_detected": false,
        "confidence": 0.055139005184173584
      },
      "generator": {
        "midjourney": {
          "is_detected": false,
          "confidence": 0.001170043833553791
        },
        "dall_e": {
          "is_detected": false,
          "confidence": 0.0017847046256065369
        },
        "stable_diffusion": {
          "is_detected": false,
          "confidence": 0.0022048193495720625
        },
        "this_person_does_not_exist": {
          "is_detected": false,
          "confidence": 0.012831537052989006
        },
        "adobe_firefly": {
          "is_detected": false,
          "confidence": 0.0019781156443059444
        },
        "flux": {
          "is_detected": true,
          "confidence": 0.922024667263031
        },
        "four_o": {
          "is_detected": false,
          "confidence": 0.002867103088647127
        }
      }
    },
    "deepfake": {
      "is_detected": false,
      "confidence": 0.4589413106441498,
      "rois": [
        {
          "is_detected": false,
          "confidence": 0.4589413106441498,
          "bbox": {
            "x1": 361,
            "y1": 207,
            "x2": 672,
            "y2": 519
          }
        }
      ]
    },
    "nsfw": {
      "is_detected": false
    },
    "quality": {
      "is_detected": true
    },
    "meta": {
      "width": 944,
      "height": 1104,
      "format": "PNG",
      "size_bytes": 1248257,
      "md5": "abb915708f924e9e224fc79efb792e49",
      "processing_status": {
        "ai_generated": "processed",
        "deepfake": "processed",
        "nsfw": "processed",
        "quality": "processed"
      }
    }
  },
  "external_id": "my-tracking-id"
}
```

Translating this response to human terms,

* The `id` is the unique identifier for this API invocation.
* The `external_id` shows the tracking ID we provided in the request
* The image is likely to be AI generated (verdict: "ai")
* The image was likely generated by Flux (highest confidence at 92.2%)
* The image is not a deepfake (confidence below 50%)
* The image has no NSFW content
* The image is of high quality (no excessive blur or compression artifacts)
* The `meta` section provides technical details about the image (944x1104 PNG, \~1.2MB)

Please note that the particular confidence scores may vary over time
as we update our models. However, in general, the higher the confidence,
the more likely the given class was detected.

For all available endpoints, see the [API Reference](/api-reference/reports-by-modality/).
