OpenAI SDK से Python और JavaScript में Unquant call करें
Unquant OpenAI chat completions format में बोलता है, इसलिए official SDKs बिना बदलाव के काम करते हैं। Base URL और key बदलें, बाकी code रखें।
Python
pip install openaiimport os
from openai import OpenAI
client = OpenAI(base_url="https://api.unquant.io/v1", api_key=os.environ["UNQUANT_API_KEY"])
reply = client.chat.completions.create(
model="glm-5.3-flash",
messages=[{"role": "user", "content": "Write a noir opening line."}],
)
print(reply.choices[0].message.content)JavaScript और TypeScript
npm install openaiimport OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.unquant.io/v1", apiKey: process.env.UNQUANT_API_KEY });
const reply = await client.chat.completions.create({
model: "qwen-3.8-flash-next",
messages: [{ role: "user", content: "Summarise this chapter in three lines." }],
});
console.log(reply.choices[0].message.content);Streaming
stream = client.chat.completions.create(
model="glm-5.3-flash",
messages=[{"role": "user", "content": "Tell me a long story."}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)include_usage token counts के साथ एक final chunk जोड़ता है। Usage कभी bill नहीं होता; यह आपकी खुद की monitoring के लिए है।
Images
Images को base64 data URLs (PNG, JPEG या WebP) के रूप में inline भेजें। Remote image URLs fetch नहीं होते।
import base64
data = base64.b64encode(open("photo.jpg", "rb").read()).decode()
client.chat.completions.create(
model="glm-5.3-flash",
messages=[{"role": "user", "content": [
{"type": "text", "text": "What is in this picture?"},
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{data}"}},
]}],
)Tool calling
tools = [{"type": "function", "function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]},
}}]
reply = client.chat.completions.create(model="glm-5.3-flash", tools=tools,
messages=[{"role": "user", "content": "Weather in Lisbon?"}])
print(reply.choices[0].message.tool_calls)Reasoning control
हर model जवाब देने से पहले reason करता है और अपनी thinking reasoning_content में अलग से return करता है। reasoning_effort को none, low या high pass करें (GLM-5.3-Flash और DeepSeek V4.1 Flash 1017 max भी लेते हैं):
client.chat.completions.create(model="glm-5.3-flash", reasoning_effort="none",
messages=[{"role": "user", "content": "Quick answer: capital of Peru?"}])Errors handle करना
आपके plan के सभी streams व्यस्त हैं। Request शुरू नहीं हुई; एक finish होने पर retry करें।
एक brief restart। Retry-After header का इंतज़ार करें, फिर retry करें।
पूरी list error reference में है।
आगे पढ़ें
- Claude Code को uncensored, unlimited model के साथ कैसे उपयोग करेंUnquant के Anthropic-compatible endpoint के ज़रिए GLM-5.3-Flash, Qwen 3.8 Flash Next या DeepSeek V4.1 Flash 1017 पर Claude Code चलाएं: दो environment variables, कोई proxy नहीं, unlimited tokens और 262K context।
- Open WebUI को Unquant से कैसे connect करेंUnquant को OpenAI API connection के रूप में Open WebUI में जोड़ें: URL, key और model list। Uncensored GLM-5.3-Flash, Qwen 3.8 Flash Next और DeepSeek V4.1 Flash 1017 पर private, ChatGPT-style interface।
- Coding और agents के लिए uncensored AIDevelopers uncensored model का उपयोग coding और agents के लिए क्यों करते हैं: security work, reverse engineering या edgy content pipelines पर कोई refusal नहीं, साथ में long agent loops के लिए 262K context और unlimited tokens।