कंटेंट पर जाएँ
रीज़निंग effort

रीज़निंग effort

नया

रीज़निंग करने वाला मॉडल अपना रीज़निंग टेक्स्ट उत्तर के बगल में, अपने अलग फ़ील्ड में लौटाता है। होस्टेड ओपन-वेट मॉडल पर एक अनुरोध फ़ील्ड तय करता है कि मॉडल उत्तर देने से पहले कितनी गहराई से रीज़निंग करे।

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)

उत्तर में रीज़निंग टेक्स्ट reasoning_content में, उत्तर content में, और रीज़निंग टोकन usage में होते हैं:

200 JSON
{
  "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 हाँ —
हर होस्टेड ओपन-वेट मॉडल हाँ हाँ

ये वे फ़्लैग capabilities.reasoning और capabilities.reasoning_effort हैं जो GET /v1/models हर id के लिए बताता है। उत्तर में रीज़निंग टेक्स्ट तभी होता है जब मॉडल ने कुछ बनाया हो। मॉडल और कीमतें

effort सेट करना

हर endpoint में effort की अपनी वर्तनी है। सब उन्हीं चार स्तरों में से एक चुनते हैं।

फ़ील्ड प्रकार डिफ़ॉल्ट विवरण लागू करने वाले
reasoning_effort string high /v1/chat/completions। उत्तर देने से पहले मॉडल कितनी गहराई से रीज़निंग करता है: off, low, medium या high। होस्टेड ओपन-वेट मॉडल
reasoning object | string /v1/chat/completions। वही मान {"effort": "low"} के रूप में या सीधी स्ट्रिंग के रूप में। दोनों फ़ील्ड भेजे जाने पर reasoning_effort गिना जाता है। होस्टेड ओपन-वेट मॉडल
reasoning.effort string high /v1/responses। ऑब्जेक्ट {"effort": "low"} के रूप में लिखा जाता है। होस्टेड ओपन-वेट मॉडल
thinking object /v1/messages। {"type": "enabled", "budget_tokens": n} या {"type": "disabled"}। बजट स्तरों में से एक चुनता है; नीचे की तालिका देखें। होस्टेड ओपन-वेट मॉडल
{
  "model": "Kimi-K3-3BIT-REAP",
  "reasoning_effort": "low",
  "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 पर थिंकिंग बजट

/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

रीज़निंग टेक्स्ट कहाँ आता है

रीज़निंग टेक्स्ट हमेशा उत्तर से अलग होता है। हर फ़ॉर्मेट में उसकी अपनी जगह है:

Endpoint स्ट्रीम नहीं स्ट्रीम
/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}
  }
}

कहाँ देखें, हर मॉडल के लिए:

मॉडल टेक्स्ट कहाँ आता है
होस्टेड ओपन-वेट मॉडल हर endpoint पर, स्ट्रीम हो या न हो। effort off वाले अनुरोध का, या response_format / text.format वाले अनुरोध का उत्तर रीज़निंग टेक्स्ट के बिना आता है।
shannon-3, shannon-3-pro, shannon-3.1, shannon-3.1-pro हर endpoint पर, स्ट्रीम हो या न हो, जब भी मॉडल ने रीज़निंग टेक्स्ट बनाया।
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 परिवार और होस्टेड ओपन-वेट मॉडल के लिए 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

होस्टेड ओपन-वेट मॉडल का पहला चंक, रीज़निंग का हो या उत्तर का, delta.role: "assistant" भी रखता है। स्ट्रीमिंग

रीज़निंग टोकन और बिलिंग

होस्टेड ओपन-वेट मॉडल पर रीज़निंग टोकन आउटपुट टोकन हैं: वे मॉडल की आउटपुट कीमत पर बिल होते हैं, और आउटपुट गिनती में पहले से शामिल हैं। usage यहाँ रीज़निंग का हिस्सा दिखाता है:

Endpoint फ़ील्ड टिप्पणी
/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 रीज़निंग और उत्तर साथ में। इस फ़ॉर्मेट में अलग गिनती नहीं है।
  • होस्टेड ओपन-वेट मॉडल पर 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 होस्टेड ओपन-वेट मॉडल को सूची से बाहर का मान मिला, उदाहरण के लिए xhigh। आपके बैलेंस से कुछ नहीं लिया जाता।
422 invalid_request_error Failed to deserialize the JSON body into the target type: … reasoning_effort स्ट्रिंग नहीं है।

प्रमाणीकरण, बैलेंस और सर्वर एरर हर अनुरोध की तरह ही हैं। त्रुटि प्रबंधन