Reasoning Models
Work with thinking/reasoning models — discover how each exposes reasoning and control it.
Overview
Reasoning (or "thinking") models produce an internal reasoning process before their final answer. Yunxin supports them natively across providers, normalizing how reasoning is requested and returned so the same client code works regardless of the upstream model.
How a model exposes and controls reasoning is model-dependent. The authoritative signal is the
reasoning_type field on each model from GET /v1/models — do not assume a single
universal toggle.
Discovering reasoning support
Each model record reports a reasoning_type describing the control surface it offers:
reasoning_type | Meaning |
|---|---|
none | The model does not expose configurable reasoning. |
thinking_budget | Reasoning is controlled by a token budget (e.g. Anthropic-style budget_tokens). |
reasoning_effort_* | Reasoning is controlled by an effort level (e.g. low / medium / high). |
thinking_toggle | Reasoning is turned on or off without a fine-grained budget. |
List reasoning-capable models and inspect their control type:
curl "https://api.yuhuanstudio.com/v1/models?capability=thinking" \
-H "Authorization: Bearer $YUNXIN_API_KEY"Reading reasoning output
For OpenAI-style Chat Completions, exposed reasoning arrives as reasoning_content on the assistant
message (and as reasoning_content deltas when streaming). Some models keep reasoning internal and
return only the final content.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["YUNXIN_API_KEY"],
base_url="https://api.yuhuanstudio.com/v1",
)
response = client.chat.completions.create(
model="model-id",
messages=[{"role": "user", "content": "Prove that the square root of 2 is irrational."}],
)
message = response.choices[0].message
reasoning = getattr(message, "reasoning_content", None)
if reasoning:
print("Thinking:\n", reasoning)
print("Answer:\n", message.content)Controlling reasoning
Use the control surface that matches the model's reasoning_type.
Effort level
Models with a reasoning_effort_* type accept a reasoning_effort value:
response = client.chat.completions.create(
model="model-id",
messages=[{"role": "user", "content": "Analyze the traveling salesman problem."}],
reasoning_effort="high",
)Thinking budget (Anthropic Messages)
Models exposing a token budget use the Anthropic Messages thinking field:
import os
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ["YUNXIN_API_KEY"],
# The Anthropic SDK appends /v1/messages itself — host only, no /v1.
base_url="https://api.yuhuanstudio.com",
)
message = client.messages.create(
model="model-id",
max_tokens=4096,
thinking={"type": "enabled", "budget_tokens": 10000},
messages=[{"role": "user", "content": "Analyze the traveling salesman problem."}],
)
for block in message.content:
if block.type == "thinking":
print("Thinking:\n", block.thinking)
elif block.type == "text":
print("Answer:\n", block.text)Some reasoning models constrain other parameters (for example they may ignore temperature/top_p, or
require reasoning budgets within a range). Yunxin adapts requests per model where possible; check the
model record for specifics.
Streaming reasoning
When streaming Chat Completions, reasoning tokens arrive as reasoning_content deltas, typically before
the final answer deltas:
stream = client.chat.completions.create(
model="model-id",
messages=[{"role": "user", "content": "What is 99 * 97?"}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta
reasoning = getattr(delta, "reasoning_content", None)
if reasoning:
print(reasoning, end="")
if delta.content:
print(delta.content, end="")With Anthropic Messages, streamed reasoning appears as thinking-type content block deltas in the SSE
event sequence (content_block_delta). See Streaming for the wire format.
How is this guide?