模型能力
推理
主要功能
先思考再回答:推理模型会在给出答案前逐步思考问题。
数学与定量能力:擅长数值挑战、逻辑谜题和复杂分析任务。
推理轨迹:用量指标会提供
reasoning_tokens。部分模型还可以通过include: ["reasoning.encrypted_content"]返回加密推理内容(见下文)。
加密推理内容
推理内容由我们加密;向 Responses API 传递 include: ["reasoning.encrypted_content"] 时可以返回。你可以将加密内容发送回来,为之前的对话提供更多 context。有关如何使用该内容的更多信息,请参阅添加加密推理内容。
reasoning_effort 参数
grok-4.7、grok-4.6 和 grok-4.5 支持 reasoning_effort 参数,用于控制模型在回答前投入多少思考。
如果未指定,reasoning_effort 默认为 "high"。推理无法禁用。
presencePenalty、frequencyPenalty 和 stop 不能与推理模型一起使用。包含这些参数的请求会返回错误。
推理强度
| 设置 | 描述 | 最适合 |
|---|---|---|
"low" | 使用一定数量的 reasoning tokens,但仍然快速 | 对延迟敏感的 Agent 用例和简单 tool calling。 |
"medium" | 为对延迟不太敏感的应用提供更多思考 | 复杂数据分析和长上下文推理。 |
"high"(默认) | 使用更多 reasoning tokens 进行更深入的思考 | 极具挑战性的问题、复杂数学、多步骤逻辑和竞赛级任务 |
"xhigh" | 最大推理深度,延迟也会相应提高 | 最困难的问题,即答案质量比响应时间更重要的场景 |
设置推理强度
下面的示例为具有挑战性的数学证明将 reasoning_effort 设置为 "high"。也可以按需替换为 "low"、"medium",或在支持的模型上替换为 "xhigh"。
import os
from xai_sdk import Client
from xai_sdk.chat import system, user
client = Client(
api_key=os.getenv("XAI_API_KEY"),
timeout=3600,
)
chat = client.chat.create(
model="grok-4.7",
reasoning_effort="high",
messages=[system("You are a highly intelligent AI assistant.")],
)
chat.append(user("Find all prime numbers p such that p^2 + 2 is also prime. Prove your answer."))
response = chat.sample()
print("Final Response:")
print(response.content)多 Agent 模型
对于 grok-4.20-multi-agent,reasoning.effort 参数控制一次请求中协作的 Agent 数量,而不是推理深度。详情请参阅 Multi Agent文档。
汇总表
| 模型 | reasoning 参数 | 行为 |
|---|---|---|
grok-4.7 | reasoning.effort:"low" / "medium" / "high"(默认) / "xhigh" | 控制推理深度(无法禁用) |
grok-4.6 | reasoning.effort:"low" / "medium" / "high"(默认) / "xhigh" | 控制推理深度(无法禁用) |
grok-4.5 | reasoning.effort:"low" / "medium" / "high"(默认) | 控制推理深度(无法禁用) |
grok-4.20-multi-agent | reasoning.effort:"low" / "medium" / "high" / "xhigh" | 控制 Agent 数量(4 或 16) |
推理内容摘要
对于 grok-4.7,我们会提供模型内部推理的摘要。下面的示例展示如何在流式传输最终响应的同时接收推理摘要增量:
import os
from xai_sdk import Client
from xai_sdk.chat import system, user
client = Client(
api_key=os.getenv("XAI_API_KEY"),
timeout=3600, # Override default timeout with longer timeout for reasoning models
)
chat = client.chat.create(
model="grok-4.7",
messages=[system("You are a highly intelligent AI assistant.")],
)
chat.append(user("A projectile is launched at 30 m/s at 37° above horizontal from a 45 m cliff. Find its speed on impact. (g=10 m/s²)"))
content_started = False
print("\n\n--------- Reasoning ---------", flush=True)
latest_response = None
for response, chunk in chat.stream():
if chunk.reasoning_content:
print(chunk.reasoning_content, end="", flush=True)示例输出
--------- Reasoning ---------
The problem is: A projectile is launched at 30 m/s at 37° above horizontal from a 45 m cliff. Find its speed on impact. (g=10 m/s²)
I need to find the speed when the projectile hits the ground. It's launched at 30 m/s at 37° from a 45 m cliff, with g=10 m/s².
Conservation of energy is a good approach. The initial kinetic energy is (1/2)mv² with v=30 m/s, and initial potential energy is mgh with h=45 m, taking ground as zero.
At impact, potential energy is zero, so initial KE + initial PE = final KE.
Thus, (1/2)m(30)² + mg(45) = (1/2)m v_f²
v_f² = 900 + 2*10*45 = 900 + 900 = 1800
v_f = sqrt(1800) = 30√2 m/s ≈ 42.4 m/s
The angle doesn't affect the final speed because the initial kinetic energy and potential energy change are the same regardless of direction, as long as the speed and height are the same.
Yes, that makes sense. The final speed is sqrt(v0² + 2gh), independent of the launch angle.使用推理模型时,reasoning tokens 会作为总用量的一部分计费。
最后更新:2026 年 9 月 21 日