Skip to Content
SFW API

Quickstart

Get a free API key and analyse your first image with curl, TypeScript or Python in two minutes.

  1. Create a free key in the console. The free tier gives you 500 credits a month.
  2. Send an image URL:
curl -X POST https://api.sfwapi.dev/v1/analyze \
  -H "Authorization: Bearer sk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/photo.jpg", "policy": {"block_level": 2}}'

Or upload a file:

curl -X POST https://api.sfwapi.dev/v1/analyze \
  -H "Authorization: Bearer sk_live_…" \
  -F "file=@photo.jpg" \
  -F 'policy={"block_level":2,"block_sex_objects":true}'

TypeScript

import { SfwApi } from '@sfwapi/sdk';

const api = new SfwApi({ apiKey: process.env.SFWAPI_KEY! });
const r = await api.analyzeUrl('https://example.com/photo.jpg', { policy: { block_level: 2, block_sex_objects: true, art: 'same_as_photos' } });

if (r.policy?.blocked) console.log(`blocked at level ${r.policy.matched_level}`);
console.log(r.nudity.level, r.nudity.scores, r.usage.balance);

Python

from sfwapi import SfwApi

api = SfwApi(api_key=os.environ["SFWAPI_KEY"])
r = api.analyze_url("https://example.com/photo.jpg", policy={"block_level": 2, "block_sex_objects": True})
print(r["nudity"]["level"], r["policy"]["blocked"], r["usage"]["balance"])

Reading the answer

  • nudity.level is the headline: 0 Everyday, 1 Revealing, 2 Implied nudity, 3 Explicit.
  • nudity.scores are 0–100; above 50 counts. Scores near 50 mean the model is unsure.
  • policy.blocked is only present when you sent a policy.
  • usage.credits is what this call cost and usage.balance what is left.

Keep the key on your server. Browsers and mobile apps should call your backend, not the API directly.

On this page