EN ▾
Get API key

NsfwLocalDeveloper docs

API Documentation

Get started with the uncensored LLM API in minutes. Use standard OpenAI-compatible tools to send text requests and receive direct, unfiltered responses.

Quickstart your first request

Start generating text immediately by pointing your client to our base URL and authenticating with a generated API key. The interface follows standard conventions, so you can use existing SDKs without learning a new protocol. You will send prompts to the uncensored model and receive text responses that do not apply typical content filters for lawful adult use.

Configure the base URL and key

Set your environment variables to route requests to our specific endpoint. Replace the placeholder key with the one generated during signup. This ensures all subsequent calls use the correct uncensored model instance.

  • Base URL: https://api.nsfwlocalllm.com/v1
  • Auth Header: Authorization: Bearer YOUR_API_KEY

You can verify your key works by checking the models endpoint. A valid key returns the available model ID immediately.

Send a chat completion request

Send a standard chat completion payload to generate text. The system processes your input and returns the model's response. Use the uncensored model ID to ensure you are hitting the unfiltered instance.

The response includes the generated text and token usage statistics. You can parse this directly into your application logic.

curl https://api.nsfwlocalllm.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Send me the server uptime stats"}]
  }'

Check for standard HTTP status codes to handle success or failure cases.

Enable streaming for real-time output

Stream responses to reduce perceived latency for your users. Enable streaming by setting stream: true in your request body. The API returns a series of Server-Sent Events (SSE) containing partial tokens.

Aggregate these tokens on the client side to reconstruct the full message. This approach is ideal for chat interfaces where immediate feedback matters. The final SSE event contains the total token usage for the request.

from openai import OpenAI

client = OpenAI(base_url="https://api.nsfwlocalllm.com/v1", api_key="YOUR_KEY")

resp = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)

Handle connection errors gracefully to ensure a smooth user experience.

Use JSON mode for structured data

Force the model to output valid JSON for programmatic consumption. Set response_format to {"type": "json_object"} in your request. This reduces parsing errors and ensures consistent data structures.

Use this for generating structured prompts, extracting entities, or building dynamic content. The model adheres to the format constraints provided in your system instructions. This is crucial for reliable integration with other services.

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.nsfwlocalllm.com/v1", apiKey: process.env.API_KEY });

const resp = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);

Validate the output JSON on your end to catch any edge cases.

Implement function calling

Define tools to extend the model's capabilities. Pass a tools array with function definitions to the request. The model can choose to call these functions based on the context.

This enables complex workflows where the LLM decides when to fetch data or perform actions. You receive the function arguments in the response and execute them on your side. Pass the results back to the model for further reasoning.

Set tool_choice to auto for flexible decision-making. This feature supports advanced roleplay scenarios requiring external data access.

stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Tell the story in second person."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Frequently asked questions

What is the context window size?

The context window is 100,000 tokens, covering both the prompt and the completion. This allows for long conversations or large document processing without losing context.

What happens if I run out of credit?

Requests fail with a 402 status code when your prepaid balance is insufficient. You can top up via crypto to resume service immediately. Errors like rate limits do not consume credit.

How do I handle rate limits?

The API enforces a limit of 300 requests per minute per key. If you exceed this, you receive a 429 status code. Implement exponential backoff in your client to handle these delays effectively.

Retrieve your API key instantly

Sign up, copy the token, update the base URL. Setup is complete.

Get API key