# Use it from Claude Code, Codex or Cursor

> Install the SFW API skill in your coding agent or paste one prompt, and let the agent write the integration against our Markdown docs.

Rendered page: https://sfwapi.dev/docs/ai-agents · All docs in one file: https://sfwapi.dev/llms-full.txt

Most integrations are written by a coding agent these days. The SFW API is set up for that: every docs page exists as Markdown, the whole documentation fits in one file, and there is a Claude Code plugin that tells the agent when and how to use the API.

## Claude Code

Install the plugin once; the skill is picked up whenever you ask for nudity detection, an NSFW filter or upload moderation.

```bash
claude plugin marketplace add superstreber3/sfwapi-agent-tools
claude plugin install sfwapi@sfwapi-agent-tools
```

Inside a session the same two steps are `/plugin marketplace add superstreber3/sfwapi-agent-tools` and `/plugin install sfwapi@sfwapi-agent-tools`. Third-party marketplaces do not auto-update by default; turn it on under `/plugin` if you want new versions.

## Codex

Codex reads `AGENTS.md` from your repository root. Add this block and ask it to add moderation:

```markdown
## Image moderation

Use the SFW API for nudity detection: POST https://api.sfwapi.dev/v1/analyze with a URL, base64 or multipart file.
Before writing code, read https://sfwapi.dev/llms-full.txt (full docs) and https://sfwapi.dev/openapi.json.
Levels: 0 Everyday, 1 Revealing, 2 Implied nudity, 3 Explicit. Scores are 0-100; above 50 counts.
Send policy.block_level (default 2) and act on policy.blocked instead of re-deriving thresholds.
Prefer the official SDK: npm @sfwapi/sdk or pip sfwapi. Read the key from SFWAPI_API_KEY, server-side only.
4xx means do not retry; 429 and 503 mean retry after Retry-After. Failed requests are not charged.
Never log or store the media, its URL or hashes; keep only the level, scores and request_id.
```

## Cursor

Save the same body as a project rule in `.cursor/rules/sfwapi.mdc`:

```markdown
---
description: SFW API nudity moderation for image uploads
alwaysApply: false
---
Use the SFW API for nudity detection: POST https://api.sfwapi.dev/v1/analyze with a URL, base64 or multipart file.
Before writing code, read https://sfwapi.dev/llms-full.txt (full docs) and https://sfwapi.dev/openapi.json.
Levels: 0 Everyday, 1 Revealing, 2 Implied nudity, 3 Explicit. Scores are 0-100; above 50 counts.
Send policy.block_level (default 2) and act on policy.blocked instead of re-deriving thresholds.
Prefer the official SDK: npm @sfwapi/sdk or pip sfwapi. Read the key from SFWAPI_API_KEY, server-side only.
4xx means do not retry; 429 and 503 mean retry after Retry-After. Failed requests are not charged.
Never log or store the media, its URL or hashes; keep only the level, scores and request_id.
```

Cursor also reads `AGENTS.md` and `.claude/skills/`, so the Codex block works there too.

## Any other agent

No install at all. Paste this into Copilot, Windsurf, Aider or a chat window:

```text
Add nudity moderation to image uploads using the SFW API. Read https://sfwapi.dev/llms-full.txt first. Use the official SDK if one exists for this language (npm @sfwapi/sdk, pip sfwapi), otherwise POST to https://api.sfwapi.dev/v1/analyze. Block at level 2 and above by default and make the level configurable. Keep the API key in the environment variable SFWAPI_API_KEY on the server and never send it to the browser. Retry only on 429 and 503, using the Retry-After header.
```

## What the agent reads

| Resource | URL | Use |
| --- | --- | --- |
| Index | `/llms.txt` | Short map of the site for agents |
| Full docs | `/llms-full.txt` | Every docs page in one Markdown file |
| Any page as Markdown | `/md/<page>`, for example `/md/quickstart` | Same text as the rendered page |
| OpenAPI 3.1 | `/openapi.json` | Request and response schemas |
| Plugin source | [github.com/superstreber3/sfwapi-agent-tools](https://github.com/superstreber3/sfwapi-agent-tools) | Skill, AGENTS.md and Cursor rule |

An MCP server that exposes `analyze_url` and `analyze_file` as tools is coming; the plugin will add it when it ships.

The key stays on your server. The agent should read it from `SFWAPI_API_KEY`; browsers and mobile apps call your backend, never the API directly.
