SFW API

Nudity filter for Discord bots

Last updated Mon Nov 09 2026 00:00:00 GMT+0000 (Coordinated Universal Time)

If you would rather not build it, SfwBot is the hosted bot on the same model. If you want it inside your own bot:

import { SfwApi } from '@sfwapi/sdk';
const api = new SfwApi({ apiKey: process.env.SFWAPI_KEY! });

client.on('messageCreate', async (msg) => {
  for (const a of msg.attachments.values()) {
    if (!a.contentType?.startsWith('image/')) continue;
    const r = await api.analyzeUrl(a.url, { policy: { block_level: 2, block_sex_objects: true, art: 'block_from_3' }, maxFrames: 5 });
    if (r.policy?.blocked) {
      await msg.delete();
      await msg.channel.send(`${msg.author}, that image was removed (level ${r.nudity.level}).`);
      break;
    }
  }
});

Notes: Discord CDN URLs are public for a while, so URL mode works and saves you the download. Stickers and emoji are static images too. Keep the key in the bot's environment, never in the client.