# GPT 推理设置:reasoning_effort、推理摘要与 verbosity Source: https://ofox.io/zh/docs/develop/models/gpt/reasoning 本页说明 GPT 系列的推理强度、推理摘要与回答长度控制;模型 ID 与接口配置见 [GPT 系列概览](https://ofox.io/zh/docs/develop/models/gpt)。 **要点**:推理消耗的 token 计入输出上限。开启推理时请预留足够的 max_completion_tokens,否则回答可能为空。 GPT-5 及之后的模型支持推理:先进行内部推理,再给出回答,适合数学、代码与多步骤分析。 | 项目 | Chat Completions | Responses | |---|---|---| | 推理强度 | `"reasoning_effort": "high"` | `"reasoning": {"effort": "high"}` | | 推理 token 数 | `usage.completion_tokens_details.reasoning_tokens` | `usage.output_tokens_details.reasoning_tokens` | | 推理内容 | 不返回 | 推理摘要,见下文 | - 常用取值为 `low`、`medium`、`high`,强度越高,推理 token 越多、耗时越长。传入模型不支持的值时返回 400,报错信息会列出该模型支持的取值。 - 未传入 `reasoning_effort` 时,各模型的默认行为不同:例如 GPT-5.4、GPT-6 Sol 默认不推理,GPT-5 默认推理。需要推理时请显式传入。 - 推理 token 按输出单价计费,并计入 `max_completion_tokens`(Responses 为 `max_output_tokens`)。 ## 推理摘要 Responses 接口可返回推理过程的摘要,Chat Completions 不返回推理内容: ```python filename="gpt_reasoning_summary.py" import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"]) resp = client.responses.create( model="openai/gpt-5.4", reasoning={"effort": "medium", "summary": "auto"}, max_output_tokens=20000, input="找出所有小于 50 的正整数 n,使 n² + n + 41 不是质数,并简要说明理由。", ) for item in resp.output: if item.type == "reasoning": for s in item.summary: print("[推理摘要]", s.text) print("[回答]", resp.output_text) ``` `output` 中可能包含多个 `reasoning` 条目,其中部分条目的 `summary` 为空数组,读取时请逐项判断。推理较少时可能没有摘要。 ## 控制回答长度 GPT-5 系列模型在 Chat Completions 中支持 `verbosity`,取值为 `low`、`medium`、`high`,用于控制回答的详略程度。它与 `max_completion_tokens` 不同,不会截断回答。 其他报错见[常见报错](https://ofox.io/zh/docs/develop/models/gpt#errors)。