EN ▾
NSFW Search APIGet API key

Uncensored LLM API. Pay per token.

NSFW Search API curl: Test Chat, Streaming and Tools

Here is how to run an NSFW search API curl test against this OpenAI-compatible text endpoint, from the first models call to streaming, JSON mode and tool calling. Every command uses model uncensored and only needs your key.

Updated

A glowing terminal sending ribbons of data to a server, illustrating a curl request to an API

Key points

  1. Set the base URL and key once in your shell, then reuse them in every command.
  2. Start with GET /v1/models, which costs no tokens.
  3. Use -N for streaming and read X-Balance-USD to see what each call cost.
  4. 429 errors are fixed by slowing down, closing open streams or waiting for Retry-After.

Before you start

You need a key and a terminal. Get the key from the API key page; the trial credit is enough for everything below. Export it once so the commands stay readable. The base URL is written out in each command so you can copy any one on its own:

export KEY="YOUR_KEY"

Every command sends the key as Authorization: Bearer and addresses the model as uncensored. Only the base URL differs from any OpenAI-style client, so what you learn here carries over to the Python and Node SDKs.

Step 1: list the models

The cheapest check is a GET that costs nothing in tokens. It proves that the key is accepted and the host is reachable.

curl -s "https://api.nsfwsearch.top/v1/models" -H "Authorization: Bearer $KEY"

You should see a JSON list that includes the ID uncensored. If you get an authentication error, check that the key has no trailing space or newline and that the header has the word Bearer. If the connection fails, check the host spelling in the URL. Only one model is offered, so there is nothing to choose between.

Step 2: a plain chat completion

The main endpoint is POST /v1/chat/completions. A minimal body has a model and a messages array.

curl -s "https://api.nsfwsearch.top/v1/chat/completions" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [
      {"role": "system", "content": "You are a concise writing assistant."},
      {"role": "user", "content": "Give me three names for a fictional port city."}
    ],
    "temperature": 0.8,
    "max_tokens": 120
  }'

The reply follows the usual shape: a choices array whose first item holds message.content, plus a usage block with prompt and completion token counts. The parameters temperature, top_p, stop, seed and the penalties are passed through to the model. max_tokens is optional; leave it out and the completion may use the remainder of the 100,000-token window, which is why it is a good habit to set it in tests.

Shell quoting is the usual source of trouble here. If your prompt contains a single quote, the shell ends the string early. Put the body in a file and send it with -d @body.json, which also makes it easy to keep test cases in version control. The maximum body size is 8 MB.

Step 3: read the response headers

Add -i to see headers along with the body, or -D - to print only the headers to the terminal while piping the body elsewhere.

curl -s -i "https://api.nsfwsearch.top/v1/chat/completions" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"uncensored","max_tokens":5,"messages":[{"role":"user","content":"Say hi"}]}' \
  | head -n 20

Four headers are worth knowing. X-Request-Id identifies the call, so quote it if you contact support. X-Balance-USD shows your remaining credit after the call, which makes it a direct way to measure what a prompt cost. X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency show the limits that apply to your key: 300 per minute and 8 concurrent for a full key, 60 and 2 for a trial key.

Step 4: streaming with curl

Set "stream": true and add -N so curl does not buffer the output. The server answers with server-sent events, one data: line per chunk, ending with a final usage chunk and then data: [DONE].

curl -N "https://api.nsfwsearch.top/v1/chat/completions" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "stream": true,
    "max_tokens": 150,
    "messages": [{"role": "user", "content": "Describe a rainy harbour in four sentences."}]
  }'

Each chunk carries a small delta with the next piece of text. Usage arrives at the end of the stream, so a client that stops reading early never sees it. Remember that a streamed request holds one of your concurrency slots until the stream closes. If you start a stream in one terminal and several more in another, a trial key will answer 429 with code concurrency once the third one is open.

Step 5: JSON mode and tool calling

JSON mode asks the model to return a valid JSON object. Still tell it in the prompt what fields you want, because the setting guarantees syntax, not your schema.

curl -s "https://api.nsfwsearch.top/v1/chat/completions" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "response_format": {"type": "json_object"},
    "messages": [
      {"role": "user", "content": "Return a JSON object with keys title and genre for an invented novel."}
    ]
  }'

Tool calling works with the same fields as the OpenAI API. You declare functions in tools, optionally force a choice with tool_choice, and the reply may contain tool_calls instead of text. Run the function yourself and send its output back as a message with role: "tool".

curl -s "https://api.nsfwsearch.top/v1/chat/completions" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "What is the weather in Lisbon?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get current weather for a city",
        "parameters": {
          "type": "object",
          "properties": {"city": {"type": "string"}},
          "required": ["city"]
        }
      }
    }],
    "tool_choice": "auto"
  }'

Look for choices[0].message.tool_calls in the response. The arguments arrive as a JSON string, so parse it before use. The model cannot call the function; it only asks for it.

Using the same request from code

Once a curl command works, the translation to an SDK is mechanical, because the JSON body maps one to one onto the arguments. The base URL and key go to the client constructor, and everything else is a keyword argument. Here is the chat request from step 2 in Node:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.nsfwsearch.top/v1",
  apiKey: process.env.KEY,
});

const resp = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Give me three names for a fictional port city." }],
  temperature: 0.8,
  max_tokens: 120,
});
console.log(resp.choices[0].message.content);

If the SDK version behaves differently from curl, the cause is almost always a header or a body field the SDK adds or omits. Run the curl version with -v to see exactly what goes over the wire, and compare it with what your library sends. That one comparison solves most "works in curl, fails in my app" reports.

Reproducible tests and the cost of a run

For repeatable checks, set seed together with a low temperature and send the same body twice. Seeded sampling is passed through to the model, so identical requests should give very similar text, which helps when you compare prompt changes. Treat it as a testing aid and not as a guarantee of byte-identical output.

Use stop to cut output at a marker, for example a blank line, when you only need the first paragraph. That is both faster to read in a terminal and cheaper, since you pay for output tokens at $0.50 per 1M.

Cost of a test is easy to compute. A prompt of 40 tokens with a 120-token reply costs 40 × $0.15 / 1,000,000 = $0.000006 for input and 120 × $0.50 / 1,000,000 = $0.00006 for output, so $0.000066 in total. Even a hundred such calls come to $0.0066, well under one cent. Read X-Balance-USD before and after a batch if you want to confirm the figure on your own account. The pricing page lists the top-up options if you outgrow the trial.

When a call fails

Most failures fall into a short list.

  • 429 with code rate_limited: more than the allowed requests per minute. Wait a moment, then retry more slowly.
  • 429 with code concurrency: too many requests at once. Close open streams or run fewer in parallel.
  • 429 with a Retry-After: 5 header: temporary overload. Wait five seconds and send again.
  • Invalid JSON error: usually quoting. Move the body to a file.
  • Empty or cut-off text: check whether max_tokens is too low; the finish_reason in the response will say so.

A small retry loop in bash is enough for scripts:

for i in 1 2 3; do
  code=$(curl -s -o out.json -w "%{http_code}" "https://api.nsfwsearch.top/v1/chat/completions" \
    -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
    -d @body.json)
  [ "$code" = "200" ] && break
  sleep 5
done
cat out.json

Failed or refused requests are not charged, so retrying a failure costs nothing extra. When everything works from curl, move on to your SDK of choice using the documentation, and see the pricing page before you plan heavier use.

Questions and answers

What base URL do I use with curl?

Use https://api.nsfwsearch.top/v1 and append /chat/completions or /models. Send the key as a Bearer token.

Which model ID should I send?

Send uncensored. It is the only model on this endpoint.

Why does curl show nothing until the end of a stream?

Curl buffers output by default. Add -N to turn buffering off so chunks appear as they arrive.

Does a curl test cost money?

Requests are billed by tokens at $0.15 per 1M input and $0.50 per 1M output. A short test costs a fraction of a cent, and the trial credit covers it.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.