Assuming,

  1. You followed the 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.

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/v1/reports/image"

with open("image.jpeg", "rb") as image_file:
    files = {"object": 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,

{
  "id": "321a0712-f725-419a-a471-5da1be3d77e3",
  "created_at": "2025-05-07T18:27:03.880456",
  "report": {
    "verdict": "ai",
    "ai": {
      "is_detected": true,
      "confidence": 0.9904811382293701
    },
    "human": {
      "is_detected": false,
      "confidence": 0.009518861770629883
    },
    "generator": {
      "midjourney": {
        "is_detected": false,
        "confidence": 0.002896074438467622
      },
      "dall_e": {
        "is_detected": false,
        "confidence": 1.5073396752995905e-05
      },
      "stable_diffusion": {
        "is_detected": false,
        "confidence": 0.001489652437157929
      },
      "this_person_does_not_exist": {
        "is_detected": false,
        "confidence": 0.00239231763407588
      },
      "adobe_firefly": {
        "is_detected": false,
        "confidence": 0.0011274905409663916
      },
      "flux": {
        "is_detected": false,
        "confidence": 0.001558194519020617
      },
      "four_o": {
        "is_detected": true,
        "confidence": 0.9810022711753845
      }
    }
  },
  "facets": {
    "quality": {
      "is_detected": true
    },
    "nsfw": {
      "version": "1.0.0",
      "is_detected": false
    }
  }
}

Translating this response to human terms,

  • The id is the unique identifier for this API invocation.
  • The image is likely to be AI generated
  • The image is of high quality (no excessive blur or compression artifacts)
  • The image has no NSFW content
  • The image was likely generated by OpenAI 4o

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.