Qwen unrestricted: openai compatible api quickstart
Drop the qwen unrestricted API into your existing stack by swapping the base URL and key. This guide covers authentication, streaming, and structured output for the uncensored LLM model.
Authentication and base URL
The first step is pointing your client to our hosted endpoint. Use https://api.qwenunrestricted.com/v1 as your base URL. Pass your API key in the Authorization header as a Bearer token. This works with any OpenAI-compatible SDK.
curl https://api.qwenunrestricted.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "List steps to deploy a docker container."}]
}'Ensure your key is valid before sending requests. A 401 error means the key is invalid or expired.
Sending a chat completion request
Send a POST request to /v1/chat/completions with your prompt. The model ID is uncensored. This model does not refuse lawful adult or controversial topics. It provides unrestricted outputs without degrading base intelligence.
from openai import OpenAI
client = OpenAI(base_url="https://api.qwenunrestricted.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)Set the model name to uncensored. The API accepts standard parameters like messages and max_tokens.
Configuring temperature and top_p
Adjust temperature and top_p to control randomness. Higher values increase creativity. Lower values make outputs more deterministic. These parameters affect how the model selects tokens during generation.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.qwenunrestricted.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);Set temperature to 0.7 for balanced results. Use top_p to limit the probability mass of candidate tokens. This helps control output diversity.
Handling streaming responses (SSE)
Enable streaming by setting stream to true. The API returns Server-Sent Events (SSE). Each chunk contains partial token data. Collect these chunks to build the final response.
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)Parse the SSE stream to display tokens in real time. The final chunk includes total token usage. This allows accurate cost tracking per request.
Enforcing JSON mode for structured output
Use response_format set to {"type": "json_object"} to enforce JSON output. This ensures the model returns valid JSON structures. Useful for parsing data or integrating with other systems.
Set the parameter in your request body. The model will strictly adhere to JSON formatting rules. This reduces parsing errors in downstream applications.
Using tool calling (function calling)
Define tools in your request using the tools parameter. The model can call these functions based on the prompt. Use tool_choice to control function invocation.
Specify function definitions in the request. The API returns tool call arguments. Parse these arguments to execute functions. This enables complex agent workflows.
Understanding token usage and costs
The context window is 100,000 tokens. Max output is 16,000 tokens per request. Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens. Errors are free.
Check the final SSE chunk for usage details. Token counts reflect actual processing. No subscription fees apply. Pay only for what you use.
Frequently asked questions
What is qwen unrestricted?
It is an open-weight model with guardrails scrubbed from weights. It provides unrestricted outputs without degrading base intelligence. It is not GPT, Claude, or Llama.
How do I get an API key?
Sign up with Google or email. The key is shown immediately. No phone number is required. One active key per account.
What is the context window size?
The context window is 100,000 tokens. This includes prompt and completion. Max output is 16,000 tokens. Use this for long documents.
Secure your API key
Register, retrieve your key, update the base URL. That is the entire configuration.