Step-by-Step Integration of the uncensored.com LLM API
Integrating an uncensored LLM into your application requires precise configuration of the base URL and authentication headers. This guide walks you through setting up the uncensored.com API for text generation, streaming, and tool usage using standard OpenAI-compatible SDKs.
Last updated
Summary
- The API uses the base URL HTTPS://api.uncensoredaicom.com/v1 and model ID "uncensored" for all requests.
- Authentication is handled via a Bearer token in the Authorization header, obtained after signing up with Google or email.
- Streaming responses are enabled by setting stream=true, delivering tokens via Server-Sent Events.
- Pricing is transparent at $0.15 per million input tokens and $0.50 per million output tokens, with prepaid crypto credit that never expires.
Prerequisites: SDK and Environment Setup
Install your preferred language SDK to communicate with the endpoint. Most developers use the official OpenAI SDK for Python, Node.js, or Go. This works because the API follows the standard OpenAI chat completions schema.
Ensure your environment has Python 3.8+ or Node.js 18+. Install the package via pip or npm. You will need an API key from the dashboard. No phone number is required for signup.
- Python:
pip install openai - Node.js:
npm install openai
Store your API key in an environment variable. This prevents accidental exposure in version control. The key grants access to the uncensored model.
Configuring the Base URL
Point your SDK client to the correct base URL. This is the most critical step for successful integration. The default OpenAI base URL will not work for this service.
Set the base URL to HTTPS://api.uncensoredaicom.com/v1. This directs requests to the uncensored LLM infrastructure. The model ID you must send is "uncensored". It is an open-weight model tuned for minimal refusals.
Verify the connection by calling the models endpoint. This confirms your credentials and base URL are correct. A successful response returns the model ID and object type.
Authentication and Header Setup
Pass your API key in the Authorization header. Use the Bearer scheme for all requests. This header authenticates your prepaid credit account.
Set the header as: Authorization: Bearer YOUR_API_KEY. The SDK handles this automatically if you pass the key to the client constructor. Ensure no extra whitespace is included. Invalid keys return a 401 Unauthorized error.
You get one active key per account. Generating a new key invalidates the previous one. This simplifies key rotation and security management. Keep your key secure in your deployment environment.
Sending a Standard Chat Request
Make a POST request to /v1/chat/completions. Send your messages as an array of role and content objects. The system supports user, assistant, and system roles.
Example structure: {"model": "uncensored", "messages": [{"role": "user", "content": "Hello"}]}. The API returns a text completion. Context window is 100,000 tokens total. Max output is 16,000 tokens per request.
Errors and refusals do not consume credit. This protects your prepaid balance. Set temperature and top_p for control. Default values work for most use cases.
Enabling Streaming for Real-Time Output
Set stream: true in your request body. This activates Server-Sent Events (SSE). Tokens arrive incrementally instead of waiting for full completion.
Parse the SSE stream to display text in real time. The final chunk contains token usage statistics. This allows accurate billing tracking. Streaming reduces perceived latency for end users.
Handle network interruptions gracefully. Reconnect if the stream drops. The uncensored API supports stable streaming. Monitor the connection state. Use this for chat interfaces or long-form generation.
Using Tools and Function Calling
Define tools in your request body. Pass a list of function schemas. The model can call these functions based on user intent. This enables agent-like behavior.
Specify tool_choice to control function selection. Use auto for automatic detection. The API supports standard tool definitions. Parse the function call arguments from the response.
Implement the function execution in your code. Send the result back as a message. The model continues the conversation. This enables complex workflows. Testing ensures accurate argument parsing.
Handling JSON Mode Responses
Set response_format: {"type": "json_object"}. This forces the model to output valid JSON. Use this for structured data extraction. It prevents malformed response errors.
Parse the JSON string in your code. Handle potential parsing errors. JSON mode improves reliability for API integrations. It is ideal for data processing pipelines.
Combine JSON mode with system prompts. Guide the model to output specific schemas. This ensures consistent formatting. Validate the output before using it. This reduces downstream errors.
Monitoring Limits and Errors
Respect the rate limits. You get 300 requests per minute per key. Maximum 8 concurrent requests. Request body size is limited to 8 MB.
Monitor HTTP status codes. 429 indicates rate limit exceeded. 400 indicates bad request. 500 indicates server error. Implement exponential backoff for retries. This prevents overwhelming the API.
Track token usage in the final streaming chunk. This helps manage your prepaid credit. Errors do not consume tokens. This protects your balance. Regular monitoring ensures smooth operation.
Calculating Costs and Token Usage
Pricing is transparent and prepaid. Input tokens cost $0.15 per million. Output tokens cost $0.50 per million. Credit never expires. No monthly fees apply.
Top up with crypto only. USDT (TRC20) or USDC (Base). Amounts range from $20 to $500. Bonus credit applies for larger top-ups. +5% from $50, +10% from $100, +15% from $200.
Calculate costs before heavy usage. Estimate token counts for your prompts. This helps budget effectively. Errors are free. Refunds are not issued, but mistakes are fixed. Use the dashboard to track spending.
Frequently asked questions
Is uncensoredai.com compatible with the OpenAI SDK?
Yes, the API is fully OpenAI compatible. You can use the standard OpenAI SDKs for Python, Node.js, and other languages. Just change the base URL to HTTPS://api.uncensoredaicom.com/v1 and pass your API key. The model ID is "uncensored". It follows the same request and response structure.
What crypto payments are accepted?
We accept USDT on the TRC20 network and USDC on the Base network. You can top up any whole amount between $20 and $500. Bonus credit is added automatically: +5% from $50, +10% from $100, and +15% from $200.
Does the prepaid credit expire?
No, your prepaid credit never expires. There are no monthly subscription fees or usage deadlines. You pay for what you use, and errors do not consume credit. This model ensures you only pay for actual value received.
Can I use this API for NSFW content?
Yes, the model is uncensored and does not refuse lawful adult, fictional, or controversial topics. It is designed for unrestricted text generation. The only hard limit is content involving minors, which is always refused. It is ideal for NSFW chatbots and creative writing.
Generate your API key
Register, retrieve the key, and update your endpoint. Minimal configuration required.