> For the complete documentation index, see [llms.txt](https://manual.personr.co/api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manual.personr.co/api-documentation/modules/predicting-a-synthesised-image.md).

# Predicting a synthesised image

Once an image has been submitted, our machine learning model will predict the likelihood of the provided image being artificially generated by other models such as Stable Diffusion or Midjourney.

In our testing, each model performed at >80% accuracy in detecting whether an image was a deepfake within their category. The following models are available for use:

<table><thead><tr><th>Model Name</th><th width="137">Accuracy</th><th width="366">Description</th></tr></thead><tbody><tr><td><code>Personr_DF_5M</code></td><td>0.923</td><td>Trained on a size of 5M parameters (Stable Diffusion v1.4, v1.5, v2.1), and designed to detect Stable Diffusion-generated images.</td></tr><tr><td><code>Personr_DF_200M</code></td><td>0.950</td><td>Trained on a size of 200M parameters (Stable Diffusion v1.4, v1.5, v2.1), and designed to detect Stable Diffusion-generated images.</td></tr><tr><td><code>Personr_MJ_5M</code></td><td>0.849</td><td>Trained on a size of 5M parameters (Midjourney v4, v5.1, v5.2), and designed to detect Midjourney-generated images.</td></tr><tr><td><code>Personr_MJ_200M</code></td><td>0.902</td><td>Trained on a size of 200M parameters (Midjourney v4, v5.1, v5.2), and designed to detect Midjourney-generated images.</td></tr><tr><td><code>Personr_Deepfake_v5</code></td><td>0.959</td><td>Our most accurate model, trained on 200M parameters using a combination of Stable Diffusion and Midjourney-generated images. </td></tr></tbody></table>

Supported file formats include: `.PNG`, `.JPEG` & `.JPG`

{% hint style="info" %}
Extremely bright or vibrant images may affect accuracy during prediction. Additionally, predictions are indications and shouldn't be considered a definitive answer.
{% endhint %}

## Predicting a synthesised image

<mark style="color:green;">`POST`</mark> `/api-deepfake-detection`

Detect whether an image has been artificially generated.

**Headers**

| Name          | Value               |
| ------------- | ------------------- |
| Content-Type  | `application/json`  |
| Authorization | `Bearer YOUR_TOKEN` |

**Body**

<table><thead><tr><th>Name</th><th width="111">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>imageUrl</code></td><td>string</td><td>The URL of the image, including file extension <mark style="color:red;">(required)</mark></td></tr><tr><td><code>modelName</code></td><td>string</td><td>The name of the model you want to use for prediction, shown above <mark style="color:red;">(required)</mark></td></tr><tr><td><code>token</code></td><td>string</td><td>The token provided to you during onboarding. This is separate from your Bearer token and exclusive to this endpoint <mark style="color:red;">(required)</mark></td></tr></tbody></table>

#### Request

{% tabs %}
{% tab title="cURL" %}

```sh
curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "imageUrl": "YOUR_IMAGE_URL/image.jpg",
    "modelName": "MODEL_NAME",
    "token": "YOUR_ENDPOINT_TOKEN"
}' \
  https://enterprise.personr.co/api/1.1/wf/api-deepfake-detection
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const axios = require('axios');

const url = 'https://enterprise.personr.co/api/1.1/wf/api-deepfake-detection';
const token = 'YOUR_BEARER_TOKEN';
const endpointToken = 'YOUR_ENDPOINT_TOKEN';

const data = {
    imageUrl: 'YOUR_IMAGE_URL/image.jpg',
    modelName: 'Personr_DF_5M',
    token: endpointToken
};

const config = {
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${token}`
    }
};

axios.post(url, data, config)
    .then(response => {
        console.log(response.data);
    })
    .catch(error => {
        console.error('Error:', error);
    });

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'uri'
require 'json'

url = URI.parse('https://enterprise.personr.co/api/1.1/wf/api-deepfake-detection')
token = 'YOUR_BEARER_TOKEN'
endpoint_token = 'YOUR_ENDPOINT_TOKEN'

data = {
  imageUrl: 'YOUR_IMAGE_URL/image.jpg',
  modelName: 'Personr_DF_5M',
  token: endpoint_token
}

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url.path)
request['Content-Type'] = 'application/json'
request['Authorization'] = "Bearer #{token}"
request.body = data.to_json

response = http.request(request)

puts response.body
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = 'https://enterprise.personr.co/api/1.1/wf/api-deepfake-detection'
token = 'YOUR_BEARER_TOKEN'
endpoint_token = 'YOUR_ENDPOINT_TOKEN'

data = {
    'imageUrl': 'hYOUR_IMAGE_URL/image.jpg',
    'modelName': 'Personr_DF_5M',
    'token': endpoint_token
}

headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {}'.format(token)
}

response = requests.post(url, json=data, headers=headers)

if response.status_code == 200:
    print(response.json())
else:
    print('Error:', response.text)
```

{% endtab %}
{% endtabs %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "response": {
        "result": "Artificial",
        "labels": [
            "Artificial",
            "Genuine"
        ],
        "confidence": [
            0.875041127204895,
            0.12495886534452438
        ]
    }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "statusCode": 400,
    "message": "Error: incorrect modelName provided"
}
```

{% endtab %}

{% tab title="401" %}

```json
{
    "error_class": "Unauthorized",
    "args": {
        "code": "1709700303639x0000000000000"
    },
    "message": null,
    "translation": "Invalid or expired token: ABC123"
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://manual.personr.co/api-documentation/modules/predicting-a-synthesised-image.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
