Quick start
Create a key, add funds and generate your first image in five minutes.
NSFW API turns an image or video request into a task. You create the task, we run it on a model, and you collect the result when it is done. Every call is billed from a prepaid USD balance.
Base URL: https://nsfwapi.io/api/v1
1. Get an API key
- Sign in to the console and open API keys.
- Create a key. It starts with
sk-and is shown once, so copy it now. - Put it in an environment variable:
export NSFWAPI_KEY="sk-..."2. Add funds
Open Billing and top up with USDT or USDC, from $5. The balance is credited when the network confirms the payment, usually within a few minutes. Check it any time:
curl https://nsfwapi.io/api/v1/balance \
-H "Authorization: Bearer $NSFWAPI_KEY"{ "balance": "5.000000", "currency": "USD", "key": { "quota": null, "used": "0.000" } }3. See what you can run
curl https://nsfwapi.io/api/v1/models \
-H "Authorization: Bearer $NSFWAPI_KEY"Each model comes with its input_schema (a JSON Schema for the request input) and its pricing. You can also try any model in the console Playground, which builds a form from the same schema.
4. Create a task
curl https://nsfwapi.io/api/v1/tasks \
-H "Authorization: Bearer $NSFWAPI_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "nano-banana-2.1",
"input": { "prompt": "a lighthouse at dusk", "resolution": "1K" }
}'{
"id": "task_...",
"model": "nano-banana-2.1",
"status": "waiting",
"cost": "0.025",
"refunded": false,
"output": null,
"error": null
}201 means the task was accepted and charged, not that it is finished. The price is fixed at this moment.
5. Get the result
Poll the task until status is success or fail:
curl https://nsfwapi.io/api/v1/tasks/task_... \
-H "Authorization: Bearer $NSFWAPI_KEY"{
"id": "task_...",
"status": "success",
"cost": "0.025",
"output": { "urls": ["https://cdn.nsfwapi.io/results/..."], "expires_at": "2026-12-15T00:00:00Z" }
}Download the files from output.urls; they are kept for at least 14 days. Rather than poll, you can ask us to call you: see Webhooks.
In code
const base = "https://nsfwapi.io/api/v1";
const headers = {
Authorization: `Bearer ${process.env.NSFWAPI_KEY}`,
"Content-Type": "application/json",
};
const create = await fetch(`${base}/tasks`, {
method: "POST",
headers: { ...headers, "Idempotency-Key": crypto.randomUUID() },
body: JSON.stringify({ model: "nano-banana-2.1", input: { prompt: "a lighthouse at dusk" } }),
});
let task = await create.json();
while (task.status !== "success" && task.status !== "fail") {
await new Promise((r) => setTimeout(r, 2000));
task = await (await fetch(`${base}/tasks/${task.id}`, { headers })).json();
}
console.log(task.output?.urls ?? task.error);import os, time, uuid, requests
base = "https://nsfwapi.io/api/v1"
headers = {"Authorization": f"Bearer {os.environ['NSFWAPI_KEY']}"}
task = requests.post(
f"{base}/tasks",
headers={**headers, "Idempotency-Key": str(uuid.uuid4())},
json={"model": "nano-banana-2.1", "input": {"prompt": "a lighthouse at dusk"}},
).json()
while task["status"] not in ("success", "fail"):
time.sleep(2)
task = requests.get(f"{base}/tasks/{task['id']}", headers=headers).json()
print(task["output"] or task["error"])Next
- Authentication: keys, spending limits and the balance endpoint.
- Tasks: the full task object, statuses and listing.
- Webhooks: get called instead of polling, and verify the signature.
- Errors and idempotency: every error code, and how to retry safely.