GPT-5 新参数与工具:开发者控制功能详解
技术背景
随着大语言模型在工程实践中的广泛应用,开发者对模型输出的控制需求日益增长。传统上,开发者通过精心设计提示词来影响输出长度和风格,但这种方法既不稳定又难以维护。同时,结构化函数调用虽然提供了接口,但强制 JSON 包装增加了不必要的复杂性。此外,对于需要严格格式输出的场景(如生成特定方言的 SQL),缺乏有效的约束机制。GPT-5 引入的冗长参数、自由格式函数调用、CFG 和最小推理模式,正是为了解决这些痛点,让开发者能够更精细地控制模型行为,提高输出质量和系统性能。
核心原理
冗长参数通过调整解码过程中的采样策略,控制生成文本的详细程度,而不改变底层提示词。自由格式函数调用允许模型直接输出原始文本负载,绕过 JSON 序列化,适用于代码、SQL 等自然文本格式。上下文无关文法(CFG)基于形式语言理论,通过定义产生式规则约束模型输出,确保生成的字符串符合预定义语法。最小推理模式通过减少推理令牌的生成,显著降低延迟,适用于简单确定性任务。这些功能共同提升了模型的可控性和工程适用性。
架构分析
这些功能在 API 层面通过新增参数和工具类型实现。冗长参数通过 text.verbosity 传入,影响输出长度。自由格式函数调用通过 tools 中的 type: "custom" 定义,模型生成原始文本作为工具输入。CFG 通过 format 字段指定语法定义,底层使用 LLGuidance 约束采样。最小推理通过 reasoning.effort 设置为 minimal。这些功能均支持 Responses API 和 Chat Completions API,但推荐使用 Responses API 以获得最佳性能。
完整实战教程
我们正在 GPT-5 系列中引入新的开发者控制功能,让您能够更好地控制模型响应——从调整输出长度和风格到强制严格格式。以下是最新功能的快速概览:
| # | 功能 | 概述 | 值/用法 |
|----|------|------|---------|
| 1. | Verbosity 参数 | 让您可以提示模型在回复中更详细或更简洁。保持提示词稳定,使用该参数而不是重写提示词。 | • low → 简洁的用户体验,最少文字。<br>• medium *(默认)* → 平衡的细节。<br>• high → 详细,适合审计、教学或交接。 |
| 2. | 自由格式函数调用 | 直接生成原始文本负载——从 Python 脚本到 SQL 查询——无需 JSON 包装即可发送到您的自定义工具。为外部运行时提供更大的灵活性,例如:<br>• 代码沙箱(Python、C++、Java 等)<br>• SQL 数据库<br>• Shell 环境<br>• 配置生成器 | 当结构化 JSON 不是必需且原始文本对目标工具更自然时使用。 |
| 3. | 上下文无关语法(CFG) | 一组定义语言中有效字符串的产生式规则。每条规则将非终结符重写为终结符和/或其他非终结符,与周围上下文无关。用于约束输出以匹配编程语言或 OpenAI 工具中自定义格式的语法。 | 用作契约,确保模型仅生成语法接受的有效字符串。 |
| 4. | 最小推理 | 使用少量或零推理令牌运行 GPT-5,以最小化延迟并加快首令牌时间。适用于确定性、轻量级任务(提取、格式化、简短重写、简单分类),这些任务不需要解释。如果未指定,推理努力默认为 medium。 | 设置推理努力为 "minimal"。避免用于多步骤规划或工具密集型工作流。 |
支持的模型:
- gpt-5
- gpt-5-mini
- gpt-5-nano
支持的 API 端点
- Responses API
- Chat Completions API
注意:我们建议在 GPT-5 系列模型中使用 Responses API,以获得模型的最佳性能。
先决条件
首先,更新你的 OpenAI SDK,使其支持 GPT-5 的新参数和工具。确保已将 OPENAI_API_KEY 设置为环境变量。
!pip install --quiet --upgrade openai pandas && \
echo -n "openai " && pip show openai | grep '^Version:' | cut -d' ' -f2 && \
echo -n "pandas " && pip show pandas | grep '^Version:' | cut -d' ' -f2
1. 冗长参数
1.1 概述
冗长参数允许您提示模型在回复中更详细或更简洁。
取值: "low"、"medium"、"high"
- low → 简洁的用户体验,最少的文字。
- medium(默认)→ 平衡的细节。
- high → 详细,适合审计、教学或交接。
保持提示词稳定,使用参数而不是重写。
from openai import OpenAI
import pandas as pd
from IPython.display import display
client = OpenAI()
question = "Write a poem about a boy and his first pet dog."
data = []
for verbosity in ["low", "medium", "high"]:
response = client.responses.create(
model="gpt-5-mini",
input=question,
text={"verbosity": verbosity}
)
# Extract text
output_text = ""
for item in response.output:
if hasattr(item, "content"):
for content in item.content:
if hasattr(content, "text"):
output_text += content.text
usage = response.usage
data.append({
"Verbosity": verbosity,
"Sample Output": output_text,
"Output Tokens": usage.output_tokens
})
# Create DataFrame
df = pd.DataFrame(data)
# Display nicely with centered headers
pd.set_option('display.max_colwidth', None)
styled_df = df.style.set_table_styles(
[
{'selector': 'th', 'props': [('text-align', 'center')]}, # Center column headers
{'selector': 'td', 'props': [('text-align', 'left')]} # Left-align table cells
]
)
display(styled_df)
输出令牌数量大致随详细程度线性增长:低(560)→ 中(849)→ 高(1288)。
2.3 在编码用例中使用 Verbosity
verbosity 参数同样会影响生成代码的长度和复杂度,以及附带解释的深度。以下是一个示例,我们针对一个任务使用不同的 verbosity 级别,来生成一个对 1000000 个随机数进行排序的 Python 程序。
from openai import OpenAI
client = OpenAI()
prompt = "Output a Python program that sorts an array of 1000000 random numbers"
def ask_with_verbosity(verbosity: str, question: str):
response = client.responses.create(
model="gpt-5-mini",
input=question,
text={
"verbosity": verbosity
}
)
# Extract assistant's text output
output_text = ""
for item in response.output:
if hasattr(item, "content"):
for content in item.content:
if hasattr(content, "text"):
output_text += content.text
# Token usage details
usage = response.usage
print("--------------------------------")
print(f"Verbosity: {verbosity}")
print("Output:")
print(output_text)
print("Tokens => input: {} | output: {}".format(
usage.input_tokens, usage.output_tokens
))
# Example usage:
ask_with_verbosity("low", prompt)
注意,代码输出是一个纯脚本。现在,让我们用 'medium' 运行。
ask_with_verbosity("medium", prompt)
中等详细度生成的代码更丰富,并附有额外解释。接下来,让我们尝试高详细度。
ask_with_verbosity("high", prompt)
高详细度产生了额外的细节和解释。
1.3 要点
新的详细度参数可靠地扩展了模型输出的长度和深度,同时保持了正确性和推理质量——无需改变底层提示。
在此示例中:
- 低详细度 生成一个最小、功能性的脚本,没有额外的注释或结构。
- 中等详细度 添加解释性注释、函数结构和可重现性控制。
- 高详细度 生成一个全面、生产就绪的脚本,包含参数解析、多种排序方法、计时/验证、使用说明和最佳实践提示。
2. 自由格式函数调用
2.1 概述
GPT-5 现在可以将原始文本负载(从 Python 脚本到 SQL 查询的任何内容)直接发送到您的自定义工具,而无需使用新的工具 "type": "custom" 将数据包装在 JSON 中。这与传统的结构化函数调用不同,为您与外部运行时交互时提供了更大的灵活性,例如:
- 带有沙箱的 code_exec(Python、C++、Java 等)
- SQL 数据库
- Shell 环境
- 配置生成器
请注意,自定义工具类型不支持并行工具调用。
2.2 快速入门示例 - 计算圆的面积
下面的代码生成了一个简单的 Python 代码来计算圆的面积,并指示模型使用自由格式的工具调用来输出结果。
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-5-mini",
input="Please use the code_exec tool to calculate the area of a circle with radius equal to the number of 'r's in strawberry",
text={"format": {"type": "text"}},
tools=[
{
"type": "custom",
"name": "code_exec",
"description": "Executes arbitrary python code",
}
]
)
print(response.output)
模型会发出一个包含原始 Python 代码的 tool call。你在服务端执行该代码,捕获打印结果,并在后续的 responses.create 调用中将其发送回去。
2.3 迷你基准测试——用三种语言对数组排序
为了说明自由形式工具调用的用法,我们将要求GPT‑5:
- 生成Python、C++和Java代码,对固定数组排序10次。
- 在代码中仅打印每次迭代所花费的时间(以毫秒为单位)。
- 调用所有三个函数,然后停止。
from openai import OpenAI
from typing import List, Optional
MODEL_NAME = "gpt-5"
# Tools that will be passed to every model invocation. They are defined once so
# that the configuration lives in a single place.
TOOLS = [
{
"type": "custom",
"name": "code_exec_python",
"description": "Executes python code",
},
{
"type": "custom",
"name": "code_exec_cpp",
"description": "Executes c++ code",
},
{
"type": "custom",
"name": "code_exec_java",
"description": "Executes java code",
},
]
client = OpenAI()
def create_response(
input_messages: List[dict],
previous_response_id: Optional[str] = None,
):
"""Wrapper around ``client.responses.create``.
Parameters
----------
input_messages: List[dict]
The running conversation history to feed to the model.
previous_response_id: str | None
Pass the ``response.id`` from the *previous* call so the model can keep
the thread of the conversation. Omit on the very first request.
"""
kwargs = {
"model": MODEL_NAME,
"input": input_messages,
"text": {"format": {"type": "text"}},
"tools": TOOLS,
}
if previous_response_id:
kwargs["previous_response_id"] = previous_response_id
return client.responses.create(**kwargs)
# Recursive
def run_conversation(
input_messages: List[dict],
previous_response_id: Optional[str] = None,
):
response = create_response(input_messages, previous_response_id)
# ``response.output`` is expected to be a list where element 0 is the model
# message. Element 1 (if present) denotes a tool call. When the model is
# done with tool calls, that element is omitted.
tool_call = response.output[1] if len(response.output) > 1 else None
if tool_call and tool_call.type == "custom_tool_call":
print("--- tool name ---")
print(tool_call.name)
print("--- tool call argument (generated code) ---")
print(tool_call.input)
# Add a synthetic *tool result* so the model can continue the thread.
input_messages.append(
{
"type": "function_call_output",
"call_id": tool_call.call_id,
"output": "done", # <-- replace with the result of the tool call
}
)
# Recurse with updated conversation and track the response id so the
# model is aware of the prior turn.
return run_conversation(input_messages, previous_response_id=response.id)
else:
# Base-case: no further tool call - return.
return
prompt = """
Write code to sort the array of numbers in three languages: C++, Python and Java (10 times each)using code_exec functions.
ALWAYS CALL THESE THREE FUNCTIONS EXACTLY ONCE: code_exec_python, code_exec_cpp and code_exec_java tools to sort the array in each language. Stop once you've called these three functions in each language once.
Print only the time it takes to sort the array in milliseconds.
[448, 986, 255, 884, 632, 623, 246, 439, 936, 925, 644, 159, 777, 986, 706, 723, 534, 862, 195, 686, 846, 880, 970, 276, 613, 736, 329, 622, 870, 284, 945, 708, 267, 327, 678, 807, 687, 890, 907, 645, 364, 333, 385, 262, 730, 603, 945, 358, 923, 930, 761, 504, 870, 561, 517, 928, 994, 949, 233, 137, 670, 555, 149, 870, 997, 809, 180, 498, 914, 508, 411, 378, 394, 368, 766, 486, 757, 319, 338, 159, 585, 934, 654, 194, 542, 188, 934, 163, 889, 736, 792, 737, 667, 772, 198, 971, 459, 402, 989, 949]
"""
# Initial developer message.
messages = [
{
"role": "developer",
"content": prompt,
}
]
run_conversation(messages)
模型输出了三个代码块,分别用Python、C++和Java实现了同一算法。函数调用的输出被链式地反馈回模型作为输入,以便模型继续运行,直到所有函数都被恰好调用一次。
2.4 要点
GPT-5 中的自由格式工具调用允许您将原始文本负载(如 Python 脚本、SQL 查询或配置文件)直接发送到自定义工具,而无需 JSON 包装。这为与外部运行时交互提供了更大的灵活性,并允许模型以您的工具所期望的确切格式生成代码或文本。当结构化 JSON 不必要且自然文本输出能提高可用性时,这非常理想。
3. 上下文无关文法(CFG)
3.1 概述
上下文无关文法是一组产生式规则的集合,这些规则定义了哪些字符串属于某种语言。每条规则将一个非终结符重写为终结符(字面量标记)和/或其他非终结符的序列,且与周围上下文无关——因此称为上下文无关。CFG 可以捕捉大多数编程语言的语法,在 OpenAI 自定义工具中,它们充当契约,强制模型仅输出文法接受的字符串。
3.2 文法基础
支持的文法语法
- Lark - https://lark-parser.readthedocs.io/en/stable/
- Regex - https://docs.rs/regex/latest/regex/#syntax
我们在底层使用 LLGuidance 来约束模型采样:https://github.com/guidance-ai/llguidance。
不支持的 Lark 特性
- 正则表达式中的环视(
(?=...)、(?!...)等) - 正则表达式中的懒惰修饰符(
*?、+?、??) - 终结符优先级、模板、%declares、%import(除了 %import common)。
终结符与规则及贪婪词法分析
| 概念 | 要点 |
|------------------|------------------------------------------------------------------------------|
| 终结符(大写)| 由词法分析器首先匹配——最长匹配优先。 |
| 规则(小写) | 组合终结符;不能影响文本如何被标记化。 |
| 贪婪词法分析器 | 永远不要试图跨多个终结符“塑造”自由文本——你会失去控制。 |
正确与错误的模式设计
✅ 一个有界的终结符处理锚点之间的自由文本
start: SENTENCE
SENTENCE: /[A-Za-z, ]*(the hero|a dragon)[A-Za-z, ]*(fought|saved)[A-Za-z, ]*(a treasure|the kingdom)[A-Za-z, ]*\./
❌ 不要将自由文本拆分到多个终端/规则中
start: sentence
sentence: /[A-Za-z, ]+/ subject /[A-Za-z, ]+/ verb /[A-Za-z, ]+/ object /[A-Za-z, ]+/
3.3 示例 - SQL 方言:MS SQL 与 PostgreSQL
以下代码示例现已成为使用 CFG 构建多方言 SQL 工具的标准参考。它展示了:
- 两个独立的语法定义(
mssql_grammar_definition、postgres_grammar_definition),分别编码 TOP 与 LIMIT 语义。 - 如何在单个脚本中提示、调用并检查工具调用。
- 并排检查助手的响应。
为不同的 SQL 方言定义 LARK 语法
import textwrap
# ----------------- grammars for MS SQL dialect -----------------
mssql_grammar = textwrap.dedent(r"""
// ---------- Punctuation & operators ----------
SP: " "
COMMA: ","
GT: ">"
EQ: "="
SEMI: ";"
// ---------- Start ----------
start: "SELECT" SP "TOP" SP NUMBER SP select_list SP "FROM" SP table SP "WHERE" SP amount_filter SP "AND" SP date_filter SP "ORDER" SP "BY" SP sort_cols SEMI
// ---------- Projections ----------
select_list: column (COMMA SP column)*
column: IDENTIFIER
// ---------- Tables ----------
table: IDENTIFIER
// ---------- Filters ----------
amount_filter: "total_amount" SP GT SP NUMBER
date_filter: "order_date" SP GT SP DATE
// ---------- Sorting ----------
sort_cols: "order_date" SP "DESC"
// ---------- Terminals ----------
IDENTIFIER: /[A-Za-z_][A-Za-z0-9_]*/
NUMBER: /[0-9]+/
DATE: /'[0-9]{4}-[0-9]{2}-[0-9]{2}'/
""")
# ----------------- grammars for PostgreSQL dialect -----------------
postgres_grammar = textwrap.dedent(r"""
// ---------- Punctuation & operators ----------
SP: " "
COMMA: ","
GT: ">"
EQ: "="
SEMI: ";"
// ---------- Start ----------
start: "SELECT" SP select_list SP "FROM" SP table SP "WHERE" SP amount_filter SP "AND" SP date_filter SP "ORDER" SP "BY" SP sort_cols SP "LIMIT" SP NUMBER SEMI
// ---------- Projections ----------
select_list: column (COMMA SP column)*
column: IDENTIFIER
// ---------- Tables ----------
table: IDENTIFIER
// ---------- Filters ----------
amount_filter: "total_amount" SP GT SP NUMBER
date_filter: "order_date" SP GT SP DATE
// ---------- Sorting ----------
sort_cols: "order_date" SP "DESC"
// ---------- Terminals ----------
IDENTIFIER: /[A-Za-z_][A-Za-z0-9_]*/
NUMBER: /[0-9]+/
DATE: /'[0-9]{4}-[0-9]{2}-[0-9]{2}'/
""")
3.4 生成特定 SQL 方言
让我们定义提示词,并调用函数来生成 MS SQL 方言。
from openai import OpenAI
client = OpenAI()
sql_prompt_mssql = (
"Call the mssql_grammar to generate a query for Microsoft SQL Server that retrieve the "
"five most recent orders per customer, showing customer_id, order_id, order_date, and total_amount, "
"where total_amount > 500 and order_date is after '2025-01-01'. "
)
response_mssql = client.responses.create(
model="gpt-5",
input=sql_prompt_mssql,
text={"format": {"type": "text"}},
tools=[
{
"type": "custom",
"name": "mssql_grammar",
"description": "Executes read-only Microsoft SQL Server queries limited to SELECT statements with TOP and basic WHERE/ORDER BY. YOU MUST REASON HEAVILY ABOUT THE QUERY AND MAKE SURE IT OBEYS THE GRAMMAR.",
"format": {
"type": "grammar",
"syntax": "lark",
"definition": mssql_grammar
}
},
],
parallel_tool_calls=False
)
print("--- MS SQL Query ---")
print(response_mssql.output[1].input)
输出的 SQL 准确使用了 "SELECT TOP" 结构。
sql_prompt_pg = (
"Call the postgres_grammar to generate a query for PostgreSQL that retrieve the "
"five most recent orders per customer, showing customer_id, order_id, order_date, and total_amount, "
"where total_amount > 500 and order_date is after '2025-01-01'. "
)
response_pg = client.responses.create(
model="gpt-5",
input=sql_prompt_pg,
text={"format": {"type": "text"}},
tools=[
{
"type": "custom",
"name": "postgres_grammar",
"description": "Executes read-only PostgreSQL queries limited to SELECT statements with LIMIT and basic WHERE/ORDER BY. YOU MUST REASON HEAVILY ABOUT THE QUERY AND MAKE SURE IT OBEYS THE GRAMMAR.",
"format": {
"type": "grammar",
"syntax": "lark",
"definition": postgres_grammar
}
},
],
parallel_tool_calls=False,
)
print("--- PG SQL Query ---")
print(response_pg.output[1].input)
输出突出显示了相同的逻辑查询——不同的物理语法。提供不同的语法,以便模型只能为所选方言生成有效的语句。
| 方言 | 生成的查询 | 关键区别 |
|---------------|--------------------------------------------------------------|------------------------------------------|
| MS SQL Server | SELECT TOP 5 customer_id, … ORDER BY order_date DESC; | 在列列表之前使用 TOP N 子句。 |
| PostgreSQL | SELECT customer_id, … ORDER BY order_date DESC LIMIT 5; | 在 ORDER BY 之后使用 LIMIT N。 |
3.5 示例 - 正则表达式 CFG 语法
以下代码示例演示了如何使用正则表达式 CFG 语法将自由格式的工具调用限制为特定的时间戳模式。
from openai import OpenAI
client = OpenAI()
timestamp_grammar_definition = r"^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]) (?:[01]\d|2[0-3]):[0-5]\d$"
timestamp_prompt = (
"Call the timestamp_grammar to save a timestamp for August 7th 2025 at 10AM."
)
response_mssql = client.responses.create(
model="gpt-5",
input=timestamp_prompt,
text={"format": {"type": "text"}},
tools=[
{
"type": "custom",
"name": "timestamp_grammar",
"description": "Saves a timestamp in date + time in 24-hr format.",
"format": {
"type": "grammar",
"syntax": "regex",
"definition": timestamp_grammar_definition
}
},
],
parallel_tool_calls=False
)
print("--- Timestamp ---")
print(response_mssql.output[1].input)
3.5 最佳实践
Lark 语法可能难以完美实现。虽然简单的语法最可靠,但复杂的语法通常需要对语法定义本身、提示词和工具描述进行迭代,以确保模型不会偏离分布。
- 保持终结符有界——使用
/[^.\n]{0,10}*\./而不是/.*\./。通过内容(否定字符类)和长度({M,N}量词)限制匹配。 - 优先使用显式字符类而不是
.通配符。 - 显式处理空白,例如使用
SP = " ",而不是全局%ignore。 - 描述你的工具:准确告诉模型 CFG 接受什么,并指示它深入思考合规性。
故障排除
- API 因语法过于复杂而拒绝 ➜ 简化规则和终结符,移除
%ignore.*。 - 出现意外标记 ➜ 确认终结符不重叠;检查贪婪词法分析器。
- 当模型偏离“分布”(表现为模型产生过长或重复的输出,语法有效但语义错误)时:
- 收紧语法。
- 迭代提示词(添加少量示例)和工具描述(解释语法并指示模型推理以符合语法)。
- 尝试更高的推理努力(例如,从中等提高到高等)。
资源:
- Lark 文档 – https://lark-parser.readthedocs.io/en/stable/
- Lark IDE – https://www.lark-parser.org/ide/
- LLGuidance 语法 – https://github.com/guidance-ai/llguidance/blob/main/docs/syntax.md
- Regex(Rust crate)– https://docs.rs/regex/latest/regex/#syntax
3.6 要点总结
GPT-5 中的上下文无关文法(CFG)支持可让你严格约束模型输出,使其符合预定义语法,确保只生成有效字符串。这对于强制执行编程语言规则或自定义格式尤其有用,可减少后处理工作和错误。通过提供精确的文法和清晰的工具描述,你可以让模型可靠地保持在目标输出结构内。
4. 最小推理
4.1 概述
GPT-5 现在支持一种新的最小推理努力。当使用最小推理努力时,模型将输出很少或没有推理令牌。这适用于开发者希望非常快速地看到第一个用户可见令牌的用例。注意:如果未提供推理努力,默认值为中等。
from openai import OpenAI
client = OpenAI()
prompt = "Classify sentiment of the review as positive|neutral|negative. Return one word only."
response = client.responses.create(
model="gpt-5",
input= [{ 'role': 'developer', 'content': prompt },
{ 'role': 'user', 'content': 'The food that the restaurant was great! I recommend it to everyone.' }],
reasoning = {
"effort": "minimal"
},
)
# Extract model's text output
output_text = ""
for item in response.output:
if hasattr(item, "content"):
for content in item.content:
if hasattr(content, "text"):
output_text += content.text
# Token usage details
usage = response.usage
print("--------------------------------")
print("Output:")
print(output_text)
4.2 要点
最小推理模式以极少或零推理令牌运行 GPT-5,以最小化延迟并加快首令牌时间。它适用于确定性、轻量级任务(如提取、格式化、简短改写、简单分类),这些任务不需要解释。如果你未指定推理力度,默认值为中等——当你更看重速度而非深思熟虑时,请明确设置为最小。
常见问题
常见错误包括:1) 未更新 SDK 导致参数不识别,需升级 openai 库。2) CFG 语法过于复杂导致 API 拒绝,应简化规则,避免使用环视和懒惰修饰符。3) 自由格式工具调用不支持并行,需设置 parallel_tool_calls: false。4) 最小推理模式用于复杂任务时输出质量下降,应仅用于简单任务。排查方法:检查 API 错误信息,使用 Lark IDE 验证语法,逐步简化提示词和工具描述。生产环境优化:合理设置冗长级别以平衡成本和体验,使用 CFG 确保输出格式,利用最小推理降低延迟。
企业应用扩展
开发者可进一步探索:1) 结合冗长参数与提示词工程,实现动态输出长度控制。2) 将自由格式函数调用与代码沙箱集成,构建自动化代码生成与执行流水线。3) 利用 CFG 定义自定义 DSL,实现领域特定语言的生成。4) 在低延迟场景中,结合最小推理与模型蒸馏,提升响应速度。此外,可关注 OpenAI 后续对 CFG 支持的扩展,以及与其他工具(如函数调用)的协同使用。
总结
本文深入解析 GPT-5 系列新增的开发者控制功能,包括冗长参数、自由格式函数调用、上下文无关文法(CFG)和最小推理模式。通过实际代码示例,展示如何调整输出长度、直接生成原始文本负载、严格约束输出格式以及降低延迟。适合有编程基础的开发者快速掌握这些高级特性,提升 AI 应用的工程化水平。
- --
内容来源与验证
- 内容等级:PREMIUM_A
- 质量等级:S_CANDIDATE
- 难度:中级
- 验证等级:V1
- 原文作者:msingh-openai
- 原文日期:2025-08-07
- 来源许可:MIT
- 来源版本:
7797b60f1c5a3bbbf8284d8c5873185cc4e2a1f4 - 查看原文
站内还有更多完整实战教程
加入会员,解锁全部教程、完整代码与持续更新内容。
加入会员