चैट कम्प्लीशन
OpenAI-compatible chat completions, streaming, images, tool calling और reasoning control के साथ।
POST /v1/chat/completions
curl https://api.unquant.io/v1/chat/completions \
-H "Authorization: Bearer $UNQUANT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"glm-5.3-flash",
"messages":[{"role":"user","content":"Hello!"}]}'Request fields
modelstringRequiredglm-5.3-flash या qwen-3.8-flash-next या deepseek-v4.1-flash-1017।
messagesarrayRequiredRoles system, user, assistant और tool। Content एक string या text और image_url parts का array है।
streambooleanReply को server-sent events के रूप में stream करें।
stream_optionsobject{"include_usage": true} token counts के साथ एक final chunk जोड़ता है।
max_tokensintegerReply length पर upper bound।
max_completion_tokensintegermax_tokens के समान।
temperaturenumberSampling की randomness।
top_pnumberNucleus sampling।
top_kintegerk सबसे likely tokens में से sample करें।
min_pnumberकिसी token के लिए minimum relative probability।
seedintegerRepeatable sampling के लिए seed।
stopstring or arrayStop sequences।
frequency_penaltynumberTokens को कितनी बार appear हुए उसके हिसाब से penalise करें।
presence_penaltynumberजो tokens appear हुए उन्हें penalise करें।
repetition_penaltynumberMultiplicative repetition penalty।
toolsarrayवे functions जिन्हें model call कर सकता है, OpenAI format में।
tool_choicestring or objectauto, none, required या एक named function।
parallel_tool_callsbooleanएक turn में कई tool calls की अनुमति दें।
response_formatobjectJSON output।
logprobsbooleanToken log probabilities return करें।
top_logprobsintegerप्रति token कितने alternatives return करें।
ninteger1 होना चाहिए: प्रति request एक completion।
reasoning_effortstringहर model: low या high; GLM-5.3-Flash और DeepSeek V4.1 Flash 1017 max भी लेते हैं। Qwen 3.8 Flash Next और DeepSeek V4.1 Flash 1017 none भी लेते हैं (thinking off); GLM-5.3-Flash हमेशा सोचता है और इसे refuse करता है।
chat_template_kwargsobjectTemplate switches, जैसे {"enable_thinking": false} (Qwen 3.8 Flash Next और DeepSeek V4.1 Flash 1017; GLM-5.3-Flash हमेशा सोचता है)।
prompt_cache_keystringप्रति conversation एक stable value उसके turns को उस server पर रखती है जो उसका cached prompt hold करता है। इसके बिना, conversation उसके system prompt और पहले message से पहचाना जाता है, इसलिए इसे set करें अगर आपका system prompt turns के बीच बदलता है।
बाकी fields ignore की जाती हैं।
Response
response.choices[0].message.contentUsage counts आपकी खुद की monitoring के लिए return होती हैं; इन्हें कभी bill नहीं किया जाता।
Streaming
"stream": true के साथ reply OpenAI chunk format में server-sent events के रूप में आती है, data: [DONE] पर समाप्त होती है। choices[0].delta.content से text पढ़ें।
Images
हर model images को image_url parts के रूप में accept करता है जो base64 data URL (data:image/png;base64,..., JPEG या WebP) hold करते हैं। URL से image links fetch नहीं होते और 400 return करते हैं।
{"role": "user", "content": [
{"type": "text", "text": "Describe this image."},
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,/9j/4AAQ..."}}
]}Tool calling
OpenAI API की तरह tools pass करें। जब model एक tool call करता है, reply में finish_reason: "tool_calls" और message.tool_calls होता है; tool run करें, उसके result और matching tool_call_id के साथ एक tool message append करें, और फिर से call करें।
Reasoning
हर model जवाब देने से पहले reason करता है और reasoning_effort लेता है: हल्के reasoning के लिए low या कठिन problems के लिए high; GLM-5.3-Flash और DeepSeek V4.1 Flash 1017 में max भी है और default high है। Thinking अलग से reasoning_content में return होती है, कभी content में mix नहीं होती।
GLM-5.3-Flash हमेशा सोचता है: उसका reasoning बंद नहीं किया जा सकता, और ऐसा request करने पर 400 error के साथ refuse कर दिया जाता है। Qwen 3.8 Flash Next और DeepSeek V4.1 Flash 1017 सीधे भी जवाब दे सकते हैं: none भेजें, या "thinking": {"type": "disabled"} या "chat_template_kwargs": {"enable_thinking": false}।
Concurrency
आपका plan set करता है कि आपकी सभी keys पर एक साथ कितने requests run हो सकते हैं। उस limit से परे कोई request 429 तुरंत return करती है और queue नहीं होती; running requests प्रभावित नहीं होतीं।