Quickstart
Get a free API key and analyse your first image with curl, TypeScript or Python in two minutes.
- Create a free key in the console. The free tier gives you 500 credits a month.
- 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.levelis the headline: 0 Everyday, 1 Revealing, 2 Implied nudity, 3 Explicit.nudity.scoresare 0–100; above 50 counts. Scores near 50 mean the model is unsure.policy.blockedis only present when you sent apolicy.usage.creditsis what this call cost andusage.balancewhat is left.
Keep the key on your server. Browsers and mobile apps should call your backend, not the API directly.