Reasoning-Aufwand
NeuEin Modell, das nachdenkt, liefert seinen Reasoning-Text neben der Antwort in einem eigenen Feld. Bei den gehosteten Open-Weight-Modellen legt ein Anfragefeld fest, wie tief das Modell nachdenkt, bevor es antwortet.
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?"}
]
}' Die Antwort enthält den Reasoning-Text in reasoning_content, die Antwort in content und die Reasoning-Tokens in 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}
}
} Welche Modelle nachdenken
| Modell | Liefert Reasoning-Text | Wendet das Aufwandsfeld an |
|---|---|---|
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 | Ja | — |
| Jedes gehostete Open-Weight-Modell | Ja | Ja |
Dies sind die Flags capabilities.reasoning und capabilities.reasoning_effort, die GET /v1/models für jede ID meldet. Eine Antwort enthält nur dann Reasoning-Text, wenn das Modell welchen erzeugt hat. Modelle & Preise
Den Aufwand festlegen
Jeder Endpunkt hat seine eigene Schreibweise für den Aufwand. Alle wählen eine derselben vier Stufen.
| Feld | Typ | Standard | Beschreibung | Angewendet von |
|---|---|---|---|---|
reasoning_effort | string | high | /v1/chat/completions. Wie tief das Modell nachdenkt, bevor es antwortet: off, low, medium oder high. | Gehostete Open-Weight-Modelle |
reasoning | object | string | /v1/chat/completions. Derselbe Wert als {"effort": "low"} oder als bloßer String. Werden beide Felder gesendet, gilt reasoning_effort. | Gehostete Open-Weight-Modelle | |
reasoning.effort | string | high | /v1/responses. Geschrieben als Objekt {"effort": "low"}. | Gehostete Open-Weight-Modelle |
thinking | object | /v1/messages. {"type": "enabled", "budget_tokens": n} oder {"type": "disabled"}. Das Budget wählt eine der Stufen; siehe die Tabelle weiter unten. | Gehostete Open-Weight-Modelle |
{
"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?"}]
} | Wert | Ebenfalls akzeptiert | Wirkung |
|---|---|---|
off | none, minimal | Kein Reasoning. Die Antwort enthält keinen Reasoning-Text. |
low | Kurzes Reasoning. | |
medium | default | Mittlere Tiefe. |
high | max | Die tiefste Stufe. Dies ist die Stufe einer Anfrage, die keinen Wert sendet. |
- Werte werden ohne Rücksicht auf Groß- und Kleinschreibung gelesen.
- Der Wert
defaultbedeutetmedium. Wird das Feld weggelassen, bedeutet dashigh. - Die Shannon-Modelle (
shannon-*) legen ihre Tiefe bei jeder Anfrage selbst fest;GET /v1/modelsmeldet für siereasoning_effort: false.
Das Thinking-Budget bei /v1/messages
Bei /v1/messages wählt das Feld thinking die Stufe. budget_tokens wählt eine der obigen Stufen; es ist kein eigenes Token-Limit. adaptive wird wie enabled gelesen.
| Sie senden | Stufe |
|---|---|
{"type": "disabled"} | off |
{"type": "enabled", "budget_tokens": n} mit n bis zu 2,048 | low |
n von 2,049 bis 8,192 | medium |
Ein größeres n, oder enabled ohne budget_tokens | high |
Kein Feld thinking | high |
Wo der Reasoning-Text eintrifft
Reasoning-Text ist immer von der Antwort getrennt. Jedes Format hat dafür seinen eigenen Platz:
| Endpunkt | Nicht gestreamt | Gestreamt |
|---|---|---|
/v1/chat/completions | choices[0].message.reasoning_content: ein String oder null, wenn das Modell keines erzeugt hat. | Chunks mit choices[0].delta.reasoning_content, vor den Chunks mit delta.content. |
/v1/responses | Ein output-Element {"type": "reasoning", "summary": [{"type": "summary_text", "text": "…"}]} vor dem Element message. Kein Element, wenn es kein Reasoning gibt. | response.output_item.added mit einem Element reasoning, dann response.reasoning_summary_text.delta-Events und ein response.reasoning_summary_text.done. |
/v1/messages | Ein erster Content-Block {"type": "thinking", "thinking": "…"}, dann der text-Block. Kein thinking-Block, wenn es kein Reasoning gibt. | Ein thinking-Content-Block: content_block_start, content_block_delta-Events mit thinking_delta, content_block_stop. Der Text-Block folgt. |
{
"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
}
} Wo Sie nachsehen müssen, pro Modell:
| Modelle | Wo der Text eintrifft |
|---|---|
| Gehostete Open-Weight-Modelle | Bei jedem Endpunkt, gestreamt oder nicht. Eine Anfrage mit dem Aufwand off oder mit response_format / text.format wird ohne Reasoning-Text beantwortet. |
shannon-3, shannon-3-pro, shannon-3.1, shannon-3.1-pro | Bei jedem Endpunkt, gestreamt oder nicht, sofern das Modell Reasoning-Text erzeugt hat. |
shannon-2-lite, shannon-2-pro | /v1/chat/completions, nicht gestreamt: in message.reasoning_content. Gestreamt, bei einer Anfrage ohne tools oder response_format: Der Stream enthält Kommentarzeilen : thinking, während das Modell nachdenkt, dann die Antwort-Chunks. /v1/messages, gestreamt: ein thinking-Block vor dem Text-Block. |
shannon-1.6-pro, shannon-coder-1 | In gestreamten Antworten und in Antworten auf Anfragen, die tools enthalten, sofern das Modell Reasoning-Text erzeugt hat. |
Bei /v1/responses enthält eine nicht gestreamte Antwort das Element reasoning für die Shannon-3-Familie und die gehosteten Open-Weight-Modelle.
Einen Stream lesen
In einem Stream kommt der Reasoning-Text zuerst, in eigenen Deltas, und die Antwort folgt. Geben Sie die beiden getrennt aus oder speichern Sie sie getrennt:
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?"}
]
}' Der erste Chunk eines gehosteten Open-Weight-Modells, Reasoning oder Antwort, enthält außerdem delta.role: "assistant". Streaming
Reasoning-Tokens und Abrechnung
Bei den gehosteten Open-Weight-Modellen sind Reasoning-Tokens Output-Tokens: Sie werden zum Output-Preis des Modells berechnet, und die Output-Anzahl enthält sie bereits. usage zeigt hier den Reasoning-Anteil:
| Endpunkt | Feld | Hinweis |
|---|---|---|
/v1/chat/completions | usage.completion_tokens_details.reasoning_tokens | Bereits in completion_tokens enthalten. |
/v1/responses | usage.output_tokens_details.reasoning_tokens | Bereits in output_tokens enthalten. |
/v1/messages | usage.output_tokens | Reasoning und Antwort zusammen. Dieses Format hat keine getrennte Zählung. |
- Bei den gehosteten Open-Weight-Modellen begrenzt
max_tokensden Antworttext. Reasoning-Tokens werden darauf nicht angerechnet. - Da Reasoning als Output berechnet wird, ist die Aufwandsstufe auch eine Kosteneinstellung:
offerzeugt keine Reasoning-Tokens. - Die Shannon-Modelle melden
prompt_tokens,completion_tokensundtotal_tokens(input_tokensundoutput_tokensbei/v1/messages) ohne Reasoning-Anteil und berechnen einen Pauschalpreis pro Token. Modelle & Preise
Reasoning in der nächsten Anfrage
Sie müssen Reasoning nicht zurücksenden. Ein thinking-Block oder ein Element reasoning in der Konversation, die Sie senden, wird nicht an das Modell weitergegeben, sodass ein Assistant-Turn mit oder ohne zurückgehen kann. Ein thinking-Block hat die beiden Felder type und thinking; er hat keine signature.
Fehler
| Status | Typ | Nachricht | Wann |
|---|---|---|---|
400 | invalid_request_error | unknown reasoning effort '<value>'; expected off, low, medium or high | Ein gehostetes Open-Weight-Modell hat einen Wert außerhalb der Liste erhalten, zum Beispiel xhigh. Von Ihrem Guthaben wird nichts abgebucht. |
422 | invalid_request_error | Failed to deserialize the JSON body into the target type: … | reasoning_effort ist kein String. |
Authentifizierungs-, Guthaben- und Serverfehler sind dieselben wie bei jeder Anfrage. Fehlerbehandlung