模型能力
Reasoning
主要功能
先思考再回答:Reasoning model 会在给出答案前逐步思考问题。
数学与定量能力:擅长数值挑战、逻辑谜题和复杂分析任务。
Reasoning Trace:Usage metrics 会提供
reasoning_tokens。部分模型还可以通过include: ["reasoning.encrypted_content"]返回 encrypted reasoning(见下文)。
Encrypted Reasoning Content
Reasoning content 由我们加密;向 Responses API 传递 include: ["reasoning.encrypted_content"] 时可以返回。你可以将 encrypted content 发送回来,为之前的对话提供更多 context。有关如何使用该内容的更多信息,请参阅添加 encrypted thinking content。
reasoning_effort 参数
grok-4.5 支持 reasoning_effort 参数,用于控制模型在回答前投入多少思考。
如果未指定,reasoning_effort 默认为 "high"。Reasoning 无法禁用。
presencePenalty、frequencyPenalty 和 stop 不能与 reasoning model 一起使用。包含这些参数的请求会返回错误。
Effort levels
| 设置 | 描述 | 最适合 |
|---|---|---|
"low" | 使用一定数量的 reasoning tokens,但仍然快速 | 对延迟敏感的 Agent 用例和简单 tool calling。 |
"medium" | 为对延迟不太敏感的应用提供更多思考 | 复杂数据分析和长上下文推理。 |
"high"(默认) | 使用更多 reasoning tokens 进行更深入的思考 | 极具挑战性的问题、复杂数学、多步骤逻辑和竞赛级任务 |
设置 reasoning effort
下面的示例为具有挑战性的数学证明将 reasoning_effort 设置为 "high"。也可以按需替换为 "low" 或 "medium"。
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.5",
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)Multi-agent model
对于 grok-4.20-multi-agent,reasoning.effort 参数控制一次请求中协作的 Agent 数量,而不是 reasoning depth。详情请参阅 Multi Agent文档。
汇总表
| 模型 | reasoning 参数 | 行为 |
|---|---|---|
grok-4.5 | reasoning.effort:"low" / "medium" / "high"(默认) | 控制 reasoning depth(无法禁用) |
grok-4.20-multi-agent | reasoning.effort:"low" / "medium" / "high" / "xhigh" | 控制 Agent 数量(4 或 16) |
Summarized Reasoning Content
对于 grok-4.5,我们会提供模型内部 reasoning 的摘要。下面的示例展示如何在 streaming 最终响应的同时接收 reasoning summary delta:
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.5",
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 model 时,reasoning tokens 会作为总用量的一部分计费。