Perplexity API: An Uncensored Alternative
The Perplexity API provides a programmatic way to access Perplexity's large language models for high-accuracy, citation-backed responses. If you require a single, dedicated endpoint without content filtering for lawful adult or controversial topics, this guide outlines the technical specifications, pricing structure, and integration steps for the Perplexity API, alongside an uncensored alternative.
Updated
Key points
- Perplexity API offers a RESTful interface compatible with standard LLM patterns, delivering responses with source citations.
- The service supports multiple model variants, each with distinct context windows and pricing tiers.
- Integration requires setting the correct base URL and authentication headers, similar to other LLM providers.
- For developers needing an uncensored endpoint with a single model ID, an alternative API is available at api.openrouterapi.cc.
- Usage is billed per token, with costs varying based on the selected model and output length.
What is the Perplexity API?
The Perplexity API exposes Perplexity's large language models through a standard HTTP interface. It is designed for developers who need to integrate AI capabilities into applications that require high factual accuracy and traceable sources. Unlike generic chat interfaces, the API returns structured responses that include the model's generated text alongside a list of source URLs used to formulate the answer. This makes it particularly useful for applications where verification of information is critical.
Accessing the API involves sending POST requests to the designated endpoint. The service supports various model configurations, allowing developers to choose between different performance and speed characteristics. The API handles the underlying infrastructure, including model selection and caching, presenting a unified interface to the client. Developers can send prompts, receive text completions, and process the associated metadata for citation display. The service operates on a token-based pricing model, where costs are incurred based on the input and output token counts.
Perplexity API vs. Uncensored Alternatives
While the Perplexity API offers robust citation features and high accuracy, it operates under specific content guidelines. Requests that violate Perplexity's terms of service may be filtered or refused, depending on the nature of the content. This filtering can be a limitation for applications that require unrestricted access to information, including controversial or adult topics. In contrast, an uncensored API provides a single endpoint dedicated to an open-weight model that does not apply the same content refusals for lawful adult use.
The uncensored alternative simplifies integration by offering one model ID, eliminating the need to manage multiple model variants. This approach reduces complexity in client code, as developers do not need to route requests to different endpoints or handle varying response structures. For applications where citation is less important than unrestricted generation, the uncensored API provides a direct, no-nonsense solution. The uncensored model is hosted on dedicated servers, ensuring consistent performance without the overhead of aggregating multiple sources.
Integrating Perplexity API with OpenRouter SDK
Integrating the Perplexity API typically involves using an HTTP client or an SDK that supports the OpenAI-compatible protocol. You will need to obtain an API key from Perplexity's dashboard and include it in the authorization header of your requests. The base URL for the API is distinct from the standard OpenAI endpoint, so you must configure your client to point to the correct address.
curl https://api.openrouterapi.cc/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Write a blunt product review of a cheap VPN."}]
}'When sending a request, you specify the model ID and the prompt. The API returns a JSON response containing the generated text and a list of sources. Developers should handle potential errors, such as rate limits or invalid requests, by checking the status code and response body. The uncensored API follows a similar pattern, using the base URL https://api.openrouterapi.cc/v1 and the model ID "uncensored". This allows for easy swapping between providers if your application requires a different content policy.
Pricing Comparison
Perplexity API pricing is based on the number of tokens processed. Different models have different rates for input and output tokens. For example, the Sonar models may have higher costs compared to the standard models due to their enhanced accuracy and citation features. Developers should calculate the expected token usage to estimate costs accurately. The API charges for both the input prompt and the generated response, so longer conversations or large documents will incur higher fees.
In comparison, the uncensored API offers a transparent pricing structure: $0.25 per 1M input tokens and $1.00 per 1M output tokens. There are no monthly subscriptions or hidden fees. Credit is prepaid and never expires, and errors or refusals are free. This model can be more cost-effective for applications with high volume or unpredictable usage patterns. Additionally, the uncensored API supports crypto payments, which may be preferred by some developers for privacy or convenience.
Content Limitations
The Perplexity API adheres to content guidelines that may restrict certain types of content, including political, religious, or adult topics, depending on the model and settings. These limitations are designed to ensure the quality and appropriateness of the responses. If your application requires unrestricted access to all topics, including adult content, you may encounter refusals from the Perplexity API. The uncensored API, on the other hand, does not refuse lawful adult, fictional, or controversial topics. It is tuned to answer without content refusals, making it suitable for applications that need diverse content generation.
One hard content limit that always applies in the uncensored API is the prohibition of sexual content involving minors. Requests containing such content will be refused. This ensures that the model remains safe for general use while allowing for broader content generation. The uncensored API is ideal for developers who need a reliable, single endpoint for generating text without the need to manage multiple model IDs or routing logic.
Code Examples for Perplexity
Here is an example of how to send a request to the Perplexity API using Python. You will need to install the requests library and set your API key.
from openai import OpenAI
client = OpenAI(base_url="https://api.openrouterapi.cc/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)This code sends a simple prompt to the API and prints the response. The uncensored API can be integrated similarly by changing the base URL and model ID. The response from the uncensored API is a standard chat completion response, compatible with OpenAI SDKs. This allows for easy migration between providers based on your application's needs. The uncensored API supports streaming, function calling, and JSON mode, providing flexibility for various use cases.
Streaming with Perplexity
Both the Perplexity API and the uncensored API support streaming responses. Streaming allows you to receive tokens as they are generated, providing a faster perceived response time for users. To enable streaming, you set the stream parameter to true in your request. The API returns a series of events, each containing a portion of the response. You can process these events in real-time to display the text as it is generated.
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)Streaming is particularly useful for chat applications where users expect immediate feedback. The uncensored API supports streaming via SSE, with token usage included in the last chunk. This allows you to track usage and costs accurately. The Perplexity API also supports streaming, but the structure of the response may differ slightly. Developers should consult the respective documentation for the exact format of streaming events.
Why Switch to an Uncensored API?
Switching to an uncensored API can simplify your integration and reduce costs. The uncensored API offers a single model ID, eliminating the need to manage multiple models. This reduces complexity in your client code and ensures consistent behavior across requests. The uncensored model is tuned to answer without content refusals, making it suitable for applications that require unrestricted access to information.
Additionally, the uncensored API has transparent pricing with no monthly fees. Credit is prepaid and never expires, and errors are free. This can lead to significant cost savings for high-volume applications. The API supports standard features like streaming, function calling, and JSON mode, ensuring compatibility with existing tools. For developers who need a reliable, uncensored endpoint, the uncensored API is a strong alternative to the Perplexity API.
Questions and answers
Is the Perplexity API compatible with OpenAI SDKs?
The Perplexity API is not directly compatible with OpenAI SDKs out of the box, as it uses a different base URL and response structure. However, you can use an adapter or configure your client to point to the Perplexity endpoint. The uncensored API is fully compatible with OpenAI SDKs, requiring only a change in the base URL and API key.
Does the uncensored API filter adult content?
The uncensored API does not refuse lawful adult, fictional, or controversial topics. However, it does have a hard limit on sexual content involving minors, which is always refused. This ensures the model remains safe for general use while providing unrestricted content generation.
How do I pay for the uncensored API?
Payment for the uncensored API is accepted via crypto only, specifically USDT on the TRC20 network or USDC on the Base network. You can top up with any whole amount from $10 to $500. There are no monthly subscriptions or hidden fees, and credit never expires.
Can I use the uncensored API for function calling?
Yes, the uncensored API supports function calling, allowing you to define tools and let the model decide which tool to use. This feature is compatible with the OpenAI function calling format, making it easy to integrate into existing applications that rely on structured tool usage.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.