Base URL and Authentication
The API accepts requests at https://api.qwenapipricing.com/v1. Every call requires a Bearer token passed in the Authorization header. You generate this key on the signup page and it identifies your prepaid credit account.
- Use standard HTTP headers for authentication.
- The key remains valid until your credit expires or you revoke it.
First Request
Send a chat completion request to test connectivity. This simple call verifies your key works and returns a basic response.
You can verify your key works with this example.
curl https://api.qwenapipricing.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "list the costs for the qwen2.5 models"}]
}'
Python Integration
Use the official OpenAI Python SDK to interact with our service. Point the client to our base URL and supply your key.
This setup works with any standard Python library expecting OpenAI endpoints.
from openai import OpenAI
client = OpenAI(base_url="https://api.qwenapipricing.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.js Integration
Node developers can use the openai npm package. Configure the client with our base URL to send requests.
This approach maintains compatibility with existing OpenAI codebases.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.qwenapipricing.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 stream: true in your request. The API returns tokens via Server-Sent Events.
Each chunk includes usage data in the final event, allowing you to track consumption in real time.
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)
Rate Limits and Errors
Each key allows 300 requests per minute and 8 concurrent connections. You receive a 401 error for invalid keys, 402 when credit is exhausted, and 429 for rate limits. The context window supports 100,000 tokens total.