Qwen AI API Quickstart
Migrate your chat completions to our uncensored endpoint in minutes. This quickstart covers authentication, streaming, and parameter tuning for the OpenAI-compatible API.
Authentication & Base URL Setup
Start by generating your API key on the dashboard. The base URL is https://api.qwenaiapi.com/v1 and you pass your key in the Authorization header. This configuration works with any standard OpenAI SDK client without code changes. You receive one active key per account; generating a new one invalidates the previous key immediately. No phone number is required for signup.
First Request
Send a POST request to /v1/chat/completions with your key and model ID. The model identifier is uncensored and it responds to standard chat messages. You can test connectivity with a simple system prompt to verify latency and response format. Errors like 401 indicate an invalid key, while 402 means your prepaid credit is exhausted.
curl https://api.qwenaiapi.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Summarize this pull request diff"}]
}'
Python SDK Integration
Use the official Python client to interact with the endpoint. Set the base URL and API key in your initialization parameters. The SDK handles tokenization and JSON serialization automatically. This approach keeps your existing application logic intact while switching the underlying model provider. The client supports both synchronous and asynchronous operations.
from openai import OpenAI
client = OpenAI(base_url="https://api.qwenaiapi.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)
Node SDK Usage
Initialize the Node.js client with your base URL and key. The package supports standard chat completion requests. You can configure the model ID to ensure you are hitting the uncensored endpoint. This integration is ideal for server-side applications needing programmatic access. The SDK manages connection pooling efficiently for high-volume requests.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.qwenaiapi.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);
Streaming Responses
Enable streaming by setting the stream parameter to true. You receive server-sent events (SSE) as tokens are generated. The final chunk contains the total token usage for billing purposes. This reduces perceived latency for users by displaying text progressively. You must process the stream correctly to capture the final usage data.
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)
Context Window & Limits
The model supports a 100,000 token context window for prompt and completion combined. You can send up to 16,000 output tokens per request. Rate limits allow 300 requests per minute and 8 concurrent requests per key. Request bodies are capped at 8 MB. Understanding these limits helps you batch requests effectively without hitting 429 errors. Errors do not consume your prepaid credit.
Common questions
What is the uncensored qwen API base URL?
The base URL is HTTPS://api.qwenaiapi.com/v1. You must set this in your OpenAI-compatible client configuration to route requests correctly.
How do I get my qwen API key?
Sign up with Google or email on the Get API key page. Your key is displayed immediately and can be used to authenticate requests.
Does the uncensored qwen API support streaming?
Yes, streaming is supported via server-sent events. Set the stream parameter to true and process the response chunks to get token-by-token output.
Secure your API key
Register, copy your credentials, update the base URL. That is the entire configuration.