☑️Standard & Premium: Policy Classification endpoints

The Policy Classification endpoints will serve you two products: Unitary Standard and Unitary Premium. The table below shows more details for each:

Product
Categories covered
How it works

Standard

Adult & Sexual. Explicit sexual activity, nudity, detailed explanations of sexual encounters…

• Non-medical Drugs. Pills, coke, marihuana, minors drinking or smoking, paraphernalia…

• Violence and Injury. People killing or sexually assaulting other people, violent fights in uncontrolled settings, animal abuse, physical threats, suicide, self-injury or eating disorders and their glorification, graphic injuries...

• Weapons and Firearms. Firearms, ammunition, explosives, non-kitchen knives or homemade weapons in dangerous settings, instructional content on weapons…

• Hate Speech and Hate Symbols. Symbols from hate organisations, discrimination of people based on their identity…

The Standard product works "off the shelf". It does not require any input from your side. Please let us know if you need help analysing Untiary's model responses to set up decision thresholds.

To see improved performance over time, you can also get in contact to share false negatives and positives and make Unitary's models better for your use case.

Premium

All Standard categories tweaked based on your content guidelines + any other categories you may need e.g. cosmetic products.

The Premium product will give you greater accuracy by understanding your content guidelines and getting fine-tuned with your data. You can benefit from Unitary's Premium offering category by category. Please get in contact if you are interested in this.

For both the Standard and Premium products, Unitary will return in the classification results a raw score that you can use to set thresholds and determine if data is safe, harmful or ambiguous.

Please read How to select thresholdsif you need help analysing the Standard scores. We'll give you custom thresholds for any premium category we fine-tune to your policy or data.

1. Authenticate

Please follow the API Authentication instructions first in order to authenticate with Unitary's API. This will generate a token that is valid for 24 hours and must be used in subsequent API requests.

2. Sending your first request

Depending on your use case, pick an image or a video and then use one of the following POST endpoints to send your first request.

POST endpoint reference

Queue an image for Policy classification

post

This endpoint predicts the policy categories of a single image.

The request must contain a url form field (a string containing a URL to download the image file from).

Example CURL:

curl --location --request POST "https://api.unitary.ai/v1/classify/policy/image" --header "Authorization: Bearer {API_TOKEN}" --header "Content-Type: multipart/form-data" --form "url={RESOURCE_URL}"
Authorizations
Body
callback_urlstring · uri · min: 1 · max: 2083Optional
captionstringOptional
urlstring · uri · min: 1 · max: 65536Optional
Responses
200
Successful Response
application/json
post
POST /classify/policy/image HTTP/1.1
Host: 
Authorization: Bearer JWT
Content-Type: application/x-www-form-urlencoded
Accept: */*
Content-Length: 83

"callback_url='https://example.com'&caption='text'&url='https://example.com'"
{
  "job_id": "text"
}

Queue a video for Policy classification

post

This endpoint predicts the policy categories of a single video.

The request must contain a url form field (a string containing a URL to download the video file from).

Example CURL:

curl --location --request POST "https://api.unitary.ai/v1/classify/policy/video" --header "Authorization: Bearer {API_TOKEN}" --header "Content-Type: multipart/form-data" --form "url={RESOURCE_URL}"
Authorizations
Body
callback_urlstring · uri · min: 1 · max: 2083Optional
captionstringOptional
urlstring · uri · min: 1 · max: 65536Optional
Responses
200
Successful Response
application/json
post
POST /classify/policy/video HTTP/1.1
Host: 
Authorization: Bearer JWT
Content-Type: application/x-www-form-urlencoded
Accept: */*
Content-Length: 83

"callback_url='https://example.com'&caption='text'&url='https://example.com'"
{
  "job_id": "text"
}

Example code

curl --location --request POST "https://api.unitary.ai/v1/classify/policy/image" \
--header "Authorization: Bearer {API_TOKEN}" \
--form "caption={CAPTION}" \
--form "url={RESOURCE_URL}"

3. Get results back via the GET endpoint

GET endpoint reference

Retrieve the results of a queued Policy classification job

get
Authorizations
Path parameters
job_idstring · uuid4Required
Responses
200
Successful Response
application/json
get
GET /classify/policy/image/{job_id} HTTP/1.1
Host: 
Authorization: Bearer JWT
Accept: */*
{
  "status": "done",
  "results": {
    "url": "https://example.com",
    "policy_categories": [
      {
        "name": "ARMS_AMMO",
        "description": "Arms & Ammunition",
        "risk_level": "high",
        "score": 0.8
      }
    ]
  },
  "msg": "text"
}

Retrieve the results of a queued Policy classification job

get
Authorizations
Path parameters
job_idstring · uuid4Required
Responses
200
Successful Response
application/json
get
GET /classify/policy/video/{job_id} HTTP/1.1
Host: 
Authorization: Bearer JWT
Accept: */*
{
  "status": "done",
  "results": {
    "url": "https://example.com",
    "policy_categories": [
      {
        "name": "ARMS_AMMO",
        "description": "Arms & Ammunition",
        "risk_level": "high",
        "score": 0.8
      }
    ],
    "metadata": {
      "width": 1,
      "height": 1,
      "fps": 1,
      "duration": 1,
      "seconds_processed": 1
    }
  },
  "msg": "text"
}

Example code

curl --location --request GET "https://api.unitary.ai/v1/classify/image/{JOB_ID}" \
--header "Authorization: Bearer {BEARER_TOKEN}"

Example responses

Depending on the processing status of the job at the time of request, you can get any of the following as the response from the GET endpoints:

{
  "status": "done",
  "results": {
    "policy_categories": [
      {
        "name": "{CATEGORY_NAME}",
        "description": "{CATEGORY_DESCRIPTION}",
        "score": 0.99
      }
    ],
    "url": "{RESOURCE_URL}"
  }
}

4. Webhooks

(optional but encouraged)

In order to have a scalable end-to-end integration, the last step is to set up the receiving of webhooks as described in the following guide: Integrating Webhooks

Last updated

Was this helpful?