# Detect AI in images

> Check whether an image was generated with AI. Upload a file or pass a URL to POST /v1/detect, and optionally ask for an experimental edited-region heatmap.

To check an image, send it to `POST /v1/detect` as a file upload (`multipart/form-data`) or as a public URL (JSON or form). Send one image per request. The check is synchronous, so the response contains the finished result. [Pricing and plans](https://ringingbytes.com/docs/pricing) lists the price per image.

## Upload a file

**cURL**
```sh
curl https://api.ringingbytes.com/v1/detect \
  -H "Authorization: Bearer $RINGING_BYTES_API_KEY" \
  -F file=@photo.jpg
```

**Node.js**
```js

const form = new FormData();
form.set("file", await openAsBlob("photo.jpg"), "photo.jpg");

const response = await fetch("https://api.ringingbytes.com/v1/detect", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.RINGING_BYTES_API_KEY}` },
  body: form,
});
console.log(await response.json());
```

**Python**
```python

with open("photo.jpg", "rb") as f:
    response = requests.post(
        "https://api.ringingbytes.com/v1/detect",
        headers={"Authorization": f"Bearer {os.environ['RINGING_BYTES_API_KEY']}"},
        files={"file": f},
    )
print(response.json())
```

An image can be up to 25 MB and 120 megapixels. The API accepts JPEG, PNG, WebP, GIF, TIFF, BMP, AVIF and MPO. Any other format, including HEIC, gets `415 UNSUPPORTED_MEDIA_TYPE`. We keep nothing once the result is delivered. See [Data retention](https://ringingbytes.com/docs/data-retention).

## Pass a URL

For an image that is already online, send its URL as JSON. The URL must be public and use `http` or `https` on the standard ports. We download the image for the check and never keep a copy of it.

**cURL**
```sh
curl https://api.ringingbytes.com/v1/detect \
  -H "Authorization: Bearer $RINGING_BYTES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg"}'
```

**Node.js**
```js
const response = await fetch("https://api.ringingbytes.com/v1/detect", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.RINGING_BYTES_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ url: "https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg" }),
});
console.log(await response.json());
```

**Python**
```python

response = requests.post(
    "https://api.ringingbytes.com/v1/detect",
    headers={"Authorization": f"Bearer {os.environ['RINGING_BYTES_API_KEY']}"},
    json={"url": "https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg"},
)
print(response.json())
```

## What runs on an image

Every image check returns these three signals:

| Signal | What it tells you |
| --- | --- |
| `generated_classifier` | A model's score (0 to 1) for whether the whole image was generated by AI. The model is not trained to spot small local edits. |
| `c2pa` | Whether the file carries Content Credentials, whether they declare AI generation (`ai_generated`), which tool made the file (`generator`) and who signed them (`validation_state`, `signer`). A declaration from a trusted signer makes the verdict `likely_ai` with high confidence. From a signer that is not trusted, it is only a hint. A missing record proves nothing. |
| `metadata` | Camera make and model, editing software, and whether EXIF, XMP or PNG metadata names an AI tool (`has_exif`, `camera`, `software`, `ai_hint`). It is a weak signal, because anyone can strip or forge metadata. |

## Edited-region heatmap (`localize`, experimental)

The heatmap (`localize=true`) is an experimental, opt-in option of the API: it is slower (several seconds), it counts as 3 image checks when it returns a heatmap (one check when it does not), and it is a hint for a reviewer that also highlights parts of some unedited photos. The integrations do not run it.

With `localize=true`, a separate edit-localization model also runs on the image. It estimates which regions were edited, for example a pasted-in or inpainted patch, and the response gains an `edit_localization` signal with a `score` and an `area_fraction`. When a map is produced, the `POST` response carries the heatmap PNG inline as `heatmap_png_base64`. It is not kept, so save it if you need it.

The model also marks regions on many unedited photos. Use the heatmap to show a reviewer where to look, and do not treat it as proof of an edit. A strong edit score (0.9 or more) turns a `likely_human` result into `uncertain`; it never produces `likely_ai`. When the signal is present, the dashboard's explanation of a Likely AI result mentions AI editing as well as generation.

```sh
curl https://api.ringingbytes.com/v1/detect \
  -H "Authorization: Bearer $RINGING_BYTES_API_KEY" \
  -F file=@photo.jpg \
  -F localize=true
```

In a JSON request with `url`, send `"localize": true`. If the edit-localization model is not available, the response leaves out the signal, the rest of the result is the same, and the check costs one normal image check.

## Look up past checks

Every check has an `id`. `GET /v1/detections/{id}` returns its usage entry, and `GET /v1/detections?limit=20&before=<id>` lists your organization's checks, newest first, a page at a time (up to 100 per page). Looking up and listing are free. Nothing is kept once a result is delivered, so these return the usage entry only: id, status, times and credits, never the file name, verdict or signals. See [Data retention](https://ringingbytes.com/docs/data-retention).

```sh
curl "https://api.ringingbytes.com/v1/detections?limit=20" \
  -H "Authorization: Bearer $RINGING_BYTES_API_KEY"
```

## Tips for better results

- Send the original file. Screenshots and copies recompressed by a chat app have lost evidence the detector looks for.
- Do not crop or resize the image before you send it.
- Read the `c2pa` and `metadata` signals as well as the verdict: they show where the result came from.
