रीझनिंग effort
नवीनरीझनिंग करणारे मॉडेल आपला रीझनिंग मजकूर उत्तराच्या शेजारी, स्वतःच्या फील्डमध्ये परत देते. होस्ट केलेल्या open-weight मॉडेल्सवर एक रिक्वेस्ट फील्ड ठरवते की मॉडेल उत्तर देण्यापूर्वी किती खोलवर रीझनिंग करते.
POST https://api.shannon-ai.com/v1/chat/completions
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.shannon-ai.com/v1")
response = client.chat.completions.create(
model="Kimi-K3-3BIT-REAP",
reasoning_effort="low",
messages=[{"role": "user", "content": "Is 221 a prime number?"}],
)
message = response.choices[0].message
print("Reasoning:", getattr(message, "reasoning_content", None))
print("Answer:", message.content)
print("Reasoning tokens:", response.usage.completion_tokens_details.reasoning_tokens) import OpenAI from "openai";
const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://api.shannon-ai.com/v1" });
const response = await client.chat.completions.create({
model: "Kimi-K3-3BIT-REAP",
reasoning_effort: "low",
messages: [{ role: "user", content: "Is 221 a prime number?" }],
});
const message = response.choices[0].message;
console.log("Reasoning:", message.reasoning_content);
console.log("Answer:", message.content);
console.log("Reasoning tokens:", response.usage.completion_tokens_details.reasoning_tokens); curl https://api.shannon-ai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Kimi-K3-3BIT-REAP",
"reasoning_effort": "low",
"messages": [
{"role": "user", "content": "Is 221 a prime number?"}
]
}' उत्तरात रीझनिंग मजकूर reasoning_content मध्ये, उत्तर content मध्ये आणि रीझनिंग टोकन्स usage मध्ये असतात:
{
"id": "chatcmpl-2a6c8e0b4d1f4a3c9e7b5d3f1a8c6e4b",
"object": "chat.completion",
"created": 1791590400,
"model": "Kimi-K3-3BIT-REAP",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "No. 221 = 13 x 17, so it is not prime.",
"reasoning_content": "Try small primes. 221 / 13 = 17, so 221 = 13 x 17."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 14,
"completion_tokens": 43,
"total_tokens": 57,
"prompt_tokens_details": {"cached_tokens": 0},
"completion_tokens_details": {"reasoning_tokens": 27}
}
} कोणती मॉडेल्स रीझनिंग करतात
| मॉडेल | रीझनिंग मजकूर देते | effort फील्ड लागू करते |
|---|---|---|
shannon-1.6-lite | — | — |
shannon-1.6-pro, shannon-2-lite, shannon-2-pro, shannon-3, shannon-3-pro, shannon-3.1, shannon-3.1-pro, shannon-coder-1 | होय | — |
| प्रत्येक होस्ट केलेले open-weight मॉडेल | होय | होय |
हे GET /v1/models प्रत्येक id साठी कळवत असलेले capabilities.reasoning आणि capabilities.reasoning_effort फ्लॅग्स आहेत. मॉडेलने काही तयार केले असेल तेव्हाच उत्तरात रीझनिंग मजकूर असतो. मॉडेल्स आणि किंमत
Effort सेट करणे
प्रत्येक एंडपॉइंटची effort लिहिण्याची स्वतःची पद्धत आहे. त्या सर्व त्याच चार स्तरांपैकी एक निवडतात.
| फील्ड | प्रकार | डिफॉल्ट | वर्णन | लागू करणारे |
|---|---|---|---|---|
reasoning_effort | string | high | /v1/chat/completions. मॉडेल उत्तर देण्यापूर्वी किती खोलवर रीझनिंग करते: off, low, medium किंवा high. | होस्ट केलेली open-weight मॉडेल्स |
reasoning | object | string | /v1/chat/completions. {"effort": "low"} म्हणून किंवा साधी स्ट्रिंग म्हणून तेच मूल्य. दोन्ही फील्ड्स पाठवल्यास reasoning_effort ग्राह्य धरले जाते. | होस्ट केलेली open-weight मॉडेल्स | |
reasoning.effort | string | high | /v1/responses. {"effort": "low"} या ऑब्जेक्टच्या रूपात लिहिले जाते. | होस्ट केलेली open-weight मॉडेल्स |
thinking | object | /v1/messages. {"type": "enabled", "budget_tokens": n} किंवा {"type": "disabled"}. बजेट स्तरांपैकी एक निवडते; खाली दिलेला तक्ता पाहा. | होस्ट केलेली open-weight मॉडेल्स |
{
"model": "Kimi-K3-3BIT-REAP",
"reasoning_effort": "low",
"messages": [{"role": "user", "content": "Is 221 a prime number?"}]
} {
"model": "Kimi-K3-3BIT-REAP",
"reasoning": {"effort": "low"},
"input": "Is 221 a prime number?"
} {
"model": "Kimi-K3-3BIT-REAP",
"max_tokens": 1024,
"thinking": {"type": "enabled", "budget_tokens": 2048},
"messages": [{"role": "user", "content": "Is 221 a prime number?"}]
} | व्हॅल्यू | हेही स्वीकारले जाते | परिणाम |
|---|---|---|
off | none, minimal | रीझनिंग नाही. उत्तरात रीझनिंग मजकूर नसतो. |
low | थोडक्यात रीझनिंग. | |
medium | default | मध्यम खोली. |
high | max | सर्वात खोल स्तर. मूल्य न पाठवणाऱ्या रिक्वेस्टचा हाच स्तर असतो. |
- मूल्ये मोठ्या किंवा लहान अक्षरांचा विचार न करता वाचली जातात.
defaultया मूल्याचा अर्थmedium. फील्ड वगळल्यासhighअसे समजले जाते.- Shannon मॉडेल्स (
shannon-*) प्रत्येक रिक्वेस्टमध्ये स्वतःची खोली ठरवतात;GET /v1/modelsत्यांच्यासाठीreasoning_effort: falseकळवते.
/v1/messages वरील thinking बजेट (मर्यादा)
/v1/messages वर thinking फील्ड स्तर निवडते. budget_tokens वरील स्तरांपैकी एक निवडते; ती स्वतःची टोकन मर्यादा नाही. adaptive हे enabled प्रमाणे वाचले जाते.
| तुम्ही पाठवता | स्तर |
|---|---|
{"type": "disabled"} | off |
{"type": "enabled", "budget_tokens": n} आणि n 2,048 पर्यंत | low |
n 2,049 ते 8,192 | medium |
मोठे n, किंवा budget_tokens शिवाय enabled | high |
thinking फील्ड नाही | high |
रीझनिंग मजकूर कुठे येतो
रीझनिंग मजकूर नेहमी उत्तरापासून वेगळा असतो. प्रत्येक फॉरमॅटमध्ये त्याची स्वतःची जागा आहे:
| एंडपॉइंट | स्ट्रीम नसलेले | स्ट्रीम केलेले |
|---|---|---|
/v1/chat/completions | choices[0].message.reasoning_content: स्ट्रिंग, किंवा मॉडेलने काही दिले नसल्यास null. | choices[0].delta.reasoning_content असलेले चंक्स, delta.content असलेल्या चंक्सच्या आधी. |
/v1/responses | message आयटमच्या आधी output आयटम {"type": "reasoning", "summary": [{"type": "summary_text", "text": "…"}]}. रीझनिंग नसल्यास आयटम नसतो. | reasoning आयटमसह response.output_item.added, त्यानंतर response.reasoning_summary_text.delta इव्हेंट्स आणि एक response.reasoning_summary_text.done. |
/v1/messages | पहिला कंटेंट ब्लॉक {"type": "thinking", "thinking": "…"}, त्यानंतर text ब्लॉक. रीझनिंग नसल्यास thinking ब्लॉक नसतो. | thinking कंटेंट ब्लॉक: content_block_start, thinking_delta असलेले content_block_delta इव्हेंट्स, content_block_stop. त्यानंतर टेक्स्ट ब्लॉक येतो. |
{
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "No. 221 = 13 x 17, so it is not prime.",
"reasoning_content": "Try small primes. 221 / 13 = 17, so 221 = 13 x 17."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 14,
"completion_tokens": 43,
"total_tokens": 57,
"prompt_tokens_details": {"cached_tokens": 0},
"completion_tokens_details": {"reasoning_tokens": 27}
}
} {
"output": [
{
"id": "rs_6f0a2c4e8b1d4f3a9c7e5b3d1f8a6c4e",
"type": "reasoning",
"summary": [
{
"type": "summary_text",
"text": "Try small primes. 221 / 13 = 17, so 221 = 13 x 17."
}
]
},
{
"id": "msg_1b3d5f7a9c2e4b6d8f0a2c4e6b8d0f1a",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "No. 221 = 13 x 17, so it is not prime.",
"annotations": []
}
]
}
],
"usage": {
"input_tokens": 14,
"input_tokens_details": {"cached_tokens": 0},
"output_tokens": 43,
"output_tokens_details": {"reasoning_tokens": 27},
"total_tokens": 57
}
} {
"content": [
{
"type": "thinking",
"thinking": "Try small primes. 221 / 13 = 17, so 221 = 13 x 17."
},
{"type": "text", "text": "No. 221 = 13 x 17, so it is not prime."}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 14,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0,
"output_tokens": 43
}
} कुठे पाहायचे, प्रत्येक मॉडेलनुसार:
| मॉडेल्स | मजकूर कुठे येतो |
|---|---|
| होस्ट केलेली open-weight मॉडेल्स | प्रत्येक एंडपॉइंटवर, स्ट्रीम केलेले किंवा नसलेले. effort off असलेल्या किंवा response_format / text.format असलेल्या रिक्वेस्टला रीझनिंग मजकुराशिवाय उत्तर मिळते. |
shannon-3, shannon-3-pro, shannon-3.1, shannon-3.1-pro | प्रत्येक एंडपॉइंटवर, स्ट्रीम केलेले किंवा नसलेले, मॉडेलने रीझनिंग मजकूर तयार केला असेल तेव्हा. |
shannon-2-lite, shannon-2-pro | /v1/chat/completions, स्ट्रीम नसलेले: message.reasoning_content मध्ये. स्ट्रीम केलेले, tools किंवा response_format नसलेल्या रिक्वेस्टमध्ये: मॉडेल रीझनिंग करत असताना स्ट्रीम : thinking या कमेंट ओळी देतो, मग उत्तराचे चंक्स. /v1/messages, स्ट्रीम केलेले: टेक्स्ट ब्लॉकच्या आधी thinking ब्लॉक. |
shannon-1.6-pro, shannon-coder-1 | स्ट्रीम केलेल्या उत्तरांमध्ये आणि tools असलेल्या रिक्वेस्ट्सच्या उत्तरांमध्ये, मॉडेलने रीझनिंग मजकूर तयार केला असेल तेव्हा. |
/v1/responses वर, स्ट्रीम नसलेल्या उत्तरात Shannon 3 कुटुंब आणि होस्ट केलेल्या open-weight मॉडेल्ससाठी reasoning आयटम असतो.
स्ट्रीम वाचणे
स्ट्रीममध्ये रीझनिंग मजकूर आधी, स्वतःच्या डेल्टांमध्ये येतो आणि त्यानंतर उत्तर. दोन्ही वेगळे छापा किंवा साठवा:
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.shannon-ai.com/v1")
stream = client.chat.completions.create(
model="Kimi-K3-3BIT-REAP",
reasoning_effort="medium",
stream=True,
messages=[{"role": "user", "content": "Is 221 a prime number?"}],
)
for chunk in stream:
if not chunk.choices:
continue
delta = chunk.choices[0].delta
reasoning = getattr(delta, "reasoning_content", None)
if reasoning:
print(reasoning, end="", flush=True) # the reasoning text comes first
if delta.content:
print(delta.content, end="", flush=True) # then the answer import OpenAI from "openai";
const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://api.shannon-ai.com/v1" });
const stream = await client.chat.completions.create({
model: "Kimi-K3-3BIT-REAP",
reasoning_effort: "medium",
stream: true,
messages: [{ role: "user", content: "Is 221 a prime number?" }],
});
for await (const chunk of stream) {
const delta = chunk.choices[0]?.delta ?? {};
if (delta.reasoning_content) process.stdout.write(delta.reasoning_content); // the reasoning text comes first
if (delta.content) process.stdout.write(delta.content); // then the answer
} curl -N https://api.shannon-ai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Kimi-K3-3BIT-REAP",
"reasoning_effort": "medium",
"stream": true,
"messages": [
{"role": "user", "content": "Is 221 a prime number?"}
]
}' होस्ट केलेल्या open-weight मॉडेलच्या पहिल्या चंकमध्ये, रीझनिंग असो वा उत्तर, delta.role: "assistant" देखील असते. स्ट्रीमिंग
रीझनिंग टोकन्स आणि बिलिंग
होस्ट केलेल्या open-weight मॉडेल्सवर रीझनिंग टोकन्स ही आउटपुट टोकन्स आहेत: त्यांचे बिल मॉडेलच्या आउटपुट किमतीने लागते, आणि आउटपुट संख्येत ती आधीच समाविष्ट असतात. येथे usage रीझनिंगचा वाटा दाखवतो:
| एंडपॉइंट | फील्ड | टीप |
|---|---|---|
/v1/chat/completions | usage.completion_tokens_details.reasoning_tokens | completion_tokens मध्ये आधीच समाविष्ट. |
/v1/responses | usage.output_tokens_details.reasoning_tokens | output_tokens मध्ये आधीच समाविष्ट. |
/v1/messages | usage.output_tokens | रीझनिंग आणि उत्तर मिळून. या फॉरमॅटमध्ये वेगळी संख्या नाही. |
- होस्ट केलेल्या open-weight मॉडेल्सवर
max_tokensउत्तराचा मजकूर मर्यादित करते. रीझनिंग टोकन्स त्यात मोजली जात नाहीत. - रीझनिंगचे बिल आउटपुट म्हणून लागत असल्याने effort स्तर हा खर्चाचा देखील एक सेटिंग आहे:
offरीझनिंग टोकन्स तयार करत नाही. - Shannon मॉडेल्स
prompt_tokens,completion_tokensआणिtotal_tokens(/v1/messagesवरinput_tokensआणिoutput_tokens) रीझनिंगचा वाटा न दाखवता कळवतात, आणि प्रत्येक टोकनसाठी एक निश्चित किंमत आकारतात. मॉडेल्स आणि किंमत
पुढच्या रिक्वेस्टमधील रीझनिंग
रीझनिंग परत पाठवावे लागत नाही. तुम्ही पाठवलेल्या संभाषणातील thinking ब्लॉक किंवा reasoning आयटम मॉडेलला दिला जात नाही, म्हणून असिस्टंट टर्न त्याच्यासह किंवा त्याशिवाय परत जाऊ शकतो. thinking ब्लॉकला type आणि thinking ही दोन फील्ड्स असतात; त्याला signature नसते.
त्रुटी
| स्टेटस | प्रकार | संदेश | केव्हा |
|---|---|---|---|
400 | invalid_request_error | unknown reasoning effort '<value>'; expected off, low, medium or high | होस्ट केलेल्या open-weight मॉडेलला यादीबाहेरचे मूल्य मिळाले, उदाहरणार्थ xhigh. तुमच्या बॅलन्समधून काहीही वजा होत नाही. |
422 | invalid_request_error | Failed to deserialize the JSON body into the target type: … | reasoning_effort स्ट्रिंग नाही. |
प्रमाणीकरण, बॅलन्स आणि सर्व्हर त्रुटी प्रत्येक रिक्वेस्टप्रमाणेच आहेत. त्रुटी हाताळणी