# A Complete Example Source: https://docs.aiornot.com/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/). # Audio - Music Source: https://docs.aiornot.com/api-reference/reports-by-modality/audio--music api-reference/openapi.yaml post /v1/reports/music Analyze an **audio file** to determine if it was generated by an AI *music* model. This endpoint is only appropriate when you are looking for ai versus human generated music. Music means both singing (vocals) and instrumentals. **Warning: This endpoint can take up two minutes for long duration audio files or if our backend is spinning up additional processing nodes. Please set a two minute timeout in your client.** # Audio - Voice Source: https://docs.aiornot.com/api-reference/reports-by-modality/audio--voice api-reference/openapi.yaml post /v1/reports/voice Analyze an **audio file** to determine if it was generated by an AI *voice* model. This endpoint is only appropriate when you are looking for ai versus human generated voices. It is not appropriate for music (including singing). **Warning: This endpoint can take up two minutes for long duration audio files or if our backend is spinning up additional processing nodes. Please set a two minute timeout in your client.** # Image Source: https://docs.aiornot.com/api-reference/reports-by-modality/image api-reference/openapi.yaml post /v2/image/sync 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 # Text Source: https://docs.aiornot.com/api-reference/reports-by-modality/text api-reference/openapi.yaml post /v2/text/sync 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 # Video Source: https://docs.aiornot.com/api-reference/reports-by-modality/video api-reference/openapi.yaml post /v2/video/sync Analyze a **video file** to determine if it contains AI-generated content. This endpoint analyzes both the video and audio components of the file, providing separate confidence scores for AI-generated video, voice, and music. It can also optionally detect deepfake video content when explicitly requested. **Caveats**: * This endpoint can take up to two minutes for longer video files or if our backend is spinning up additional processing nodes. Please set a 120 second timeout in your client. * This endpoint is synchronous and will only analyze a portion of the content for longer duration videos. The response includes the duration tested. For videos longer than 30 seconds, we recommend breaking them into 30-second segments on the client side for complete analysis. * Due to a limitation in our document provider, the playground only supports small files of up to 10MB. This limit does not apply when using the API directly. # Is Live Source: https://docs.aiornot.com/api-reference/system-management/is-live api-reference/openapi.yaml get /v1/system/live Check if the API is live. This is useful for diagnosing issues with your integration. Is there a bug on your side, or are we simply down? You should not hit this endpoint very frequently as our system may flag it as abuse. Please see also [our status page](https://status.aiornot.com/). # Introduction Source: https://docs.aiornot.com/index What is the AI Or Not API? The **AI or Not API** lets you automatically verify whether **images, audio clips, or videos were created with or tampered by generative-AI models**. Designed for developers who need fast, reliable content provenance checks—moderation teams, media platforms, forensic analysts, compliance tools, and researchers—our API returns a clear verdict plus confidence scores and model-specific insights in a single call. **Why use it?** * **State-of-the-art accuracy** – powered by continually updated detectors trained on the latest generative models (e.g. diffusion, GAN, transformers, etc). * **Privacy first** – uploaded media are processed and deleted immediately after inference. * **Granular feedback** – JSON responses include flags for ai detection as well as an ever-expanding list of per-modality specific features # Getting Started Source: https://docs.aiornot.com/setup How to get started with the AI or Not API ## Overview 1. **Create an account:** Visit [aiornot.com](https://aiornot.com) and choose any plan that includes the API access you need. 2. **Locate your API key:** Once logged in, head to **[API](https://www.aiornot.com/dashboard/api)** tab and click copy the generated key. 3. **Call appropriate API endpoint**: See the [API Reference](/api-reference) for details. ## Authentication All permissioned endpoints require the API key as a bearer token in the `Authorization` header. This key is a secret and should be stored securely. Think of it like your password. Anyone with access to this key can make requests to the API on your behalf, using your quota. Code examples in the [API Reference](/api-reference) show how to include the API key in your requests. ## Response Serialization The API returns JSON responses. [API Reference](/api-reference) shows what that response format looks like for each endpoint. However, there is one critical thing to note when integrating the API into your application: We may add additional fields to existing endpoint responses without changing the API version. However, we will never remove or rename a field without releasing a new API version. Successful integrations must be resilient to new fields. This allows us to add new information to responses (e.g. a new image generator classification) without breaking existing integrations. To make this more concrete, image you are using pydantic in Python to deserialize the response. At integration time, you might have code that looks like, ```python theme={null} class ExampleResp(BaseModel): is_ai: bool ``` which successfully deserializes responses like, ```json theme={null} { "is_ai": true } ``` If we added a new field to the response, e.g. ```json theme={null} { "is_ai": true, "is_upscaled": false } ``` your deserialization code will break unless you had something like, ```python theme={null} class ExampleResp(BaseModel): is_ai: bool # Ignore any extra fields in the response model_config = ConfigDict(extra='ignore') ``` Otherwise, please carefully observe which fields are optional (e.g. can be `null`) in particular responses. Some endpoints return `null` responses for sub-model errors without failing completely, so long as the primary model was successfully (e.g. `quality` in the image model). ## Rate Limiting Depending on your plan, you may be subject to rate limits between 1 and 5 requests per second. This limit exists to prevent abuse of the API. It is not a technical constraint. If you need a higher limit, please [contact us](mailto:support@aiornot.com).