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()){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"report": {
"meta": {
"width": 640,
"height": 480,
"format": "jpeg",
"size_bytes": 102400,
"md5": "a1b2c3d4e5f6789012345678901234567",
"processing_status": {
"ai_generated": "processed",
"deepfake": "processed",
"nsfw": "processed",
"quality": "processed"
}
},
"ai_generated": {
"verdict": "ai",
"ai": {
"is_detected": true,
"confidence": 0.95
},
"human": {
"is_detected": false,
"confidence": 0.05
},
"generator": {
"midjourney": 0.95,
"dall_e": 0.95,
"stable_diffusion": 0.95,
"this_person_does_not_exist": 0.95,
"adobe_firefly": 0.95,
"flux": 0.95,
"four_o": 0.95
}
},
"deepfake": {
"is_detected": true,
"confidence": 0.95,
"rois": [
{
"is_detected": true,
"confidence": 0.95,
"bbox": {
"x1": 120,
"y1": 85,
"x2": 380,
"y2": 295
}
}
]
},
"nsfw": {
"is_detected": true,
"version": "1.0.0"
},
"quality": {
"is_detected": true
},
"reverse_search": {
"was_found": true,
"matches": [
{
"domain": "cnet.com",
"image_url": "https://img.tineye.com/result/59752e592ddca832cb36bf200135b4f30f6fadca2ea4acc7c63f8dd231463c72-43",
"width": 196,
"height": 147,
"earliest_crawl_date": "2021-03-26",
"earliest_backlink": "https://www.cnet.com/topics/internet-culture/2/"
}
]
}
},
"created_at": "2023-11-07T05:31:56Z",
"external_id": "<string>"
}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:
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()){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"report": {
"meta": {
"width": 640,
"height": 480,
"format": "jpeg",
"size_bytes": 102400,
"md5": "a1b2c3d4e5f6789012345678901234567",
"processing_status": {
"ai_generated": "processed",
"deepfake": "processed",
"nsfw": "processed",
"quality": "processed"
}
},
"ai_generated": {
"verdict": "ai",
"ai": {
"is_detected": true,
"confidence": 0.95
},
"human": {
"is_detected": false,
"confidence": 0.05
},
"generator": {
"midjourney": 0.95,
"dall_e": 0.95,
"stable_diffusion": 0.95,
"this_person_does_not_exist": 0.95,
"adobe_firefly": 0.95,
"flux": 0.95,
"four_o": 0.95
}
},
"deepfake": {
"is_detected": true,
"confidence": 0.95,
"rois": [
{
"is_detected": true,
"confidence": 0.95,
"bbox": {
"x1": 120,
"y1": 85,
"x2": 380,
"y2": 295
}
}
]
},
"nsfw": {
"is_detected": true,
"version": "1.0.0"
},
"quality": {
"is_detected": true
},
"reverse_search": {
"was_found": true,
"matches": [
{
"domain": "cnet.com",
"image_url": "https://img.tineye.com/result/59752e592ddca832cb36bf200135b4f30f6fadca2ea4acc7c63f8dd231463c72-43",
"width": 196,
"height": 147,
"earliest_crawl_date": "2021-03-26",
"earliest_backlink": "https://www.cnet.com/topics/internet-culture/2/"
}
]
}
},
"created_at": "2023-11-07T05:31:56Z",
"external_id": "<string>"
}Array of analysis types to include. Valid values are ai_generated, deepfake, nsfw, quality, reverse_search.
ai_generated, deepfake, nsfw, quality, reverse_search Array of analysis types to exclude. Valid values are ai_generated, deepfake, nsfw, quality, reverse_search.
ai_generated, deepfake, nsfw, quality, reverse_search An optional external identifier for tracking this image analysis.
The image file to analyze.
Successful Response
Unique identifier associated with the request.
Show child attributes
Show child attributes
640
480
"jpeg"
102400
"a1b2c3d4e5f6789012345678901234567"
Show child attributes
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.
ai, human, unknown { "is_detected": true, "confidence": 0.95 }{ "is_detected": false, "confidence": 0.05 }A map of generator names to their prediction base.Please note that
Show child attributes
0.95
Show child attributes
0.95
Show child attributes
0.95
0.95
Show child attributes
true
0 <= x <= 10.95
Show child attributes
true
0 <= x <= 10.95
Show child attributes
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.
Show child attributes
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).
Show child attributes
Indicates whether matching images were found on the web
true
List of matching images found on the web
Show child attributes
The domain where the matching image was found
"cnet.com"
URL of the matching image
"https://img.tineye.com/result/59752e592ddca832cb36bf200135b4f30f6fadca2ea4acc7c63f8dd231463c72-43"
Width of the matching image in pixels
196
Height of the matching image in pixels
147
The earliest date this image was crawled (YYYY-MM-DD format)
"2021-03-26"
URL of the earliest page where this image was found
"https://www.cnet.com/topics/internet-culture/2/"
Date and time of request processing.
The external identifier provided in the request, if any.