Integrating Uncensored Llama API with Python SDK
Developers often seek a reliable way to integrate uncensored text generation into their Python applications without the overhead of multimodal features. This guide provides a tested checklist for SDK settings and a step-by-step integration process for the OpenAI-compatible endpoint. We focus on getting the client library configured correctly for pure text responses.
Understanding the API Endpoint Structure
Before writing any code, it is essential to understand the structure of the API endpoint. Our service provides a hosted, OpenAI-compatible chat-completions API. This means you can use standard libraries that expect an OpenAI-style interface. The base URL for our service is https://api.uncensoredllama.com/v1. You must ensure your client library points to this specific URL to access our uncensored model.
The API serves one uncensored open-weight text model. When making requests, you must specify the model ID as 'uncensored'. This ensures that the model does not refuse lawful adult, fictional, security-research, or controversial topics. The API is text-in, text-out, meaning it does not handle image, audio, or video generation. Keeping this distinction clear helps avoid unnecessary overhead in your application.
Our API supports standard parameters such as temperature, top_p, stop sequences, seed, and penalties. These parameters allow you to fine-tune the output of the model. For example, you can set a lower temperature for more deterministic responses or use the seed parameter for reproducible results. Understanding these parameters is important for getting the desired behavior from the uncensored model.
It is important to note that our API does not support embeddings, OCR, fine-tuning, or model routing. If your application requires these features, you may need to use a different service. However, for pure text generation, our API provides a straightforward and efficient solution. Always check the API documentation for the latest details on supported parameters and endpoints.
Configuring the Python Client Library
To integrate our API with Python, you will need to install the official OpenAI Python client library. This library is widely used and well-documented, making it easy to adapt for our service. You can install the library using pip. Once installed, you can configure the client to point to our base URL. This step is critical for ensuring that your requests are routed correctly to our uncensored model.
When configuring the client, you must set the API key. Our API uses a simple key-based authentication system. You can generate a key during the signup process, which supports Google login or email and password. The key is shown immediately after signup, so you can start using it right away. Make sure to store your key securely and avoid committing it to version control.
Set the model parameter to 'uncensored' in your client configuration. This tells the API which model to use for generating responses. Since our API serves only one uncensored model, this setting is essential for accessing the correct behavior. Without this setting, the client might default to a different model or fail to authenticate.
It is also important to handle errors correctly. Our API returns specific error codes for common issues. A 401 error indicates an invalid key, a 402 error means you have no credit, and a 429 error signifies a rate limit. By handling these errors in your code, you can provide a better user experience and troubleshoot issues more effectively.
Handling Streaming Responses
Streaming responses are a key feature of our API, allowing you to receive text output in real-time. This is particularly useful for chat applications where users expect immediate feedback. Our API supports streaming over Server-Sent Events (SSE). When you enable streaming, the API sends usage information in the last chunk, which helps you track token consumption accurately.
To implement streaming in Python, you need to set the stream parameter to true in your request. The client library will then yield chunks of text as they are generated. You can process these chunks as they arrive, updating the user interface in real-time. This approach reduces the perceived latency and provides a smoother user experience.
When streaming, it is important to handle the end of the stream correctly. The last chunk contains the usage data, including the number of input and output tokens. You can use this information to calculate the cost of the request. Our pricing is based on token usage, with specific rates for input and output tokens.
Streaming also allows you to implement features like typing indicators or progressive text display. This can make your application feel more responsive and engaging. However, keep in mind that streaming requires more complex error handling and state management compared to non-streaming responses. Ensure your code is reliable enough to handle network interruptions or partial responses.
Managing Prepaid Credit and Payments
Our API uses a prepaid credit system, which means you pay for what you use. There are no monthly subscriptions or hidden fees. You can top up your credit using cryptocurrency, specifically USDT on TRC20 or USDC on Base. The minimum top-up amount is $20, and the maximum is $500. You can choose any whole amount within this range.
One of the benefits of our prepaid system is that paid credit never expires. You can top up whenever you need more credits, and they will remain available for use. Additionally, we offer bonus credit for top-ups of $50 or more. The bonus ranges from +5% to +15%, depending on the amount you top up. This can help you get more value for your money.
It is important to note that our API only accepts crypto payments. We do not accept credit cards, PayPal, or bank transfers. This means you will need a cryptocurrency wallet to make payments. Make sure to have enough crypto in your wallet before attempting to top up your account. The top-up process is straightforward, and you can track your balance in the dashboard.
Errors and refusals are free, which means you only pay for successful token generation. This can help you manage your budget more effectively. However, keep in mind that the API has a rate limit of 300 requests per minute per key. If you exceed this limit, you will receive a 429 error. Plan your requests accordingly to avoid unnecessary delays.
When Our API Is Not the Right Choice
While our API is excellent for uncensored text generation, it may not be the right choice for every use case. For example, if your application requires image, audio, or video generation, our API does not support these features. You would need to use a different service that specializes in multimodal content. Similarly, if you need embeddings for semantic search or OCR for document processing, our API is not suitable.
Another scenario where our API might not be ideal is if you need fine-tuning capabilities. Our API serves a fixed open-weight model, and you cannot fine-tune it to your specific dataset. If you require a model that is tailored to your domain, you might need to use a service that offers fine-tuning options. Additionally, if you need model routing to switch between different models based on the task, our API does not support this feature.
Our API is also not suitable if you need an SLA with specific uptime guarantees. We do not claim any SLA percentages, so you should not rely on it for mission-critical applications that require high availability. Similarly, if you need certifications like SOC2, HIPAA, or ISO, our API does not currently offer these. Check the vendor documentation for current prices and limits if you need these features.
Finally, if you are looking for a free unlimited tier, our API is not the right choice. We offer a trial credit of $0.50 for new accounts, but ongoing usage requires prepaid credit. If you need a completely free option, you might need to explore other services. However, for uncensored text generation with a simple prepaid model, our API is a strong contender.
Addressing Common Developer Questions
Developers often ask how to integrate uncensored Llama models into their Python projects, especially when dealing with security research or pentesting agents. Threads on r/netsec frequently discuss the use of uncensored Llama models for reconnaissance, SQL injection, privilege escalation, and Active Directory attacks. These discussions highlight the need for a reliable API that can handle complex text-based tasks without censorship.
One common question is how to ensure that the API does not refuse requests related to security research. Our API is designed to be uncensored, meaning it does not refuse lawful adult, fictional, security-research, or controversial topics. This makes it suitable for tools like GHOST, an open-source AI pentest agent that uses uncensored Llama 3.3 70B for various attacks. Developers can integrate our API to power these agents with minimal configuration.
Another frequent question is how to handle the context window. Our API supports a context window of 100,000 tokens, which includes both the prompt and the completion. This is ample for most security research tasks, allowing you to process large amounts of text without running out of context. However, if your application requires handling even larger contexts, you might need to chunk your input or use a different service.
Developers also ask about the pricing structure. Our API charges $0.15 per million input tokens and $0.50 per million output tokens. This is a straightforward pricing model that helps you estimate costs based on token usage. Since errors and refusals are free, you only pay for successful generations. This can help you manage your budget effectively, especially when running large-scale pentesting campaigns.
Best Practices for Integration
When integrating our API, it is important to follow best practices to ensure a smooth experience. First, always handle errors gracefully. Our API returns specific error codes for common issues, such as invalid keys, insufficient credit, or rate limits. By handling these errors in your code, you can provide a better user experience and troubleshoot issues more effectively.
Second, use streaming for real-time applications. Streaming allows you to receive text output in real-time, which is important for chat applications and other interactive tools. Make sure to handle the end of the stream correctly and track token usage for billing purposes. This will help you manage your budget and provide a responsive user interface.
Third, store your API key securely. Avoid committing your key to version control and use environment variables or a secrets manager to store it. This will prevent accidental exposure of your key and ensure that your account remains secure. Regularly rotate your keys if you suspect a compromise.
Finally, test your integration thoroughly before deploying to production. Use the trial credit to test different parameters and scenarios. Ensure that your application handles edge cases, such as network interruptions or partial responses. By following these best practices, you can build a reliable and reliable application using our uncensored Llama API.
Frequently asked questions
How do I set up the Python client for our uncensored API?
Install the OpenAI Python client library and configure the base URL to https://api.uncensoredllama.com/v1. Set the model ID to 'uncensored' and provide your API key for authentication. This ensures the client connects to our uncensored text model.
What payment methods are accepted for topping up credit?
Our API only accepts cryptocurrency payments. You can top up using USDT on TRC20 or USDC on Base. The minimum top-up amount is $20, and the maximum is $500. Credit cards, PayPal, and bank transfers are not accepted.
Does the API support streaming responses?
Yes, the API supports streaming over Server-Sent Events (SSE). You can enable streaming by setting the stream parameter to true. Usage information is provided in the last chunk, allowing you to track token consumption accurately.
What is the context window size?
The context window is 100,000 tokens, which includes both the prompt and the completion. This allows for processing large amounts of text, making it suitable for complex tasks like security research and long-form content generation.