Check text
Moderate text
Section titled “Moderate text”https://gptunnel.ru/v1/moderationsThe 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
| Parameter | Type | Required? | Description |
|---|---|---|---|
Authorization | string | Required | GPTunneL API key |
Request body
| Parameter | Type | Required? | Description |
|---|---|---|---|
input | string | Required | Text to check. Send one non-empty string |
useWalletBalance | boolean | Optional | Set to true to use your personal balance |
Example request
Section titled “Example request”Set your API key in the GPTUNNEL_API_KEY environment variable.
import jsonimport osfrom 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))curl --fail-with-body --silent --show-error \ --url 'https://gptunnel.ru/v1/moderations' \ --header "Authorization: ${GPTUNNEL_API_KEY:?Set GPTUNNEL_API_KEY}" \ --json '{ "input": "A blue sky."}'const response = await fetch('https://gptunnel.ru/v1/moderations', { method: 'POST', headers: { Authorization: process.env.GPTUNNEL_API_KEY, 'Content-Type': 'application/json', }, body: JSON.stringify({ "input": "A blue sky." }),})if (!response.ok) throw new Error(await response.text())console.log(await response.json())Example response
Section titled “Example 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 }}Errors
Section titled “Errors”| 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 }}