# text-moderation

{% hint style="info" %}
Чтобы отправлять авторизованные запросы нужно получить API ключ, как это сделать написано в разделе [**С чего начать?**](https://docs.gptunnel.ru/)
{% endhint %}

## Модерация текста

<mark style="color:green;">`POST`</mark> `https://gptunnel.ru/v1/moderations`

Синхронный запрос к модели *text*-*moderation*-latest

#### Headers

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | string | API ключ    |

#### Request Body

| Name                                    | Type   | Description              |
| --------------------------------------- | ------ | ------------------------ |
| input<mark style="color:red;">\*</mark> | string | Контент                  |
| useWalletBalance                        | bool   | Использовать личный счет |

{% tabs %}
{% tab title="200: OK Успешный ответ" %}
{% code fullWidth="false" %}

```
{
	"id": "modr-9b51yQZrBNIHDrIeX5bBcftbj5wgs",
	"model": "text-moderation-007",
	"results": [
		{
			"flagged": false,
			"categories": {
				"sexual": false,
				"hate": false,
				"harassment": false,
				"self-harm": false,
				"sexual/minors": false,
				"hate/threatening": false,
				"violence/graphic": false,
				"self-harm/intent": false,
				"self-harm/instructions": false,
				"harassment/threatening": false,
				"violence": false
			},
			"category_scores": {
				"sexual": 0.00009054947440745309,
				"hate": 0.00007182655826909468,
				"harassment": 0.00016347762721125036,
				"self-harm": 0.0000020744676021422492,
				"sexual/minors": 0.000013518638297682628,
				"hate/threatening": 0.0000010106600711878855,
				"violence/graphic": 0.00001040412189468043,
				"self-harm/intent": 4.586087243296788e-7,
				"self-harm/instructions": 3.98835481973947e-7,
				"harassment/threatening": 0.000023142851205193438,
				"violence": 0.00013958947965875268
			}
		}
	],
	"usage": {
		"prompt_tokens": 5,
		"completion_tokens": 0,
		"prompt_cost": 0.00005,
		"completion_cost": 0,
		"total_cost": 0.00005
	}
}
```

{% endcode %}
{% endtab %}

{% tab title="404: Not Found Модель не найдена" %}

```json
{
  "error": {
    "message": "The model 'gpt-5' does not exist",
    "type": "invalid_request_error",
    "param": null,
    "code": "model_not_found"
  }
}
```

{% endtab %}

{% tab title="402: Payment Required Недостаточно средств" %}

```json
{
  "error": {
    "message": "Organization balance is too low to use API",
    "type": "insufficient_balance_error",
    "param": null,
    "code": null
  }
}
```

{% endtab %}

{% tab title="401: Unauthorized Ошибка авторизации" %}

```json
{
  "error": {
    "message": "Unauthorized",
    "type": "unauthorized_request_error",
    "param": null,
    "code": null,
  }
}
```

{% endtab %}
{% endtabs %}

### Пример запроса

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

```typescript
import axios from 'axios'

const request = axios({
  method: 'POST',
  url: 'https://gptunnel.ru/v1/moderations',
  headers: {
    // use your API key here
    Authorization: 'YOUR_API_KEY',
  },
  data: {
     input: "Your text string goes here",
  },
})

request.then((result) => {
  console.log(result)
}).catch((error) => {
  console.error(error)
})
```

{% endtab %}

{% tab title="Curl" %}

```bash
curl --request POST \
  --url https://gptunnel.ru/v1/moderations \
  --header 'Authorization: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
      "input": "Your text string goes here"
}'
```

{% endtab %}
{% endtabs %}

### Пример ответа

```json
{
	"id": "modr-9b51yQZrBNIHDrIeX5bBcftbj5wgs",
	"model": "text-moderation-007",
	"results": [
		{
			"flagged": false,
			"categories": {
				"sexual": false,
				"hate": false,
				"harassment": false,
				"self-harm": false,
				"sexual/minors": false,
				"hate/threatening": false,
				"violence/graphic": false,
				"self-harm/intent": false,
				"self-harm/instructions": false,
				"harassment/threatening": false,
				"violence": false
			},
			"category_scores": {
				"sexual": 0.00009054947440745309,
				"hate": 0.00007182655826909468,
				"harassment": 0.00016347762721125036,
				"self-harm": 0.0000020744676021422492,
				"sexual/minors": 0.000013518638297682628,
				"hate/threatening": 0.0000010106600711878855,
				"violence/graphic": 0.00001040412189468043,
				"self-harm/intent": 4.586087243296788e-7,
				"self-harm/instructions": 3.98835481973947e-7,
				"harassment/threatening": 0.000023142851205193438,
				"violence": 0.00013958947965875268
			}
		}
	],
	"usage": {
		"prompt_tokens": 5,
		"completion_tokens": 0,
		"prompt_cost": 0.00005,
		"completion_cost": 0,
		"total_cost": 0.00005
	}
}
```


---

# Agent Instructions: 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:

```
GET https://docs.gptunnel.ru/moderations/text-moderation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
