使用 Codex harness 构建并运行云端智能体,由 OpenAI 全托管。
随着我们将 Codex 和 ChatGPT for Work 扩展到全球数百万用户,我们了解到要让长时间运行的智能体在实践中良好运作需要什么。有用的智能体需要一个强大的 harness,能够管理上下文、高效使用工具并协调子智能体。它们还需要能够让其可靠运行数天的基础设施,以及可以处理文件、运行代码并保存中间结果的环境。
今天,我们推出 Agents API 公测版,通过一个简单、灵活的 API,将驱动 Codex 的同一套 harness 和基础设施带给开发者。
OpenAI 负责托管和维护 harness。你可以选择智能体的计算环境:在 OpenAI 托管的沙箱中、在你自己的基础设施上,或使用我们的沙箱合作伙伴之一。Agents API 为你提供了坚实的基础,让你能够在我们优化的智能体 harness 和基础设施之上构建智能体,这样你就可以专注于让你的智能体独一无二的工具、知识和工作流。
“借助 Agents API,我们的评估分数从 0.71 提升到了 0.85。API 中的子智能体支持非常出色,大幅加快了我们的工作流。此前,在我们旧有的设置中观察和编排子智能体相当繁琐,但新的 API 让我们的延迟降低了 4 倍。我们花了很长时间试图为此做优化,而子智能体流程带来了巨大的开箱即用提升。”
Jack Weissenberger,Ciridae 首席技术官

Agents API 以驱动 Codex 的同一套 harness 和基础设施为你的智能体提供支持。
只需一次 API 调用即可构建云端智能体
借助 Agents API,你只需一次 API 调用,指定任务、模型、工具和环境,即可创建一个可用于生产环境的智能体:
JSON
1import OpenAI from "openai";23const client = new OpenAI();45const 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});
我们的客户如何评价 Agents API
“要改造现实世界的业务,就意味着把 AI 部署到各种形态的工作流中。Agents API 提供了 harness;而环境、上下文和用户体验仍由我们掌控。借助我们的 AI 平台 Nexus,我们现在能在数小时内跨行业搭建起智能体,从住宅服务到建筑设计皆可覆盖。”
Rasmus Wissmann,Long Lake 首席技术官
“Agents API 让我们得以换一种思路来设计复杂的多步骤工作流。过去我们要编写提示词链并自行管理一套工具调用,而现在我们可以直接在代码中使用智能体,就像 Codex 在你的笔记本电脑上运行那样。它已经帮我们解决了几个原本需要自行构建定制智能体基础设施才能解决的问题。”
Cole Striler,WithCoverage 工程总监
“在将我们的案件审查工作流迁移到 Agents API 之后,我们看到每个案件的成本降低了 60%,延迟更低,token 效率显著提升,同时保持了原有的性能。”
Bhavyansh Sabharwal,SafetyKit 技术团队成员
“在我们的测试中,最突出的是 Agents API 处理突发负载的方式有多么自然。我们可以将工作分散到数百个智能体上,异步运行它们,之后再收集结果,而无需在峰值之间让基础设施闲置。”
Dmitry Khanukov,Dwelly 联合创始人兼 CTO
“赢得客户的信任在金融服务中至关重要。OpenAI 的 Agents API 使我们能够构建更可靠的智能体,让客户有信心在生产环境中使用它们。通过将智能体运行框架与沙箱分离,我们将智能体响应失败率降低了 86%。”
Serhii Shchoholiev,Hypha 首席工程师
“Agents API 在一个真实、活跃的代码仓库中完成了实现、独立审查、修复以及真实浏览器验证。总体而言,该智能体的工程品质非常出色。”
Maks Operlejn,deepsense.ai 高级 ML 工程师
“在 Nash,我们部署了数千个长时间运行的 AI 智能体,管理着全球物流网络中数亿次配送。OpenAI 的 Agents API 为我们提供了所需的持久会话与编排层,让智能体能够在生产环境中持续运行,管理上下文、恢复和多步骤执行,而 Nash 则提供工具和执行环境,将它们与物理世界连接起来。这使我们的智能体能够跨复杂工作流进行推理、行动、恢复和协作,这些工作流可能持续数小时甚至数天。这些智能体是生产基础设施,为我们的合作伙伴运行关键任务物流运营。”
Aziz Alghunaim,Nash.ai 联合创始人兼 CTO
选择你的智能体环境
不同的工作负载需要不同的计算、存储和部署选项。Agents API 让你可以选择适合你应用的沙箱。
我们正在与生态合作伙伴携手,包括 Blaxel、Cloudflare、Daytona、DigitalOcean、E2B、Modal、Oracle、Runloop 和 Vercel,为一系列需求提供一流的集成:
- 完全托管的环境,或部署在你自己的 VPC 中
- 特定的文件和密钥存储机制
- 不同的 CPU、GPU 和内存配置,具备与贵公司工作流相匹配的性能、冷启动和成本特征。

Agents API 提供与主流生态服务商的一流集成。
OpenAI 托管沙箱
对于希望快速上手并高效扩展的开发者,我们还推出了 OpenAI 托管沙箱。它复用了驱动 Codex 和 ChatGPT 的同一套沙箱基础设施。
OpenAI 负责沙箱的配置与管理,为你的智能体提供一个安全且高性能的环境,用于运行代码、处理文件并生成产物。这些沙箱可以灵活地配置你的文件、软件包、技能和插件,为智能体提供完成任务所需的一切。
基于持续演进的 Codex harness 进行构建
要利用新的模型能力,往往意味着要重构你的 harness,这会占用本可用于改进应用的宝贵时间。Agents API 在每次模型发布时,以版本化的方式提供对这些能力的访问。我们与模型同步维护并持续改进 harness,帮助你的智能体在每次升级中获得更好的性能。例如,harness 近期的改进包括:
让智能体在长时间会话中持续工作
为了支持模型连续工作数小时,我们构建了上下文管理机制,帮助智能体在更长的会话中携带相关信息。当会话接近上下文窗口上限时,Agents API 会自动压缩较早的上下文,保留智能体继续工作所需的信息。开发者可以构建跨越多个上下文窗口的工作流,而无需自行实现压缩逻辑。
帮助智能体高效使用更多工具
Agents API 帮助智能体找到合适的工具并高效使用它们。工具搜索会按需加载相关的工具定义,有助于减少 token 用量和成本,同时保留模型的缓存。工具可用后,程序化工具调用让智能体可以并行执行调用、串联相关操作,并在代码中过滤或合并结果,从而能够处理海量数据,同时只将相关结果带回上下文中。Agents API 支持 MCP、自定义函数以及网页搜索等内置工具。
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}
让智能体通过子智能体并行处理工作
借助多智能体支持,Agents API 可以将复杂任务拆解为相互独立的部分,并委派给并行工作的子智能体。每个子智能体都维护自己的上下文,从而帮助它专注于自己的任务,而主智能体则协调它们的工作并汇总结果。这可以加速那些受益于并行处理的研究、分析和编码任务,而无需你自己构建编排逻辑。
JSON
1"agent": {2 "model": "gpt-6-astra",3 "multi_agent": {4 "enabled": true,5 "max_concurrent_subagents": 3,6 }7}
构建于开源基础之上
Agents API 由开源的 Codex harness 驱动,让开发者能够了解协调模型调用、工具和上下文的核心逻辑。借助 Agents API,OpenAI 负责运营和维护该 harness,而开发者则可以查看其公开代码库并从中学习。
开始构建
Agents API 今日面向所有开发者开放公开测试版。使用 Agents API 无需额外费用——你只需为智能体所使用的 token 和工具付费,具体如我们的定价页面所述。
浏览Agents API 概览以了解更多,或按照快速入门开始使用,将 Codex 背后的 harness 引入你自己的智能体。
在公开测试期间,我们将根据你们的反馈快速迭代,朝着正式可用版本推进。请告诉我们哪些地方好用、在哪里遇到了阻碍,以及你们在生产环境中构建和运行智能体需要什么。
Build and run cloud agents with the Codex harness, fully managed by OpenAI.
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.
Today, we’re introducing the Agents API in public beta, bringing that same harness and infrastructure that powers Codex to developers through a simple, flexible API.
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.
“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.”
Jack Weissenberger, CTO, Ciridae

Agents API powers your agents with the same harness and infrastructure behind Codex.
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:
JSON
1import OpenAI from "openai";23const client = new OpenAI();45const 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});
What our customers are saying about Agents API
“Transforming real-world businesses means deploying AI into workflows of every shape. Agents API supplies the harness; the environment, context, and UX stay ours. With our AI platform Nexus we now stand up agents in hours across industries, from residential services to architecture.”
Rasmus Wissmann, CTO, Long Lake
“The Agents API has enabled us to think differently about how we can architect complex, multi-step workflows. We used to write prompt chains and manage our own set of tool calls, but now we can use agents directly in our code much like how Codex works on your laptop. It’s already helped us solve several problems that would’ve otherwise required us to build custom agent infrastructure.”
Cole Striler, Director of Engineering, WithCoverage
“After migrating our case review workflow to the Agents API, we saw a 60% reduction in cost per case, lower latency, and significantly improved token efficiency while maintaining existing performance.”
Bhavyansh Sabharwal, Member of Technical Staff, SafetyKit
“What stood out in our testing was how naturally the Agents API handled bursty workloads. We could fan out work across hundreds of agents, run them asynchronously, and collect the results later, without keeping infrastructure idle between peaks.”
Dmitry Khanukov, Co-founder & CTO, Dwelly
“Earning customers’ trust is critical in financial services. OpenAI’s Agents API enables us to build more reliable agents, giving customers the confidence to use them in production. By separating the agent harness from the sandbox, we reduced failed agent responses by 86%.”
Serhii Shchoholiev, Lead Engineer, Hypha
“The Agents API handled the implementation, independent review, remediation, and real-browser validation in a real, active repository. Overall, the agent’s engineering quality was very strong.”
Maks Operlejn, Senior ML Engineer, deepsense.ai
“At Nash, we deploy thousands of long-running AI agents that manage hundreds of millions of deliveries across global logistics networks. OpenAI’s Agents API gives us the durable session and orchestration layer we need for agents operating continuously in production managing context, recovery, and multi-step execution, while Nash provides the tools and execution environment that connect them to the physical world. This lets our agents reason, act, recover, and collaborate across complex workflows that can span hours or days. These agents are production infrastructure running mission-critical logistics operations for our partners.”
Aziz Alghunaim, Co-founder & CTO, Nash.ai
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.
We’re partnering with ecosystem providers , including Blaxel, Cloudflare, Daytona, DigitalOcean, E2B, Modal, Oracle, Runloop, and Vercel, to provide first-class integrations for a range of needs:
- Fully managed environments or deployments within your 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.

The Agents API offers first-class integrations with popular ecosystem providers.
OpenAI hosted sandboxes
For developers who want to get started quickly and scale efficiently, we’re also introducing the OpenAI hosted sandbox . This leverages the same sandboxing infrastructure that powers Codex and 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.
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:
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 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.
Help agents efficiently use more tools
The Agents API helps agents find the right tools and use them efficiently. Tool search 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 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.
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 , 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.
JSON
1"agent": {2 "model": "gpt-6-astra",3 "multi_agent": {4 "enabled": true,5 "max_concurrent_subagents": 3,6 }7}
Build on 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 .
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 .
Explore theAgents API overview to learn more, or follow thequickstart to get started and bring the harness behind Codex into your own agents.
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.