API verwenden
Reasoning
Unsere Modelle denken nach, bevor sie antworten. Sie können dieses Reasoning lesen und für jede Anfrage entscheiden, wie viel es Ihnen wert ist.
Aufwand wählen
Senden Sie reasoning_effort mit einer der Stufen, die das Modell akzeptiert. Mehr Aufwand bedeutet längeres, sorgfältigeres Reasoning und mehr Ausgabe-Token; weniger Aufwand eine schnellere, günstigere Antwort. Wenn Sie keinen Aufwand senden, nutzen alle Modelle high. Jede Stufe von OpenAI oder Anthropic funktioniert ebenfalls und wird auf die nächstgelegene Stufe des Modells abgebildet: minimal wird zu low, medium zu high und xhigh zu max. none (oder off) schaltet das Reasoning bei Modellen mit off ab; bei den anderen gilt die niedrigste Stufe.
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.libremodel.ai/v1", api_key=os.environ["LIBREMODEL_API_KEY"])
response = client.chat.completions.create(
model="deepseek-v4.1-flash-1017",
reasoning_effort="low", # low, high or max; "none" thinks as little as the model allows
messages=[{"role": "user", "content": "Is 1,234,567 divisible by 7?"}],
)
message = response.choices[0].message
print(getattr(message, "reasoning_content", None)) # how it got there
print(message.content) # the answerimport OpenAI from 'openai'
const client = new OpenAI({ baseURL: 'https://api.libremodel.ai/v1', apiKey: process.env.LIBREMODEL_API_KEY })
const response = await client.chat.completions.create({
model: 'deepseek-v4.1-flash-1017',
reasoning_effort: 'low',
messages: [{ role: 'user', content: 'Is 1,234,567 divisible by 7?' }],
})
const message = response.choices[0].message as typeof response.choices[0]['message'] & { reasoning_content?: string }
console.log(message.reasoning_content) // how it got there
console.log(message.content) // the answer| Modell | reasoning_effort |
|---|---|
kimi-k3.1-pro-uncensored | low · high · max |
deepseek-v4.1-flash-1017-uncensored | off · low · high · max |
glm-5.3-flash-uncensored | low · high · max |
kimi-k3.1-pro | low · high · max |
deepseek-v4.1-flash-1017 | off · low · high · max |
minimax-m3.1-flash | low · high · max |
Reasoning lesen
In Chat Completions kommt das Reasoning in choices[0].message.reasoning_content, neben der Antwort in content. Beim Streaming kommt es zuerst, in delta.reasoning_content. Siehe Streaming.
Reasoning zählt zu max_tokens
- Reasoning-Token sind Ausgabe-Token: Sie zählen zu
max_tokensund werden zum Ausgabepreis abgerechnet. - Ist das Limit erreicht, während das Modell noch nachdenkt, kommt die Antwort mit leerem
contentundfinish_reason: "length". Erhöhen Siemax_tokensoder senken Sie den Aufwand. - Lassen Sie bei
maxreichlich Spielraum: Eine schwierige Frage kann mehrere Tausend Reasoning-Token brauchen, bevor das erste Wort der Antwort kommt.
Mit Tool-Aufrufen
Wenn das Modell ein Tool aufruft, senden Sie seine Assistant-Nachricht unverändert zurück, reasoning_content eingeschlossen, und danach die Ergebnisse. So setzt das Modell sein eigenes Reasoning fort. Siehe Tool-Aufrufe.
Im Format von Anthropic
Auf /v1/messages aktivieren Sie thinking und senden output_config.effort (low, medium, high, xhigh oder max, auf die Stufen des Modells abgebildet). Mit aktiviertem thinking und ohne output_config.effort oder budget_tokens nutzt es high. Das Reasoning kommt in thinking-Blöcken zurück, vor dem text-Block. thinking mit type: "disabled" schaltet es bei Modellen mit off ab.
import os
from anthropic import Anthropic
client = Anthropic(base_url="https://api.libremodel.ai", api_key=os.environ["LIBREMODEL_API_KEY"])
message = client.messages.create(
model="deepseek-v4.1-flash-1017",
max_tokens=8192,
thinking={"type": "enabled", "budget_tokens": 4096},
messages=[{"role": "user", "content": "Is 1,234,567 divisible by 7?"}],
)
for block in message.content:
if block.type == "thinking":
print("thinking:", block.thinking)
elif block.type == "text":
print("answer:", block.text)| Format | Aufwand wählen mit | Reasoning kommt zurück in |
|---|---|---|
| Chat Completions | reasoning_effort | message.reasoning_content |
| Anthropic Messages | output_config.effort | thinking-Blöcken |
| Responses | reasoning.effort | Einem reasoning-Ausgabe-Item |
Es funktioniert in allen drei API-Formaten gleich. Siehe Anthropic- und Responses-API.