EN ▾
Get API key

Integrating NsfwLocal with Chat Clients

Connecting an uncensored model to a chat interface requires precise configuration of the API endpoint and authentication. This guide walks you through the specific settings needed to integrate our hosted service with popular clients like SillyTavern or JanitorAI. You will learn how to manage your API key, adjust system prompts, and handle streaming responses for a smooth user experience.

Developer workspace with chat interface and crypto symbols

Understanding the API Endpoint Structure

Before configuring your chat client, it is essential to understand the structure of our API. Our service provides a hosted, OpenAI-compatible chat-completions API that serves a single uncensored open-weight text model. The primary endpoint for sending messages is POST /v1/chat/completions. This endpoint accepts text input and returns text output, making it compatible with most standard chat interfaces that support OpenAI-style APIs.

The base URL for all requests is https://api.nsfwlocalllm.com/v1. When setting up your client, ensure you use this exact URL to avoid connection errors. Unlike some other services, we do not offer embeddings, image generation, or audio processing. The focus is strictly on text generation, which simplifies the integration process for developers and users who only need conversational AI.

Additionally, you can retrieve model information using the GET /v1/models endpoint. This allows your client to verify the available models dynamically. The model ID you must send in your requests is uncensored. This identifier tells the server which specific model to use for generating responses. Keeping this ID consistent ensures that your chat client interacts correctly with our backend infrastructure.

It is important to note that our API does not support fine-tuning or model routing. You cannot switch between different models or train the model on your own data through the API. The model is fixed, and its behavior is determined by the system prompt and the parameters you send. This consistency can be an advantage for users who want a predictable and stable output without the complexity of managing multiple model versions.

Configuring Authentication and API Keys

Authentication is handled via API keys, which you receive immediately after signing up. You can sign up using Google or an email and password combination. Once registered, your API key is displayed on the screen, so make sure to copy it securely. This key is required for all requests to the API. If you do not include a valid key, you will receive a 401 error indicating an invalid key.

When configuring your chat client, locate the field for the API key and paste your key there. Ensure that there are no extra spaces or line breaks in the key, as this can cause authentication failures. The key is tied to your account and allows you to access the API. If you lose your key, you may need to generate a new one through your account dashboard.

Our API uses prepaid credit, which is charged based on real token usage. Errors and refusals are free, so you only pay for successful completions. The credit is charged in real-time, and your balance is updated accordingly. If you run out of credit, you will receive a 402 error, indicating that you need to top up your account. This pay-as-you-go model ensures that you only pay for what you use, without any monthly subscription fees.

Top-ups can be made using crypto, specifically USDT on TRC20 or USDC on Base. The minimum top-up amount is $20, and the maximum is $500. You can also receive bonus credit when you top up $50 or more, with bonuses ranging from 5% to 15%. Cards, PayPal, and bank transfers are not accepted, so ensure you have a compatible crypto wallet before making a top-up. This method of payment is secure and allows for quick processing of your credits.

Setting Up System Prompts and Parameters

System prompts are important for defining the behavior of the model. In your chat client, you can set a system prompt that dictates how the model should respond. For example, you might set a prompt that defines the character's personality or the context of the conversation. This prompt is sent with every request and helps guide the model's output.

Our API supports various parameters that allow you to fine-tune the model's behavior. You can set the temperature to control the randomness of the output, with higher values producing more creative responses. The top_p parameter controls the nucleus sampling, which limits the model to the most likely tokens. You can also set stop sequences to halt generation at specific points, and use a seed for reproducible results.

Penalties can be applied to discourage certain tokens or phrases. This is useful for preventing the model from repeating itself or using unwanted language. By adjusting these parameters, you can customize the model's output to better fit your needs. Experiment with different settings to find the optimal configuration for your use case.

It is important to note that the context window for our API is 100,000 tokens, which includes both the prompt and the completion. This large context window allows for long conversations without losing context. However, keep in mind that the model's performance may vary depending on the length and complexity of the input. Testing different configurations is key to achieving the best results.

Handling Streaming and JSON Mode

Streaming is a key feature of our API, allowing you to receive responses in real-time. When you enable streaming in your chat client, the API sends data in chunks using Server-Sent Events (SSE). This provides a smoother user experience, as users can see the response as it is generated. The last chunk of the stream includes usage information, which can be useful for tracking token consumption.

For developers who need structured data, our API supports JSON mode. This ensures that the output is formatted as valid JSON, making it easier to parse and process. You can enable JSON mode by setting the appropriate parameter in your request. This is particularly useful for applications that require specific data structures or integration with other systems.

Function calling is another powerful feature supported by our API. You can define tools or functions that the model can call during generation. This allows for more interactive and dynamic conversations, where the model can perform actions or retrieve information based on the conversation context. Setting up function calling requires defining the tools in your request and handling the responses accordingly.

When implementing streaming or JSON mode, ensure that your chat client is configured to handle these formats correctly. Misconfigurations can lead to errors or incomplete responses. Testing the integration thoroughly is essential to ensure that all features work as expected. This includes verifying that streaming responses are displayed correctly and that JSON output is valid.

When Our API Is Not the Right Choice

While our API is excellent for text generation, it may not be the right choice for everyone. If you need features like image generation, audio processing, or OCR, our API does not support these capabilities. Our service is focused solely on text-in, text-out functionality, so if your project requires multimodal outputs, you may need to look elsewhere.

Additionally, if you require fine-tuning or model routing, our API may not meet your needs. We offer a single uncensored model, so you cannot switch between different models or train the model on your own data. If your project involves complex model management or specific training requirements, a more flexible solution might be more suitable.

Another consideration is the payment method. Our API accepts only crypto payments, specifically USDT on TRC20 or USDC on Base. If you prefer using credit cards, PayPal, or bank transfers, our payment options may not be convenient for you. Ensure that you have a crypto wallet and are comfortable with crypto transactions before integrating our API.

Finally, if you need a service with a specific SLA or certifications like SOC2 or HIPAA, our API may not be the best fit. We do not claim any SLA percentages or certifications, and our service is designed for developers and indie builders who prioritize uncensored text generation over enterprise-grade guarantees. Evaluate your project's requirements carefully to determine if our API aligns with your needs.

Addressing Common Reddit Questions

Users on Reddit often ask about the best uncensored models for role-playing and long-form content. Many users are looking for models that can handle extended conversations without losing context or coherence. Our API's large context window of 100,000 tokens makes it well-suited for long-form RP, as it can maintain context over many turns. However, the quality of the output also depends on the system prompt and parameters you set.

Another common question is about the best models for specific hardware setups. Users with different GPU capabilities often seek recommendations for models that run efficiently on their machines. While our API is hosted, so hardware is not a concern, users still want to know how the model performs in terms of speed and response quality. Testing the API with your specific use case is the best way to determine its suitability.

Users also discuss the trade-offs between local and hosted solutions. Local models offer more control and privacy, but hosted APIs like ours provide ease of use and scalability. Our API eliminates the need for managing hardware and software updates, allowing users to focus on their content. However, this comes with the trade-off of relying on a third-party service for uptime and performance.

Finally, users often ask about the cost-effectiveness of using an API versus running a local model. Our API offers a pay-as-you-go model with no monthly fees, which can be more cost-effective for users with variable usage. The prepaid credit system ensures that you only pay for what you use, making it a flexible option for indie builders and developers.

Troubleshooting and Best Practices

Troubleshooting common issues can save you time and ensure a smooth integration. If you encounter a 401 error, check that your API key is correct and has not been revoked. If you receive a 402 error, it means you have run out of credit, and you need to top up your account. A 429 error indicates that you have exceeded the rate limit of 300 requests per minute, so you may need to adjust your request frequency.

Best practices for using our API include monitoring your token usage and adjusting your parameters accordingly. Keep an eye on your credit balance to avoid unexpected service interruptions. Use the GET /v1/models endpoint to verify the available models and ensure that your client is configured correctly. Regularly updating your client to the latest version can also help prevent compatibility issues.

When setting up your chat client, use the uncensored model ID and ensure that the base URL is correct. Test your integration with a few simple requests before deploying it to production. This helps identify any configuration errors early on. Additionally, use the streaming feature to provide a better user experience, as it allows for real-time response generation.

Finally, consider the limitations of our API when planning your project. If you need features like image generation or fine-tuning, our API may not be the right choice. Focus on the strengths of our API, such as its large context window and uncensored text generation, to get the most value from the service. By following these best practices, you can ensure a successful integration and a satisfying user experience.

Frequently asked questions

How do I get an API key?

You can sign up using Google or an email and password. Your API key is shown immediately after registration. Make sure to copy it securely, as it is required for all requests.

What is the cost of using the API?

The API costs $0.15 per 1M input tokens and $0.50 per 1M output tokens. Credit is charged by real token usage, and errors are free. You can top up with crypto, starting from $20.

Does the API support streaming?

Yes, the API supports streaming over SSE. Usage information is included in the last chunk of the stream. This allows for real-time response generation in your chat client.

What happens if I run out of credit?

If you run out of credit, you will receive a 402 error. You can top up your account using USDT on TRC20 or USDC on Base. Top-ups range from $20 to $500, with bonuses available for larger amounts.