सामग्रीमा जानुहोस्
रिजनिङ एफर्ट

रिजनिङ एफर्ट

नयाँ

रिजनिङ गर्ने मोडलले आफ्नो रिजनिङ टेक्स्ट जवाफको छेउमा, आफ्नै फिल्डमा फर्काउँछ। होस्ट गरिएका ओपन-वेट मोडलहरूमा एउटा अनुरोध फिल्डले जवाफ दिनु अघि मोडलले कति गहिरो रिजनिङ गर्छ भनेर तोक्छ।

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}
  }
}

कुन मोडलले रिजनिङ गर्छ

मोडल रिजनिङ टेक्स्ट फर्काउँछ प्रयास फिल्ड लागू गर्छ
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 का लागि रिपोर्ट गर्छ। मोडलले रिजनिङ टेक्स्ट बनाएको बेला मात्र जवाफमा रिजनिङ टेक्स्ट हुन्छ। मोडल र मूल्य

प्रयास सेट गर्ने

हरेक इन्डपोइन्टमा प्रयास लेख्ने आफ्नै तरिका छ। ती सबैले उही चार स्तरमध्ये एउटा छान्छन्।

फिल्ड प्रकार पूर्वनिर्धारित विवरण लागू गर्ने
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
n 2,048 सम्म हुँदा {"type": "enabled", "budget_tokens": n} low
n 2,049 देखि 8,192 सम्म medium
ठूलो n, वा budget_tokens बिना enabled high
thinking फिल्ड छैन high

रिजनिङ टेक्स्ट कहाँ आइपुग्छ

रिजनिङ टेक्स्ट सधैं उत्तरबाट छुट्टै हुन्छ। हरेक ढाँचामा यसको आफ्नै ठाउँ छ:

इन्डपोइन्ट स्ट्रिम नगरिएको स्ट्रिम गरिएको
/v1/chat/completions choices[0].message.reasoning_content: स्ट्रिङ, वा मोडलले केही नबनाएमा null। delta.content भएका चङ्कहरू अघि, choices[0].delta.reasoning_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}
  }
}

कहाँ हेर्ने, प्रति मोडल:

मोडलहरू टेक्स्ट कहाँ आइपुग्छ
होस्ट गरिएका ओपन-वेट मोडलहरू हरेक इन्डपोइन्टमा, स्ट्रिम गरिएको वा नगरिएको। प्रयास 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 परिवार र होस्ट गरिएका ओपन-वेट मोडलहरूका लागि 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 ले रिजनिङको हिस्सा देखाउँछ:

इन्डपोइन्ट फिल्ड टिप्पणी
/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 ले उत्तरको टेक्स्ट सीमित गर्छ। रिजनिङ टोकन यसमा गनिँदैनन्।
  • रिजनिङ आउटपुटका रूपमा बिल हुने भएकाले प्रयास स्तर लागतको सेटिङ पनि हो: 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 स्ट्रिङ होइन।

प्रमाणीकरण, ब्यालेन्स र सर्भर त्रुटिहरू हरेक अनुरोधमा जस्तै हुन्छन्। त्रुटि व्यवस्थापन