# Rate images

> Classify an image as sfw or nsfw, or against rating levels you define, on its own or as part of a generation.

`POST /image/rate` classifies one image. There is no `model` field. Mynth
picks the model and keeps it current. By default the result `level` is `sfw`
or `nsfw`.

**SDK**

```ts
import Mynth from "@mynthio/sdk";

const mynth = new Mynth();

const rating = await mynth.image.rate({ url: "https://cdn.example.com/lighthouse.png" });

console.log(rating.level); // "sfw" or "nsfw"
```

**CLI**

```bash
npx @mynthio/cli image rate https://cdn.example.com/lighthouse.png
```

**REST**

```bash
curl https://api.mynth.io/image/rate \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://cdn.example.com/lighthouse.png"}'
```

A standalone rating costs $0.0002, charged only when the task succeeds. The
body takes `url` and the rating mode, and no `webhook` or `metadata`. The SDK
also accepts a `file`.

## Custom levels

Send `mode: "custom"` with your own levels. The result `level` is one of the
`value` strings you sent, and the SDK types it that way.

```json
{
  "url": "https://cdn.example.com/lighthouse.png",
  "mode": "custom",
  "levels": [
    { "value": "safe", "description": "No explicit content" },
    { "value": "adult", "description": "Nudity or sexual content" }
  ]
}
```

`levels` takes 2 to 7 entries. `value` is 1 to 24 characters and
`description` 1 to 150. Omitting `mode` means `nsfw_sfw`. In the CLI, repeat
`-l value=description`, or pass `--levels-file` or `--levels-json`.

## On a generation

`rating` on `POST /image/generate` rates each successful image and puts the
outcome on that image. `true` runs the default sfw/nsfw check. A
`{ "mode": "custom", "levels": [...] }` object runs your levels. Rating on a
generation costs $0.

```json
{ "model": "black-forest-labs/flux.2-pro", "prompt": "A lighthouse at dusk", "rating": true }
```

Each successful image then carries
`"rating": { "status": "success", "level": "sfw" }`. A rating that fails does
not fail the image: `rating.status` is `failed` with an `error.code`, and the
image is still there. The CLI flag is `--content-rating`.

## Next steps

- [Generate images](https://mynth.io/docs/guides/generate-images.md): where `rating` sits on the request.
- [Review images](https://mynth.io/docs/guides/review-images.md): quality, not content.
