ระดับความพยายามในการให้เหตุผล
ใหม่โมเดลที่ให้เหตุผลจะส่งข้อความการให้เหตุผลมาพร้อมกับคำตอบ ในฟิลด์ของตัวเอง บนโมเดล 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 และ tokens ของการให้เหตุผลใน 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 ที่โฮสต์ | ใช่ | ใช่ |
นี่คือแฟล็ก capabilities.reasoning และ capabilities.reasoning_effort ที่ GET /v1/models รายงานสำหรับแต่ละ id คำตอบมีข้อความการให้เหตุผลเฉพาะเมื่อโมเดลสร้างขึ้นมา โมเดลและราคา
การตั้งค่า effort
แต่ละ endpoint สะกด 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"} งบ (budget) เลือกหนึ่งในระดับต่างๆ ดูตารางด้านล่าง | โมเดล 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สำหรับโมเดลเหล่านี้
งบการคิด (thinking budget) ที่ใช้กำหนดความลึกของการให้เหตุผลบน /v1/messages
บน /v1/messages ฟิลด์ thinking เลือกระดับ budget_tokens เลือกหนึ่งในระดับข้างต้น ไม่ใช่ขีดจำกัด tokens ของตัวเอง adaptive ถูกอ่านเหมือน enabled
| สิ่งที่คุณส่ง | ระดับ |
|---|---|
{"type": "disabled"} | off |
{"type": "enabled", "budget_tokens": n} โดย n ไม่เกิน 2,048 | low |
n ตั้งแต่ 2,049 ถึง 8,192 | medium |
n ที่มากกว่านั้น หรือ enabled โดยไม่มี budget_tokens | high |
ไม่มีฟิลด์ thinking | high |
ข้อความการให้เหตุผลมาถึงที่ใด
ข้อความการให้เหตุผลแยกจากคำตอบเสมอ แต่ละรูปแบบมีที่วางของตัวเอง:
| เอนด์พอยต์ | ไม่สตรีม | สตรีม |
|---|---|---|
/v1/chat/completions | choices[0].message.reasoning_content: สตริง หรือ null เมื่อโมเดลไม่ได้สร้างข้อความ | chunk ที่มี choices[0].delta.reasoning_content ก่อน chunk ที่มี delta.content |
/v1/responses | รายการ output ชื่อ {"type": "reasoning", "summary": [{"type": "summary_text", "text": "…"}]} ก่อนรายการ message ไม่มีรายการนี้เมื่อไม่มีการให้เหตุผล | response.output_item.added พร้อมรายการ reasoning แล้วตามด้วย event response.reasoning_summary_text.delta และ response.reasoning_summary_text.done หนึ่งรายการ |
/v1/messages | content block แรก {"type": "thinking", "thinking": "…"} แล้วตามด้วยบล็อก text ไม่มีบล็อก thinking เมื่อไม่มีการให้เหตุผล | content block thinking: content_block_start, event content_block_delta ที่มี thinking_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 ที่โฮสต์ | บนทุก 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 ขณะที่โมเดลให้เหตุผล แล้วจึงส่ง chunk ของคำตอบ /v1/messages แบบสตรีม: บล็อก thinking ก่อนบล็อกข้อความ |
shannon-1.6-pro, shannon-coder-1 | ในคำตอบแบบสตรีมและในคำตอบของคำขอที่มี tools เมื่อใดก็ตามที่โมเดลสร้างข้อความการให้เหตุผล |
บน /v1/responses คำตอบที่ไม่ใช่สตรีมจะมีรายการ reasoning สำหรับตระกูล Shannon 3 และโมเดล open-weight ที่โฮสต์
การอ่านสตรีม
ในสตรีม ข้อความการให้เหตุผลมาก่อน ใน delta ของตัวเอง แล้วคำตอบตามมา ให้พิมพ์หรือเก็บสองส่วนแยกกัน:
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?"}
]
}' chunk แรกของโมเดล open-weight ที่โฮสต์ ไม่ว่าเป็นการให้เหตุผลหรือคำตอบ จะมี delta.role: "assistant" ด้วย สตรีมมิง
Tokens ของการให้เหตุผลและการเรียกเก็บเงิน
บนโมเดล open-weight ที่โฮสต์ tokens ของการให้เหตุผลคือ output tokens: คิดเงินตามราคาเอาต์พุตของโมเดล และจำนวนเอาต์พุตรวมไว้แล้ว 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จำกัดข้อความคำตอบ tokens ของการให้เหตุผลไม่นับรวม - เนื่องจากการให้เหตุผลถูกคิดเงินเป็นเอาต์พุต ระดับ effort จึงเป็นตัวตั้งค่าค่าใช้จ่ายด้วย:
offไม่สร้าง tokens ของการให้เหตุผล - โมเดล Shannon รายงาน
prompt_tokens,completion_tokensและtotal_tokens(input_tokensและoutput_tokensบน/v1/messages) โดยไม่มีสัดส่วนการให้เหตุผล และคิดเงินในราคาเดียวต่อ token โมเดลและราคา
การให้เหตุผลในคำขอถัดไป
คุณไม่ต้องส่งการให้เหตุผลกลับ บล็อก thinking หรือรายการ reasoning ในบทสนทนาที่คุณส่งจะไม่ถูกส่งต่อให้โมเดล ดังนั้นรอบของ assistant จะส่งกลับโดยมีหรือไม่มีก็ได้ บล็อก 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 ไม่ใช่สตริง |
ข้อผิดพลาดด้านการยืนยันตัวตน ยอดคงเหลือ และเซิร์ฟเวอร์ เหมือนกับคำขอทุกประเภท การจัดการข้อผิดพลาด