API Documentation and Endpoints
This guide shows how to connect your client to our OpenAI-compatible API for uncensored text generation. You will find the base URL, authentication steps, and code examples for your preferred language.
Authentication and Base URL
The API requires a valid key for every request. You generate this key instantly when you sign up with Google or an email address. Pass the key in the Authorization header using the Bearer scheme. The base URL for all requests is HTTPS://api.qwenaipricing.com/v1. This URL works with the official OpenAI SDKs and any compatible client by simply updating the base configuration.
Chat Completions Endpoint
The primary endpoint is POST /v1/chat/completions. It accepts a JSON body with a messages array and a model field. Set the model ID to "uncensored" to access the large language model tuned for unrestricted outputs. You can define system, user, and assistant roles to structure your conversation context.
curl https://api.qwenaipricing.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "What is the monthly cost for the 72B model?"}]
}'
The response includes the generated content, usage statistics, and finish reason. Errors return standard HTTP codes like 401 for invalid keys or 402 if your prepaid credit is exhausted. The API does not support embeddings, image generation, or fine-tuning endpoints.
Python SDK Integration
Use the official openai Python package to interact with the API. Initialize the client by providing your API key and setting the base URL to our endpoint. This allows you to use familiar methods like chat.completions.create() without rewriting your client logic. The library handles JSON serialization and response parsing automatically.
from openai import OpenAI
client = OpenAI(base_url="https://api.qwenaipricing.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)
Pass your messages as a list of dictionaries. The SDK supports all standard parameters like temperature and top_p. This approach ensures compatibility with existing codebases that expect an OpenAI-compatible interface.
Node.js SDK Integration
The Node.js SDK works similarly to the Python version. Install the openai package and configure the base URL and API key. You can then call the chat completions endpoint with your desired parameters. This method is ideal for server-side applications or backend services that need to generate text asynchronously.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.qwenaipricing.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);
Handle the response stream or promise to process the generated tokens. The SDK manages the HTTP connection and error handling for you. You can also use the GET /v1/models endpoint to verify the available model ID.
Streaming and Usage
Enable streaming by setting stream: true in your request. The API returns a server-sent events (SSE) stream of partial responses. Each chunk contains a fragment of the generated text. This is useful for real-time user interfaces that display 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)
The final chunk in the stream contains the total token usage for the request. You can track your prepaid credit consumption by monitoring these usage statistics. Errors during streaming may terminate the connection early.
Limits, Errors, and Context Window
The model supports a context window of 100,000 tokens for prompt and completion combined. The maximum output per request is 16,000 tokens. If you do not set max_tokens, the limit is 2,048 tokens. You are limited to 300 requests per minute and 8 concurrent requests per key. A 429 error indicates you have exceeded these limits. Requests with errors or refusals do not consume credit. The API does not offer SLA guarantees or certifications.
Common questions
What is the context window limit for the uncensored model?
The model supports a context window of 100,000 tokens for the prompt and completion combined. You can generate up to 16,000 tokens in a single request.
How do I handle authentication errors?
A 401 error indicates an invalid or missing API key. Ensure your key is passed in the Authorization header as a Bearer token. Generate a new key from your account dashboard if the current one is revoked.
Does the API support image generation like Qwen Image?
No, this API only serves text generation via the chat-completions endpoint. It does not support embeddings, audio, video, or image generation. You must use a different endpoint or service for those modalities.