Responses API 新增工具和功能

为开发者和企业在 Responses API 中引入远程 MCP 服务器支持、图像生成、Code Interpreter 等功能。

今天,我们为 Responses API 添加了新的内置工具,它是我们用于构建自主代理应用的核心 API 原语。 这包括对所有 远程 Model Context Protocol (MCP) 服务器 ⁠(opens in a new window) 的支持,以及诸如 图像生成 ⁠(opens in a new window)Code Interpreter ⁠(opens in a new window) 等工具,以及对 文件搜索 ⁠(opens in a new window) 的改进。 这些工具可在我们的 GPT‑4o 系列、GPT‑4.1 系列和 OpenAI o-series 推理模型中使用。 o3 和 o4-mini 现在可以直接在 Responses API 的 chain-of-thought 中调用工具和函数,从而产生上下文更丰富、更相关的答案。 将 o3 和 o4-mini 与 Responses API 结合使用,可以跨请求和工具调用保留推理 token,从而提高模型智能,并降低开发者的成本和延迟。

我们还在 Responses API 中引入了新功能,以提高企业和开发者的可靠性、可见性和隐私性。 这些包括 后台模式 ⁠(opens in a new window),用于异步和更可靠地处理长时间运行的任务,支持 推理摘要 ⁠(opens in a new window),以及支持 加密推理项目 ⁠(opens in a new window)

自 2025 年 3 月发布具有 Web 搜索、文件搜索和计算机使用等工具的 Responses API 以来,已有成千上万的开发人员使用该 API 在我们的模型中处理了数万亿个 token。 客户使用该 API 构建了各种自主代理应用程序,包括 Zencoder ⁠(opens in a new window) 的编码代理、Revi ⁠(opens in a new window) 面向私募股权和投资银行业的市场情报代理,以及 MagicSchool AI ⁠(opens in a new window) 的教育助手——所有这些都使用 Web 搜索将相关的最新信息提取到他们的应用程序中。 现在,借助今天发布的新工具和功能,开发人员可以构建更有用、更可靠的代理。

新的远程 MCP 服务器支持

我们正在 Responses API 中添加对 远程 MCP 服务器 ⁠(opens in a new window) 的支持,这是基于 Agents SDK 中的 MCP 支持 ⁠(opens in a new window) 的发布而构建的。 MCP 是一种开放协议,它标准化了应用程序如何向 LLM 提供上下文。 通过在 Responses API 中支持 MCP 服务器,开发人员只需几行代码即可将我们的模型连接到托管在任何 MCP 服务器上的工具。 以下是一些示例,展示了开发人员如何立即将远程 MCP 服务器与 Responses API 结合使用:

Shopify Twilio Stripe DeepWiki (Devin)

Python


1
response = client.responses.create(
2
 model="gpt-4.1",
3
 tools=[{
4
  "type": "mcp",
5
  "server_label": "shopify",
6
  "server_url": "https://pitchskin.com/api/mcp",
7
 }],
8
 input="Add the Blemish Toner Pads to my cart"
9
)

```
`
The Blemish Toner Pads have been added to your cart! You can proceed to checkout here:
![Pitch. Skin checkout page showing express options \(Shop Pay, PayPal, G Pay\), contact and delivery form fields, and an order summary for one ‘Blemish Toner Pads 200 mL \(120 pads\)’ priced at AUD $49.](https://images.ctfassets.net/kftzwdyauwt9/4tJh30qd64hXN5bcEFxQUa/09162bd854c113ecb5feb836316e4cb0/Screenshot_2025-05-20_at_4.14.13â__PM.png?w=3840&q=90&fm=webp)
#### Python

1 response = client.responses.create( 2 model="gpt-4o", 3 tools=[ 4 { "type": "web_search_preview" }, 5 { 6 "type": "mcp", 7 "server_label": "twilio", 8 "server_url": "https://.twil.io/mcp", 9 "headers": { "x-twilio-signature": "..." } 10 } 11 ], 12 input="Get the latest soccer news and text a short summary to +1 555 555 5555" 13 )

`
I found the latest soccer news, summarized it, and texted the update to +1 555 555 5555.
![iPhone Messages chat titled ‘Soccer News’ showing a single grey bubble with headlines: ‘Transfers open; Spurs eye first trophy in Europa League; Bayern may sell Boey; Reus rescues LA Galaxy in El Tráfico draw.](https://images.ctfassets.net/kftzwdyauwt9/6gjeUhXCwWaIy15OgmIdGr/b2647531f453e1cdcf59d2515ab8ea18/Frame_21.png?w=3840&q=90&fm=webp)
#### Python

1 response = client.responses.create( 2 model="o3", 3 tools=[ 4 { 5 "type": "mcp", 6 "server_label": "stripe", 7 "server_url": "https://mcp.stripe.com", 8 "headers": { "Authorization": "Bearer " } 9 } 10 ], 11 input="user_291471 used 700 minutes of storage at $0.30/minute. Generate a payment link for this." 12 )

`
Here is the payment link for user_29471's storage usage (700 minutes at $0.30/min, total $210). You can share this link with the user for payment.
![Hypernian checkout: $210 storage charge with Link, card, or Cash App Pay options and a ‘Pay’ button.](https://images.ctfassets.net/kftzwdyauwt9/3JYfIIlQr4CbtJAc5tHttX/f0cf60b0e547655ef5ec2f41e715e2ad/Screenshot_2025-05-20_at_11.50.58â__AM.png?w=3840&q=90&fm=webp)
#### Python

1 response = client.responses.create( 2 model="gpt-4.1-mini", 3 tools=[{ 4 "type": "mcp", 5 "server_label": "deepwiki", 6 "server_url": "https://mcp.deepwiki.com/mcp" 7 }], 8 input="give me 5 interesting facts on modelcontextprotocol/python-sdk -- keep it short!" 9 )

`
Here are 5 interesting facts about the modelcontextprotocol/python-sdk:
1. The MCP SDK implements a standardized client-server architecture for exposing context to Large Language Models (LLMs) using well-defined protocols and transports like SSE, WebSocket, and STDIO.
2. It provides two main server implementations: FastMCP (high-level with decorator-based API) and a low-level Server for complete protocol control.
3. MCP defines three core primitives: Resources (data exposure), Tools (functions), and Prompts (interactive templates).
4. The SDK includes automatic function metadata extraction and validation using Pydantic models, ensuring robust and strongly typed function calls.
5. During initialization, MCP servers declare capabilities like resource subscription and prompt management, enabling clients to adapt dynamically for security and feature negotiation.

流行的远程 MCP 服务器包括 [_Cloudflare_ ⁠(opens in a new window)](https://openai.com/index/<https:/developers.cloudflare.com/agents/guides/remote-mcp-server/>)、[_Hubspot_ ⁠(opens in a new window)](https://openai.com/index/<https:/developers.hubspot.com/mcp>)、[_Intercom_ ⁠(opens in a new window)](https://openai.com/index/<https:/developers.intercom.com/docs/guides/mcp>)、[_PayPal_ ⁠(opens in a new window)](https://openai.com/index/<https:/developer.paypal.com/tools/mcp-server>)、[_Plaid_ ⁠(opens in a new window)](https://openai.com/index/<https:/plaid.com/docs/mcp/>)、[_Shopify_ ⁠(opens in a new window)](https://openai.com/index/<https:/shopify.dev/docs/apps/build/storefront-mcp>)、[_Stripe_ ⁠(opens in a new window)](https://openai.com/index/<https:/docs.stripe.com/mcp>)、[_Square_ ⁠(opens in a new window)](https://openai.com/index/<https:/developer.squareup.com/docs/mcp>)、[_Twilio_ ⁠(opens in a new window)](https://openai.com/index/<https:/github.com/twilio-labs/function-templates/tree/main/mcp-server>)、[_Zapier_ ⁠(opens in a new window)](https://openai.com/index/<https:/zapier.com/mcp>) 等等。 我们预计远程 MCP 服务器的生态系统将在未来几个月内迅速发展,从而使开发人员可以更轻松地构建功能强大的代理,这些代理可以连接到其用户已经依赖的工具和数据源。 为了更好地支持生态系统并为该开发标准做出贡献,OpenAI 还加入了 MCP 的指导委员会。

要了解如何启动自己的远程 MCP 服务器,请查看 [_Cloudflare_ ⁠(opens in a new window)](https://openai.com/index/<https:/developers.cloudflare.com/agents/guides/remote-mcp-server/>) 的本指南。 要了解如何在 Responses API 中使用 MCP 工具,请查看我们 API Cookbook 中的 [_本指南_ ⁠(opens in a new window)](https://openai.com/index/<http:/cookbook.openai.com/examples/mcp/mcp_tool_guide>)。

## 图像生成、Code Interpreter 和文件搜索更新

借助 Responses API 中的内置工具,开发人员只需一个 API 调用即可轻松创建功能更强大的代理。 通过在推理时调用多个工具,模型现在可以在诸如 Humanity’s Last Exam 之类的行业标准基准上实现更高的工具调用性能 ([_来源_](https://openai.com/index/</index/introducing-o3-and-o4-mini/>))。 今天,我们添加了新工具,包括:

*   **图像生成:** 除了使用 [_Images API_ ⁠(opens in a new window)](https://openai.com/index/<https:/platform.openai.com/docs/api-reference/images>) 之外,开发人员现在还可以在 Responses API 中作为工具访问我们的 [_最新图像生成模型_](https://openai.com/index/</index/image-generation-api/>) —`gpt-image-1`。 该工具支持实时流式传输(使开发人员可以在图像生成时查看图像的预览),以及多轮编辑(使开发人员可以提示模型逐步精细地细化这些图像)。 [_了解更多_ ⁠(opens in a new window)](https://openai.com/index/<https:/platform.openai.com/docs/guides/image-generation?image-generation-model=gpt-image-1#generate-images>)。
*   **Code Interpreter:** 开发人员现在可以在 Responses API 中使用 [_Code Interpreter_ ⁠(opens in a new window)](https://openai.com/index/<https:/platform.openai.com/docs/guides/tools-code-interpreter>) 工具。 此工具对于数据分析、解决复杂的数学和编码问题以及帮助模型深入理解和处理图像非常有用(例如, [_thinking with images_](https://openai.com/index/</index/thinking-with-images/>))。 诸如 o3 和 o4-mini 之类的模型在其 chain-of-thought 中使用 Code Interpreter 工具的能力已提高了多个基准测试的性能,包括 Humanity’s Last Exam ([_来源_](https://openai.com/index/</index/introducing-o3-and-o4-mini/>))。 [_了解更多_ ⁠(opens in a new window)](https://openai.com/index/<https:/platform.openai.com/docs/guides/tools-code-interpreter>)。
*   **文件搜索:** 开发人员现在可以在我们的推理模型中访问 [_文件搜索_ ⁠(opens in a new window)](https://openai.com/index/<https:/platform.openai.com/docs/guides/tools-file-search>) 工具。 文件搜索使开发人员能够根据用户查询将文档的相关部分提取到模型的上下文中。 我们还对文件搜索工具进行了更新,使开发人员可以在多个向量存储中执行搜索,并支持使用数组进行属性过滤。 [_了解更多_ ⁠(opens in a new window)](https://openai.com/index/<https:/platform.openai.com/docs/guides/tools-file-search>)。

## Responses API 中的新功能

除了新工具之外,我们还在 Responses API 中添加了对新功能的支持,包括:

*   **后台模式:** 正如在 [_Codex_](https://openai.com/index/</index/introducing-codex/>)、[_deep research_](https://openai.com/index/</index/introducing-deep-research/>) 和 [_Operator_](https://openai.com/index/</index/introducing-operator/>) 等自主代理产品中所看到的那样,推理模型可能需要几分钟才能解决复杂的问题。 开发人员现在可以使用后台模式在 o3 等模型上构建类似的体验,而无需担心超时或其他连接问题——后台模式会异步启动这些任务。 开发人员可以轮询这些对象以检查是否完成,或者在他们的应用程序需要了解最新状态时开始流式传输事件。 [_了解更多_ ⁠(opens in a new window)](https://openai.com/index/<https:/platform.openai.com/docs/guides/async-requests>)。

#### Python

1 response = client.responses.create( 2 model="o3", 3 input="Write me an extremely long story.", 4 reasoning={ "effort": "high" }, 5 background=True 6 )

`
*   **推理摘要:** Responses API 现在可以生成模型内部 chain-of-thought 的简洁、自然语言摘要,类似于你在 ChatGPT 中看到的摘要。 这使开发人员可以更轻松地调试、审计和构建更好的最终用户体验。 推理摘要免费提供。 [_了解更多_ ⁠(opens in a new window)](https://openai.com/index/<https:/platform.openai.com/docs/guides/reasoning?api-mode=responses#reasoning-summaries>)。

#### Python

1 response = client.responses.create( 2 model="o4-mini", 3 tools=[ 4 { 5 "type": "code_interpreter", 6 "container": {"type": "auto"} 7 } 8 ], 9 instructions=( 10 "You are a personal math tutor. " 11 "When asked a math question, run code to answer the question." 12 ), 13 input="I need to solve the equation 3x + 11 = 14. Can you help me?", 14 reasoning={"summary": "auto"} 15 )

`
*   **加密推理项:** 符合 [_零数据保留 (ZDR)_ ⁠(opens in a new window)](https://openai.com/index/<https:/community.openai.com/t/zero-data-retention-information/702540>) 条件的客户现在可以在 API 请求中重复使用推理项,而无需将任何推理项存储在 OpenAI 的服务器上。 对于诸如 o3 和 o4-mini 之类的模型,在函数调用之间重复使用推理项可以提高智能,减少 token 使用量并提高缓存命中率,从而降低成本和延迟。 [_了解更多_ ⁠(opens in a new window)](https://openai.com/index/<https:/platform.openai.com/docs/guides/reasoning?api-mode=responses#encrypted-reasoning-items>)。

#### Python

1 response = client.responses.create( 2 model="o3", 3 input="Implement a simple web server in Rust from scratch.", 4 store=False, 5 include=["reasoning.encrypted_content"] 6 )

`
## 定价和可用性

所有这些工具和功能现在都可在 Responses API 中使用,并且在我们的 GPT‑4o 系列、GPT‑4.1 系列和我们的 OpenAI o-series 推理模型(o1、o3、o3‑mini 和 o4-mini)中受支持。 图像生成仅在我们的推理模型系列的 o3 上受支持。

现有工具的定价保持不变。 图像生成成本为 5.00 美元/1M 文本输入 token、10.00 美元/1M 图像输入 token 和 40.00 美元/1M 图像输出 token,缓存输入 token 可享受 75% 的折扣。 Code Interpreter 每个容器的成本为 0.03 美元。 文件搜索的成本为每天每 GB 向量存储 0.10 美元,每 1k 个工具调用 2.50 美元。 调用远程 MCP 服务器工具没有额外费用——你只需为 API 的输出 token 付费。 在我们的文档中了解有关 [_定价_ ⁠(opens in a new window)](https://openai.com/index/<https:/platform.openai.com/docs/pricing#built-in-tools>) 的更多信息。

我们很高兴看到你构建的产品!