# AI Text Moderation API

## About

This Utility API uses AI to safeguard content by analyzing textual content against safety attributes like toxicity, violence, and other sensitive topics.

This API categorizes content into harmful categories such as derogatory language, violent scenarios, sexual references, insults, profanity, and more. Confidence scores provide insights into the likelihood of content belonging to specific categories. This API is essential for maintaining a safe online environment, ensuring that user-generated text adheres to community guidelines and content standards. It provides a quick and reliable solution for text moderation, minimizing the exposure of undesirable content and fostering a positive user experience.

The atoms cost is subjected to change depending on the size of the input file and the provider selected. The list of providers and the atoms cost for each provider is given below:

| Provider (requested_service) | Atoms |
| ----------------------------- | ----- |
| Google                        | 500   |

## API Playground

ApyHub AI

This API endpoint does not have a playground. You can test it with Voiden.

## API Documentation

### Request example

```bash
curl --location --request POST 'https://api.apyhub.com/ai/text/moderation' \
--header 'apy-token: {{token}}' \
--header 'Content-Type: application/json' \
--data '{
    "text": "Shut up!",
    "requested_service": "google",
    "google": {
        "key": "your-google-key"
    }
}'
```

**Method:** `POST`

**Content Type:** `application/json`

**Request Body**

| Attribute            | Type   | Mandatory | Description                                                                                 |
| ---------------------| ------ | --------- | ------------------------------------------------------------------------------------------- |
| text                 | String | Yes       | Provide the textual content for which you want to perform text moderation.                  |
| requested_service    | String | Yes       | Enter the name of service provider. Supported providers are `google`.                      |
| google.key          | String | Yes       | Input service key provided by google.                                                     |

**Sample Response**

A successful request returns the text moderation response in the output parameter specified. If the request fails, the response contains an error code and a message to help determine what went wrong.

### HTTP Response Codes

The method may return one of the following HTTP status codes:

| Status Code | Description                                   |
| ----------- | --------------------------------------------- |
| 200         | The request was successful.                  |
| 400         | Invalid input - the file is corrupt or the supported inputs are not provided. |
| 401         | Required authentication information is either missing or not valid for the resource. |
| 500         | If any unexpected error occurs while processing the request. |

## Authentication

All API requests to ApyHub services need to be authenticated. Currently we support `tokens` or `basic authentication` mechanisms. You can generate and view your existing credentials from your workspace settings.

Points to note:

- Credential secrets are generated on the fly and are not stored in plain text, so on generating a credential please save the secrets somewhere safe.
- Use the `apy-token` as the header parameter to pass the token.
- Use the `Authorization` header to send the basic authentication credentials.

## Error codes

```json
{
  "error": {
    "code": 105,
    "message": "Invalid URL"
  }
}
```

To search for a specific error code, enter the code in the search box below.

##### 101 - Missing parameters
This code is returned when mandatory parameters are missing from the request.

##### 102 - Invalid JSON
This code is returned when invalid JSON is passed in the request body.

##### 103 - Invalid input
This code is returned when an invalid input is provided.

##### 104 - Invalid file
This code is returned when there is an issue with a file.

##### 105 - Invalid URL
This code is returned when there is an issue with a URL.

##### 109 - Invalid input format
This code is returned when input is not provided in the required format.

##### 110 - Server error
This code is returned when an unexpected error occurs while processing a request.

## Reviews

4.3 / 5

32 ratings

5  4  3  2  1

### AI Image Explicit Content Detection API

Flag adult and violent content in images with the AI Image Explicit Content Detection API.

### AI Video Explicit Content Detection API

Detect adult content in images with the AI Video Explicit Content Detection API.

### AI Text Entity Sentiment Analysis API

Analyze sentiment toward entities in text using the AI Text Entity Sentiment Analysis API.

### AI Text Entity Recognition API

Identify entities like people, places, and organizations with the AI Text Entity Recognition API.
