Qwen api key Integration Guide
Connect your application to our uncensored LLM API using standard OpenAI-compatible endpoints. This guide covers authentication, request formats, streaming, and tool calling for immediate integration.
Base URL and Authentication
Use the provided base URL and an API key for all requests. We support standard headers and client libraries.
- Base URL: HTTPS://api.qwenapikey.com/v1
- Auth Header: Authorization: Bearer
The API key is generated when you sign up. Keep it secure. You can rotate it anytime from your dashboard.
First Request
Send a POST request to /v1/chat/completions to get a response. Use the model id "uncensored".
Here is a curl example:
- Command: curl -X POST HTTPS://api.qwenapikey.com/v1/chat/completions -H "Authorization: Bearer YOUR_KEY" -H "Content-Type: application/json" -d '{"model": "uncensored", "messages": [{"role": "user", "content": "Hello"}]}'
This returns a JSON object with the generated text.
Python SDK Integration
Install the OpenAI Python package and configure it to point to our base URL. Pass your key and set the model to "uncensored".
Code example:
- pip install openai
- from openai import OpenAI
- client = OpenAI(base_url="HTTPS://api.qwenapikey.com/v1", api_key="YOUR_KEY")
- response = client.chat.completions.create(model="uncensored", messages=[{"role": "user", "content": "Test"}])
Access the response via response.choices[0].message.content.
Node SDK Integration
Use the OpenAI Node SDK. Set the base URL and API key in the configuration object. Specify the model as "uncensored".
Code example:
- import OpenAI from 'openai';
- const openai = new OpenAI({ baseUrl: 'HTTPS://api.qwenapikey.com/v1', apiKey: 'YOUR_KEY' });
- const response = await openai.chat.completions.create({ model: 'uncensored', messages: [{ role: 'user', content: 'Test' }] });
Retrieve the text from the response object.
Streaming Responses and Tokens
Enable streaming by setting stream: true. The API returns Server-Sent Events (SSE). Token usage is included in the last chunk.
Code example:
- const stream = await client.chat.completions.create({ model: 'uncensored', messages: [{ role: 'user', content: 'Tell a story' }], stream: true });
- for await (const chunk of stream) { console.log(chunk.choices[0].delta.content); }
Check the last chunk for usage statistics.
Limits, Errors, and Context
Handle 401 for invalid keys, 402 for insufficient credit, and 429 for rate limits. The context window is 100,000 tokens. Max output is 16,000 tokens. Request limit is 300 per minute.
Monitor your usage via the dashboard. Errors during processing do not charge credits. Refusals for content policy are also free.
cURL
curl https://api.qwenapikey.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "List the endpoints for the qwen api key"}]
}'Python
from openai import OpenAI
client = OpenAI(base_url="https://api.qwenapikey.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
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.qwenapikey.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
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)Common questions
How do I get my qwen API key?
Sign up using Google or email. Your key is displayed immediately. No phone number is required. You can rotate it anytime.
What is the context window size?
The context window is 100,000 tokens. This includes both input and output. Max output per request is 16,000 tokens.
How does billing work?
Prepaid credit is charged by real token usage. Errors and refusals are free. Credit never expires. Top up with crypto only.
Get your key now
Sign up, copy the key, update your base URL. Done.