# Rate image

> Queues a content rating for an image and returns the task. The result is a single level, so this is the cheap check to run before publishing something generated.

`POST /image/rate`

**Auth:** API key or OAuth token

## Request body

### custom

- `levels` (required, object[]) — ≥ 2 items, ≤ 7 items.
  - `description` (required, string) — ≥ 1 characters, ≤ 150 characters.
  - `value` (required, string) — ≥ 1 characters, ≤ 24 characters.
- `mode` (required, "custom")
- `url` (required, string)

### nsfw_sfw

- `url` (required, string)
- `mode` ("nsfw_sfw") — Default `"nsfw_sfw"`.

## Response

### 201 — Image rating task created

- `data` (required, object)
  - `estimatedCost` (required, string) — Estimated cost in USD reserved for this task. Failed tasks are not charged. Example `"0.0002"`.
  - `taskId` (required, string) — Task ID Example `"tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP"`.

```json
{
  "data": {
    "estimatedCost": "0.0002",
    "taskId": "tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP"
  }
}
```

### 400 — Validation Error

- `success` (required, false)
- `error` (required, array)
- `data` (required, any)

```json
{
  "success": false,
  "error": []
}
```

## Request samples

### cURL

```bash
curl -X POST https://api.mynth.io/image/rate \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "levels": [
      {
        "description": "string",
        "value": "string"
      }
    ],
    "mode": "custom",
    "url": "string"
  }'
```

### JavaScript

```ts
const response = await fetch("https://api.mynth.io/image/rate", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MYNTH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "levels": [
      {
        "description": "string",
        "value": "string"
      }
    ],
    "mode": "custom",
    "url": "string"
  }),
});

const { data } = await response.json();
```

The full schema for this endpoint is in the [OpenAPI document](https://api.mynth.io/openapi.json).
