Skip to content

Check text

POSThttps://gptunnel.ru/v1/moderations

The endpoint takes one text input and returns an overall flag and category results. To get a separate result for each text, send separate requests. A test request with an array of two strings returned one entry in results. The service chooses the model. In the example below, the response field model is omni-moderation-latest.

Request headers

ParameterTypeRequired?Description
AuthorizationstringRequiredGPTunneL API key

Request body

ParameterTypeRequired?Description
input#stringRequiredText to check. Send one non-empty string
useWalletBalance#booleanOptionalSet to true to use your personal balance

Set your API key in the GPTUNNEL_API_KEY environment variable.

import json
import os
from urllib.request import Request, urlopen
body = {
'input': 'A blue sky.',
}
request = Request(
'https://gptunnel.ru/v1/moderations',
headers={
'Authorization': os.environ['GPTUNNEL_API_KEY'],
'Content-Type': 'application/json',
},
data=json.dumps(body).encode('utf-8'),
method='POST',
)
with urlopen(request, timeout=30) as response:
print(json.load(response))

The text A blue sky. returned one result with flagged: false. Read the category flags in categories and their numeric scores in category_scores. The example shows two of the returned categories. Moderation is billed per call. The usage.prompt_tokens field reports the input token count for reference. Text length does not affect the per-call rate. The usage.total_cost field shows the cost of the call in rubles after any discount.

{
"model": "omni-moderation-latest",
"results": [
{
"flagged": false,
"categories": {
"harassment": false,
"illicit": false
},
"category_scores": {
"harassment": 0,
"illicit": 0
}
}
],
"usage": {
"prompt_tokens": 4,
"completion_tokens": 0,
"prompt_cost": 0.24,
"completion_cost": 0,
"total_cost": 0.24
}
}
HTTP What to check
401 Send a valid API key in the Authorization header.
402 Check the balance of the selected account.
422 If the input field is missing or empty, provide text to check.

The endpoint returned the following HTTP 422 response:

{
"error": {
"message": "input must be not empty",
"type": "invalid_input",
"param": null,
"code": null
}
}