તર્ક પ્રયત્ન
reasoning કરતું મોડેલ તેનો reasoning ટેક્સ્ટ જવાબની બાજુમાં, પોતાના ફીલ્ડમાં પાછો આપે છે. હોસ્ટેડ open-weight મોડેલ્સ પર એક રિક્વેસ્ટ ફીલ્ડ નક્કી કરે છે કે જવાબ આપતા પહેલાં મોડેલ કેટલું ઊંડું reasoning કરે.
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-uncensored-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-uncensored-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-uncensored-3BIT-REAP",
"reasoning_effort": "low",
"messages": [
{"role": "user", "content": "Is 221 a prime number?"}
]
}' જવાબ reasoning ટેક્સ્ટ reasoning_content માં, જવાબ content માં, અને reasoning ટોકન્સ usage માં લઈ જાય છે:
{
"id": "chatcmpl-2a6c8e0b4d1f4a3c9e7b5d3f1a8c6e4b",
"object": "chat.completion",
"created": 1791590400,
"model": "Kimi-K3-uncensored-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}
}
} કયા મોડેલ્સ reasoning કરે છે
| મોડેલ | reasoning ટેક્સ્ટ આપે છે | 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 મોડેલ | હા | હા |
આ તે ફ્લેગ્સ capabilities.reasoning અને capabilities.reasoning_effort છે જે GET /v1/models દરેક id માટે જણાવે છે. જવાબ reasoning ટેક્સ્ટ ત્યારે જ લઈ જાય છે જ્યારે મોડેલે કંઈ બનાવ્યું હોય. મોડેલ્સ અને કિંમત
effort સેટ કરવું
દરેક એન્ડપોઇન્ટનું effort લખવાનું પોતાનું રૂપ છે. બધા એ જ ચાર સ્તરોમાંથી એક પસંદ કરે છે.
| ફીલ્ડ | પ્રકાર | ડિફોલ્ટ | વર્ણન | કોણ લાગુ કરે છે |
|---|---|---|---|---|
reasoning_effort | string | high | /v1/chat/completions. જવાબ આપતા પહેલાં મોડેલ કેટલું ઊંડું reasoning કરે: 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-uncensored-3BIT-REAP",
"reasoning_effort": "low",
"messages": [{"role": "user", "content": "Is 221 a prime number?"}]
} {
"model": "Kimi-K3-uncensored-3BIT-REAP",
"reasoning": {"effort": "low"},
"input": "Is 221 a prime number?"
} {
"model": "Kimi-K3-uncensored-3BIT-REAP",
"max_tokens": 1024,
"thinking": {"type": "enabled", "budget_tokens": 2048},
"messages": [{"role": "user", "content": "Is 221 a prime number?"}]
} | મૂલ્ય | આ પણ સ્વીકારાય છે | અસર |
|---|---|---|
off | none, minimal | કોઈ reasoning નહીં. જવાબ કોઈ reasoning ટેક્સ્ટ લઈ જતો નથી. |
low | ટૂંકું reasoning. | |
medium | default | મધ્યમ ઊંડાઈ. |
high | xhigh, 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 |
reasoning ટેક્સ્ટ ક્યાં આવે છે
reasoning ટેક્સ્ટ હંમેશા જવાબથી અલગ હોય છે. દરેક ફોર્મેટમાં તેની પોતાની જગ્યા છે:
| એન્ડપોઇન્ટ | સ્ટ્રીમ વિના | સ્ટ્રીમ સાથે |
|---|---|---|
/v1/chat/completions | choices[0].message.reasoning_content: સ્ટ્રિંગ, અથવા મોડેલે કંઈ ન બનાવ્યું હોય ત્યારે null. | delta.content વાળા chunks પહેલાં choices[0].delta.reasoning_content વાળા chunks. |
/v1/responses | message આઇટમ પહેલાં output આઇટમ {"type": "reasoning", "summary": [{"type": "summary_text", "text": "…"}]}. reasoning ન હોય ત્યારે કોઈ આઇટમ નથી. | reasoning આઇટમ સાથે response.output_item.added, પછી response.reasoning_summary_text.delta ઇવેન્ટ્સ અને એક response.reasoning_summary_text.done. |
/v1/messages | પહેલો કન્ટેન્ટ બ્લોક {"type": "thinking", "thinking": "…"}, પછી text બ્લોક. reasoning ન હોય ત્યારે 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 વાળી રિક્વેસ્ટનો જવાબ reasoning ટેક્સ્ટ વિના અપાય છે, અને બીજા કેટલાક જવાબો પણ તેના વિના આવે છે: reasoning ને હંમેશાં વૈકલ્પિક ગણો. |
Shannon મોડેલ્સ (shannon-1.6-*, shannon-2-*, shannon-3*, shannon-coder-1) | ક્યાંય નહીં. મોડેલ જવાબ આપતા પહેલાં reasoning કરે છે, પણ કોઈ પણ એન્ડપોઇન્ટ પર જવાબમાં reasoning ટેક્સ્ટ હોતું નથી, અને reasoning ન તો usage માં ગણાય છે, ન તેનું બિલ થાય છે. મોડેલ reasoning કરે ત્યારે સ્ટ્રીમમાં કોમેન્ટ લાઇન્સ આવી શકે છે. |
/v1/responses પર, સ્ટ્રીમ ન થતો જવાબ Shannon 3 ફેમિલી અને હોસ્ટેડ open-weight મોડેલ્સ માટે reasoning આઇટમ લઈ જાય છે.
સ્ટ્રીમ વાંચવો
સ્ટ્રીમમાં reasoning ટેક્સ્ટ પહેલા આવે છે, પોતાના deltas માં, અને જવાબ પછી આવે છે. બંનેને અલગ છાપો કે સંગ્રહો:
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-uncensored-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-uncensored-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-uncensored-3BIT-REAP",
"reasoning_effort": "medium",
"stream": true,
"messages": [
{"role": "user", "content": "Is 221 a prime number?"}
]
}' હોસ્ટેડ open-weight મોડેલનો પહેલો chunk, reasoning હોય કે જવાબ, delta.role: "assistant" પણ લઈ જાય છે. સ્ટ્રીમિંગ
reasoning ટોકન્સ અને બિલિંગ
હોસ્ટેડ open-weight મોડેલ્સ પર, reasoning ટોકન્સ આઉટપુટ ટોકન્સ છે: તેમનું બિલ મોડેલની આઉટપુટ કિંમતે થાય છે, અને આઉટપુટ ગણતરીમાં તે પહેલેથી શામેલ છે. usage અહીં reasoning હિસ્સો બતાવે છે:
| એન્ડપોઇન્ટ | ફીલ્ડ | નોંધ |
|---|---|---|
/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 | reasoning અને જવાબ સાથે મળીને. આ ફોર્મેટમાં અલગ ગણતરી નથી. |
- હોસ્ટેડ open-weight મોડેલ્સ પર
max_tokensજવાબના ટેક્સ્ટને મર્યાદિત કરે છે. reasoning ટોકન્સ તેમાં ગણાતા નથી. - reasoning નું બિલ આઉટપુટ તરીકે થતું હોવાથી, effort સ્તર ખર્ચનું સેટિંગ પણ છે:
offકોઈ reasoning ટોકન્સ બનાવતું નથી. - Shannon મોડેલ્સ reasoning હિસ્સા વિના
prompt_tokens,completion_tokensઅનેtotal_tokens(/v1/messagesપરinput_tokensઅનેoutput_tokens) જણાવે છે, અને ટોકન દીઠ એક નિશ્ચિત કિંમતે બિલ કરે છે. મોડેલ્સ અને કિંમત
આગલી રિક્વેસ્ટમાં reasoning
તમારે reasoning પાછું મોકલવાની જરૂર નથી. તમે મોકલેલી વાતચીતમાંનો thinking બ્લોક અથવા reasoning આઇટમ મોડેલને આપવામાં આવતો નથી, તેથી assistant ટર્ન તેની સાથે કે વિના પાછો જઈ શકે. thinking બ્લોકમાં type અને thinking બે ફીલ્ડ હોય છે; તેમાં signature નથી.
એરર્સ
રીઝનિંગ મૂલ્ય ક્યારેય વિનંતીને નિષ્ફળ કરતું નથી. none, minimal, low, medium, high, xhigh અને max બધા સ્વીકારાય છે, દરેક મોડલ અને દરેક endpoint પર; યાદી બહારનું મૂલ્ય, અથવા જે સ્ટ્રિંગ નથી તે, અવગણવામાં આવે છે અને ડિફોલ્ટ સ્તર વપરાય છે.
પ્રમાણીકરણ, બેલેન્સ અને સર્વર એરર્સ દરેક રિક્વેસ્ટ જેવી જ છે. ભૂલ સંભાળ
