主题
强制思考(Extended Thinking)
让模型显式输出推理过程再给最终答案。难题正确率显著提升。
一句话
普通模式 = "蹭蹭跑出答案";思考模式 = "想清楚再答"。 难题/数学/算法/调试用思考模式,简单任务用普通模式。
Claude 思考模式
POST https://shuro.vip/v1/messages请求示例
json
{
"model": "claude-sonnet-4-6",
"max_tokens": 16000,
"thinking": {
"type": "enabled",
"budget_tokens": 10000
},
"messages": [
{
"role": "user",
"content": "请解决这道数学题:x² + 5x + 6 = 0 的解?详细展示思考过程"
}
]
}关键字段
| 字段 | 类型 | 说明 |
|---|---|---|
model | string | 普通模型 ID(如 claude-sonnet-4-6) |
thinking.type | string | "enabled" 启用思考 |
thinking.budget_tokens | integer | 思考可用 token 预算(≤ max_tokens) |
max_tokens | integer | 总 token 上限(必须 > budget_tokens) |
开启方式
Shuro 没有 -thinking 后缀的别名模型。所有 Claude 模型都用普通模型 ID + 请求体 thinking 参数开启思考,budget_tokens 自己控制。
Headers
Content-Type: application/json
anthropic-version: 2023-06-01
x-api-key: <您的 API Key>响应结构
json
{
"content": [
{
"type": "thinking",
"thinking": "我需要解二次方程 x² + 5x + 6 = 0\n用因式分解:\n(x+2)(x+3) = 0\nx = -2 或 x = -3"
},
{
"type": "text",
"text": "解为 x = -2 或 x = -3"
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 30,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"output_tokens": 145,
"output_tokens_details": {
"thinking_tokens": 87 ← 思考部分消耗的 token(在 output_tokens_details 里)
}
}
}content 数组里有两块:
type: "thinking"—— 模型的思考过程(可以选择给用户看 / 不给看)type: "text"—— 最终回答
OpenAI / GPT-5 系列思考
GPT-5.4 / GPT-5.5 默认就带思考,通过 reasoning_effort 控制深度:
json
{
"model": "gpt-5.5",
"messages": [...],
"reasoning_effort": "high"
}reasoning_effort 取值
| 值 | 思考预算 | 适用 |
|---|---|---|
"minimal" | 极少 | 简单分类 |
"low" | 少 | 日常对话 |
"medium" | 中(默认) | 一般问题 |
"high" | 多 | 难题、debug、设计 |
响应
json
{
"choices": [{
"message": {
"role": "assistant",
"content": "答案:..."
}
}],
"usage": {
"prompt_tokens": 50,
"completion_tokens": 200,
"total_tokens": 250,
"completion_tokens_details": {
"reasoning_tokens": 150 ← 其中思考用了多少
}
}
}待验证(TODO/VERIFY):思考过程是否回传
以下内容基于旧平台实测(2026-06),尚未在 Shuro 复测,仅供参考。
旧平台上 GPT-5 系经中转不返回 reasoning_content 字段——思考在上游进行,只能从 usage.completion_tokens_details.reasoning_tokens 看到消耗量;reasoning_effort 参数本身正常生效。
何时该启用思考
✅ 适合思考
- 数学题(特别是多步推理)
- 算法/数据结构问题
- 代码 debug(定位深层 bug)
- 复杂决策(多目标权衡)
- 长文档总结(需要梳理)
- 写作大纲设计
❌ 不适合
- 翻译(直接给答案就行)
- 简单 CRUD 代码
- 改 typo
- 格式转换
- 摘要短文本
成本与性能
思考会显著增加 token 消耗:
| 模式 | Token 消耗 | 响应时间 | 质量 |
|---|---|---|---|
| 不思考 | 1× | 1× | 基线 |
| Claude thinking | 2-5× | 3-10× | +10-30% |
| GPT-5 high | 3-8× | 5-15× | +15-40% |
简单任务用了思考 = 烧钱白瞎。复杂任务不用思考 = 答案质量低。
实战示例(Python)
Claude
python
import anthropic
client = anthropic.Anthropic(
api_key="<您的 API Key>",
base_url="https://shuro.vip"
)
resp = client.messages.create(
model="claude-opus-4-8", # 普通 ID + thinking 参数即可
max_tokens=8192,
thinking={
"type": "enabled",
"budget_tokens": 4096
},
messages=[
{"role": "user", "content": "证明费马小定理"}
]
)
# 分离思考和最终答案
for block in resp.content:
if block.type == "thinking":
print("=== 思考过程 ===")
print(block.thinking)
elif block.type == "text":
print("=== 最终答案 ===")
print(block.text)OpenAI
python
from openai import OpenAI
client = OpenAI(api_key="<key>", base_url="https://shuro.vip/v1")
resp = client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": "证明费马小定理"}],
reasoning_effort="high"
)
msg = resp.choices[0].message
print("思考:", msg.reasoning_content)
print("答案:", msg.content)跟 Claude Code / Cursor 的集成
Claude Code 自动开启 thinking
主动让 Claude Code 思考:
/think
请重构 auth.ts 模块,先想清楚架构或在 CLAUDE.md:
markdown
## 工作约定
- 重大架构决策必须先 thinking 再写代码Cursor
Cursor 侧启用思路:
- 默认模型选
claude-opus-4-6(或claude-sonnet-4-6),思考由客户端通过thinking请求参数开启 - 或 Composer 内手动
/think
调试用户的思考
把模型思考给用户看 vs 隐藏:
python
# 给用户看(方便理解过程)
return f"思考:{thinking}\n\n答案:{answer}"
# 不给用户看(更简洁)
return answer内部用 thinking + 外部只返结果
python
# 提示词:"请深度思考但不要给我看思考过程,只给最终答案"
# 配 reasoning_effort=high 内部思考
# 输出只取 message.content(不取 reasoning_content)最佳实践:让模型脑子里转一圈,但只给用户看精炼后的答案。
跟 Superpowers 等框架配合
Superpowers 框架强制 spec-driven,自动在 spec 阶段调用 thinking 模式。你不用手动开启。
