思考功能(thinking)是豆包 doubao-seed 系列模型的特性参数,用于控制模型在给出最终答案前是否先进行深度思考(链式推理)。与其他厂商不同,豆包额外提供 auto 档位,可由模型根据问题难度自动决定是否思考。该功能适用于数学推导、逻辑分析、代码调试等需要多步推理的场景。
auto
思考开关thinking.type:
thinking.type
enabled
disabled
请求方法: POST
POST
Base URL: https://api.apexrouter.top/v1/chat/completions
https://api.apexrouter.top/v1/chat/completions
开启后,模型会先输出思考过程(链式推理),再给出最终答案。思考过程在响应的 reasoning_content 字段,最终回答在 content 字段。
reasoning_content
content
import json import requests # 配置 API 密钥 api_key = "sk-................................." # 替换为你的 知能API 令牌 url = "https://api.apexrouter.top/v1/chat/completions" # 设置请求头 headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" } # 构造请求数据 data = { "model": "doubao-seed-2-1-pro-260628", # 豆包 doubao-seed 系列思考模型(按 知能API 实际提供的名称填写) "messages": [ { "role": "user", "content": "从1加到10等于多少?" # 用户提问 } ], "thinking": {"type": "enabled"} # 开启思考功能:先输出思考过程再给答案,可选 enabled / disabled / auto } try: # 发送 API 请求 response = requests.post(url, headers=headers, json=data) response.raise_for_status() # 检查 HTTP 错误 # 处理响应结果 print("请求成功!") print(json.dumps(response.json(), indent=2, ensure_ascii=False)) except requests.exceptions.RequestException as e: # 异常处理 print(f"请求失败: {e}")
关闭后,模型跳过思考过程,直接给出最终答案。
import json import requests # 配置 API 密钥 api_key = "sk-............................." # 替换为你的 知能API 令牌 url = "https://api.apexrouter.top/v1/chat/completions" # 设置请求头 headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" } # 构造请求数据 data = { "model": "doubao-seed-2-1-pro-260628", # 豆包 doubao-seed 系列模型(按 知能API 实际提供的名称填写) "messages": [ { "role": "user", "content": "从1加到10等于多少?" # 用户提问 } ], "thinking": {"type": "disabled"} # 关闭思考功能:直接给出最终答案 } try: # 发送 API 请求 response = requests.post(url, headers=headers, json=data) response.raise_for_status() # 检查 HTTP 错误 # 处理响应结果 print("请求成功!") print(json.dumps(response.json(), indent=2, ensure_ascii=False)) except requests.exceptions.RequestException as e: # 异常处理 print(f"请求失败: {e}")
thinking
extra_body={"thinking": {"type": "enabled"}}
© 2026 知能API Doubao thinking