Skip to main content
Introducing the Agents API | OpenAI

September 10, 2026

ProductAPI

Introducing the Agents API

Build and run cloud agents with the Codex harness, fully managed by OpenAI.

00:0902:18

Listen to article收听文章5:045:04收听文章 5:04

As we’ve scaled Codex and ChatGPT for Work to millions of people around the world, we’ve learned what it takes to make long-running agents work well in practice. Useful agents need a powerful harness that manages context, uses tools efficiently, and coordinates subagents. They also need infrastructure that keeps them running reliably for days, with environments where they can work with files, run code, and save intermediate results.随着我们将 Codex 和 ChatGPT for Work 扩展到全球数百万用户,我们深刻理解了如何让长期运行的智能体(agents)在实践中发挥作用。实用的智能体需要强大的支撑框架来管理上下文、高效使用工具并协调子智能体。它们还需要能够支持其连续数日可靠运行的基础设施,以及能够处理文件、运行代码和保存中间结果的环境。

Today, we’re introducing the Agents API⁠(opens in a new window) in public beta, bringing that same harness and infrastructure that powers Codex to developers through a simple, flexible API.今天,我们推出了 Agents API(在新的窗口中打开)的公开测试版,旨在通过简单、灵活的 API,为开发者提供驱动 Codex 的核心支撑框架与基础设施。

What our customers are saying about Agents API

1 of 8
“With the Agents API, our evaluation score went from 0.71 to 0.85. The subagent support in the API is great and drastically sped up our workflow. Previously it was pretty cumbersome to observe and orchestrate subagents in our old setup but the new APIs gave us a 4x latency reduction. We spent a long time trying to optimize for this and the subagent flows were a huge out-of-the-box lift.”“在使用 Agents API 后,我们的评估分数从 0.71 提升到了 0.85。API 对子智能体的支持非常出色,极大地加快了我们的工作流。以前,在旧架构中观察和编排子智能体相当繁琐,而新的 API 使我们的延迟降低了 4 倍。我们曾花费大量时间进行优化,而子智能体流程的引入带来了立竿见影的巨大提升。”
Jack Weissenberger, CTO, Ciridae
  • Ciridae
  • Long Lake
  • WithCoverage
  • SafetyKit
  • Dwelly
  • Hypha
  • deepsense.ai
  • Nash.ai

Build cloud agents with a single API call

With the Agents API, you can create a production-ready agent in a single API call by specifying the task, model, tools, and environment:借助 Agents API,您只需通过一次 API 调用,指定任务、模型、工具和环境,即可创建一个生产就绪的智能体:

JavaScriptJavaScript

1
import OpenAI from "openai";
2

3
const client = new OpenAI();
4

5
const session = await client.beta.agents.sessions.create({
6
agent: {
7
model: "gpt-6-astra",
8
tools: [
9
{
10
type: "mcp",
11
server_label: "observability",
12
transport: {
13
type: "http",
14
server_url: "https://observability.example.com/mcp",
15
},
16
},
17
],
18
multi_agent: { enabled: true, max_concurrent_subagents: 3 },
19
},
20
vault_ids: ["vault_YOUR_VAULT_ID"],
21
environment: {
22
type: "openai_hosted",
23
capability_directories: ["/workspace/capabilities/skills"],
24
},
25
input:
26
"Investigate service-api’s elevated 5xx rate over the last 30 minutes. " +
27
"Delegate deployment, error, and dependency analysis to subagents. " +
28
"Save findings, evidence, and recommended mitigation in /workspace/outputs.",
29
});

OpenAI hosts and maintains the harness. You choose the agent’s compute environment: in an OpenAI-managed sandbox, on your own infrastructure, or with one of our sandbox partners. The Agents API gives you a strong foundation for building agents on top of our optimized agent harness and infrastructure, so you can focus on the tools, knowledge, and workflows that make your agent unique.OpenAI 负责托管和维护该支撑框架。您可以选择智能体的计算环境:在 OpenAI 管理的沙盒中、在您自己的基础设施上,或通过我们的沙盒合作伙伴之一运行。Agents API 为您在我们的优化智能体框架和基础设施之上构建智能体提供了坚实的基础,让您可以专注于那些使您的智能体独一无二的工具、知识和工作流。

An application sends tasks to the Agents API and receives events and output. The Agents API runs the managed Codex harness, sending tool calls to a sandbox and receiving tool results. The application controls self-hosted compute.

Agents API powers your agents with the same harness and infrastructure behind Codex.Agents API 以驱动 Codex 的相同支撑框架和基础设施为您的智能体赋能。

Choose your agent environment

Different workloads need different compute, storage, and deployment options. The Agents API lets you choose a sandbox that fits your application.不同的工作负载需要不同的计算、存储和部署选项。Agents API 让您可以选择适合您应用的沙盒。

We’re partnering with ecosystem providers⁠(opens in a new window), including Blaxel, Cloudflare, Daytona, DigitalOcean, E2B, Modal, Oracle, Runloop, and Vercel, to provide first-class integrations for a range of needs:我们正在与生态系统提供商(在新的窗口中打开)合作,包括 Blaxel、Cloudflare、Daytona、DigitalOcean、E2B、Modal、Oracle、Runloop 和 Vercel,以针对各种需求提供一流的集成方案:

  • Fully managed environments or deployments within your VPC完全托管的环境或在您的 VPC 内进行的部署
  • Specific file and secret storage mechanisms特定的文件和密钥存储机制
  • Different CPU, GPU, and memory configurations, with performance, cold-start, and cost profiles to match your company’s workflow.不同的 CPU、GPU 和内存配置,以及符合您公司工作流的性能、冷启动和成本配置。
Sandbox partners: Modal, Cloudflare, Daytona, Blaxel, Runloop, Vercel, Oracle, E2B, and DigitalOcean.

The Agents API offers first-class integrations with popular ecosystem providers.Agents API 提供与主流生态系统提供商的一流集成。

OpenAI hosted sandboxes

For developers who want to get started quickly and scale efficiently, we’re also introducing the OpenAI hosted sandbox⁠(opens in a new window). This leverages the same sandboxing infrastructure that powers Codex and ChatGPT.对于希望快速上手并高效扩展的开发者,我们还推出了 OpenAI 托管沙盒(在新的窗口中打开)。它利用了驱动 Codex 和 ChatGPT 的相同沙盒基础设施。

OpenAI provisions and manages the sandbox, giving your agent a secure and performant environment to run code, work with files, and produce artifacts. These sandboxes can be flexibly configured with your files, packages, skills and plugins to give the agent what it needs to complete the task.OpenAI 提供并管理沙盒,为您的智能体提供一个安全且高性能的环境来运行代码、处理文件并生成工件。这些沙盒可以根据您的文件、包、技能和插件进行灵活配置,从而为智能体提供完成任务所需的一切。

Build with an evolving Codex harness

Taking advantage of new model capabilities often means reworking your harness, taking valuable time away from improving your application. The Agents API provides versioned access to these capabilities with each model launch. We maintain and continuously improve the harness alongside our models, helping your agents get better performance from every upgrade. For example, recent improvements to the harness include:利用新的模型能力往往意味着需要重构您的支撑框架,这会占用改进应用所需的宝贵时间。Agents API 在每次模型发布时提供对这些能力的版本化访问。我们与模型同步维护并持续改进该支撑框架,帮助您的智能体从每次升级中获得更好的性能。例如,近期对支撑框架的改进包括:

Keep agents working across long sessions

To support models working for hours, we’ve built context management that helps agents carry relevant information across longer sessions. The Agents API automatically compacts⁠(opens in a new window) earlier context as a session approaches its context limit, preserving information the agent needs to continue. Developers can build workflows that span multiple context windows without implementing their own compaction logic.为了支持长达数小时的模型运行,我们构建了上下文管理功能,帮助智能体在更长的会话中携带相关信息。当会话接近上下文限制时,Agents API 会自动压缩(在新的窗口中打开)先前的上下文,从而保留智能体继续工作所需的信息。开发者无需实现自己的压缩逻辑,即可构建跨越多个上下文窗口的工作流。

Help agents efficiently use more tools

The Agents API helps agents find the right tools and use them efficiently. Tool search⁠(opens in a new window) loads relevant tool definitions as needed, helping reduce token usage and cost while preserving the model’s cache. Once tools are available, programmatic tool calling⁠(opens in a new window) lets agents run calls in parallel, chain related operations, and filter or combine results in code so they can work through large volumes of data while bringing only the relevant results back into context. The Agents API supports MCP, custom functions, and built-in tools like web search.Agents API 帮助智能体找到合适的工具并高效使用它们。工具搜索(在新的窗口中打开)功能会根据需要加载相关的工具定义,从而在保留模型缓存的同时减少 Token 使用量和成本。一旦工具可用,程序化工具调用(在新的窗口中打开)功能允许智能体并行运行调用、链接相关操作,并在代码中过滤或组合结果,以便它们在处理大量数据时,仅将相关结果带回上下文中。Agents API 支持 MCP、自定义函数以及 Web 搜索等内置工具。

JSON

1
"agent": {
2
"tools": [
3
{
4
"type": "mcp",
5
"server_label": "openai_docs",
6
"transport": {
7
"type": "http",
8
"server_url": "https://developers.openai.com/mcp"
9
}
10
},
11
]
12
}

Let agents parallelize work with subagents

With multi-agent support⁠(opens in a new window), the Agents API can break complex tasks into independent pieces and delegate them to subagents that work in parallel. Each subagent maintains its own context, helping it stay focused on its assignment, while the main agent coordinates their work and brings the results together. This can speed up research, analysis, and coding tasks that benefit from parallel work, without requiring you to build your own orchestration.借助多智能体支持(在新的窗口中打开),Agents API 可以将复杂任务拆解为独立的部分,并委派给并行工作的子智能体。每个子智能体维护其自己的上下文,有助于其专注于分配的任务,而主智能体则协调它们的工作并汇总结果。这可以在无需您自行构建编排逻辑的情况下,加速那些受益于并行工作的研究、分析和编码任务。

JSON

1
"agent": {
2
"model": "gpt-6-astra",
3
"multi_agent": {
4
"enabled": true,
5
"max_concurrent_subagents": 3,
6
}
7
}

An open-source foundation

The Agents API is powered by the open-source Codex harness, giving developers visibility into the core logic that coordinates model calls, tools, and context. With the Agents API, OpenAI operates and maintains that harness while developers can inspect and learn from its public codebase⁠(opens in a new window).Agents API 由开源的 Codex 支撑框架驱动,使开发者能够洞察协调模型调用、工具和上下文的核心逻辑。通过 Agents API,OpenAI 负责运营和维护该框架,而开发者可以查看并学习其公开代码库(在新的窗口中打开)。

Start building

Agents API is available in public beta today to all developers. There are no additional fees for using the Agents API – you simply pay for the tokens and tools your agents use, as outlined on our pricing page⁠(opens in a new window).Agents API 即日起向所有开发者开放公开测试版。使用 Agents API 无需额外费用——您只需按照定价页面(在新的窗口中打开)所述,为您智能体使用的 Token 和工具付费。

Explore the Agents API overview⁠(opens in a new window) to learn more, or follow the quickstart⁠(opens in a new window) to get started and bring the harness behind Codex into your own agents.浏览 Agents API 概览(在新的窗口中打开)以了解更多信息,或按照快速入门(在新的窗口中打开)指南开始使用,将驱动 Codex 的支撑框架引入您自己的智能体中。

During the public beta, we’ll iterate quickly based on your feedback as we work toward general availability. Let us know what’s working, where you’re running into friction, and what you need to build and run your agents in production.在公开测试期间,我们将根据您的反馈快速迭代,并朝着正式发布的目标迈进。请告诉我们哪些功能运行良好、您在何处遇到了阻碍,以及您在生产环境中构建和运行智能体时还需要什么。

Author作者

OpenAIOpenAI