OpenAI 已在公开测试版中发布 Agents API。它为开发者提供了与运行 Codex 相同的 harness 和基础设施。OpenAI 负责托管和维护该 harness。开发者可以在 OpenAI 管理的沙箱、自己的基础设施或合作伙伴沙箱中运行智能体的计算。
它可以部署吗?可以。它已在公开测试版中面向所有开发者上线。数据仅限美国境内,且不支持零数据保留。
OpenAI 发布了什么
Agents API 是一项基于开源 Codex harness 构建的托管服务。OpenAI 团队表示,为 Work 扩展 Codex 和 ChatGPT 的过程揭示了长时间运行的智能体需要什么。它们需要一个能够管理上下文、高效使用工具并协调子智能体的 harness。它们还需要能够让它们可靠运行数天的基础设施。
官方文档围绕 4 个概念来组织该 API:
- Agent:模型、指令、工具以及可供其使用的 MCP 服务器。
- Environment:一个可选的沙箱,智能体在其中访问文件、加载技能并运行命令。
- Session:一个持久化的智能体实例,负责处理任务并响应输入。
- 事件与条目:发送给智能体的输入以及它产生的输出。
一个会话分 4 步运行。你创建会话并给它一个任务。然后你通过流式传输或 webhook 跟进进度。最后,你继续执行新任务或引导当前轮次。
一次 API 调用
OpenAI 的公告展示了一个通过单次调用创建的事故调查智能体:
import OpenAI from "openai";
const client = new OpenAI();
const session = await client.beta.agents.sessions.create({
agent: {
model: "gpt-6-astra",
tools: [
{
type: "mcp",
server_label: "observability",
transport: {
type: "http",
server_url: "https://observability.example.com/mcp",
},
},
],
multi_agent: { enabled: true, max_concurrent_subagents: 3 },
},
vault_ids: ["vault_YOUR_VAULT_ID"],
environment: {
type: "openai_hosted",
capability_directories: ["/workspace/capabilities/skills"],
},
input:
"Investigate service-api's elevated 5xx rate over the last 30 minutes. " +
"Delegate deployment, error, and dependency analysis to subagents. " +
"Save findings, evidence, and recommended mitigation in /workspace/outputs.",
}); 快速入门涵盖了 API 密钥权限和 SDK 设置。
智能体的运行位置
环境选择是主要的架构决策。Agents API 支持 3 种沙箱选项,也可以在没有沙箱的情况下运行。
- OpenAI 托管的沙箱:使用 Codex 和 ChatGPT 背后的沙箱基础设施。你可以用文件、软件包、技能和插件来配置它。
- 自托管:你在自己的环境中运行
codex exec-server。它使用受限密钥注册,并通过 WebSocket 连接。所有连接都是出站的。 - 合作伙伴沙箱:Blaxel、Cloudflare、Daytona、DigitalOcean、E2B、Modal、Oracle、Runloop 和 Vercel 均提供一等公民级集成。
Harness 负责处理的内容
OpenAI 与其模型一同维护该 harness,并在每次模型发布时提供带版本号的访问方式。
- 长会话:当会话接近其上限时,API 会自动压缩较早的上下文。开发者无需自行编写压缩逻辑。
- 高效工具使用:工具搜索仅在需要时加载工具定义。这降低了 token 用量和成本,同时保留了模型的缓存。程序化工具调用让智能体能够并行运行调用并串联操作。智能体在代码中筛选或合并结果,因此只有相关数据会返回上下文中。支持的工具包括 MCP、自定义函数以及网页搜索等内置工具。
- 子智能体:借助多智能体支持,主智能体将复杂任务拆分为相互独立的部分。每个子智能体保留自己的上下文。主智能体协调它们并合并结果。
Agents API 与 Agents SDK 与 Responses API 对比
OpenAI 的 运行时对比对这三种方案做了如下定位:
| Agents API | Agents SDK | Responses API | |
|---|---|---|---|
| 智能体运行位置 | OpenAI 运行托管的 Codex harness | 在你的应用程序内部 | 你的应用程序,可选托管编排 |
| 集成工作量 | 低 | 中 | 高 |
| 任务之间的状态 | 保存的会话配置、轮次和条目 | 你的存储和 SDK 会话 | 手动历史记录、响应链式调用或 Conversations |
| 执行环境 | OpenAI 托管、自托管,或无沙箱 | 你的运行时和沙箱提供商 | 你自己的环境 |
早期客户成果
OpenAI 发布了这些由客户报告的数据。它们由厂商提供,并非独立基准测试。
- Ciridae:评估分数从 0.71 升至 0.85,子智能体流程的延迟降低了 4 倍。
- SafetyKit:迁移其案件审查工作流后,每案件成本降低 60%。
- Hypha:将 harness 与沙箱分离后,智能体响应失败率降低 86%。
- Nash.ai:在全球物流网络中运行数千个长时间运行的智能体。
核心要点
- OpenAI 的 Agents API 将托管的 Codex harness 作为公开测试版 API 开放。
- 智能体可在 OpenAI 托管、自托管或 9 个合作伙伴沙箱中运行。
- 压缩、工具搜索、程序化工具调用和子智能体均为内置功能。
- 不收取额外费用;你只需为 token、工具和容器时间付费。
- 目前仅限美国数据驻留,且不支持 ZDR,这限制了对受监管工作负载的支持。
OpenAI has released the Agents API in public beta. It gives developers the same harness and infrastructure that run Codex. OpenAI hosts and maintains the harness. Developers run the agent’s compute in an OpenAI-managed sandbox, their own infrastructure, or a partner sandbox.
Is it deployable? Yes. It is live for all developers in public beta. Data stays US-only, and Zero Data Retention is unsupported.
What OpenAI Shipped
The Agents API is a managed service built on the open-source Codex harness. OpenAI team states scaling Codex and ChatGPT for Work showed what long-running agents need. They need a harness that manages context, uses tools efficiently, and coordinates subagents. They also need infrastructure that keeps them running reliably for days.
The official docs organize the API around 4 concepts:
- Agent: the model, instructions, tools, and MCP servers available to it.
- Environment: an optional sandbox where the agent accesses files, loads skills, and runs commands.
- Session: a durable agent instance that works on tasks and responds to input.
- Events and items: the inputs sent to the agent and the output it produces.
A session runs in 4 steps. You create it and give it a task. Then you follow progress through streaming or webhooks. Finally, you continue with a new task or steer the current turn.
One API Call
OpenAI’s announcement shows an incident-investigation agent created in a single call:
import OpenAI from "openai";
const client = new OpenAI();
const session = await client.beta.agents.sessions.create({
agent: {
model: "gpt-6-astra",
tools: [
{
type: "mcp",
server_label: "observability",
transport: {
type: "http",
server_url: "https://observability.example.com/mcp",
},
},
],
multi_agent: { enabled: true, max_concurrent_subagents: 3 },
},
vault_ids: ["vault_YOUR_VAULT_ID"],
environment: {
type: "openai_hosted",
capability_directories: ["/workspace/capabilities/skills"],
},
input:
"Investigate service-api's elevated 5xx rate over the last 30 minutes. " +
"Delegate deployment, error, and dependency analysis to subagents. " +
"Save findings, evidence, and recommended mitigation in /workspace/outputs.",
}); The quickstart covers API key permissions and SDK setup.
Where the Agent Runs
Environment choice is the main architectural decision. The Agents API supports 3 sandbox options, and it can also run without a sandbox.
- OpenAI-hosted sandbox: uses the sandboxing infrastructure behind Codex and ChatGPT. You can configure it with files, packages, skills, and plugins.
- Self-hosted: you run
codex exec-serverinside your environment. It registers with a restricted key and connects over WebSocket. All connections are outbound. - Partner sandboxes: Blaxel, Cloudflare, Daytona, DigitalOcean, E2B, Modal, Oracle, Runloop, and Vercel have first-class integrations.
What the Harness Handles
OpenAI maintains the harness alongside its models, with versioned access at each model launch.
- Long sessions: The API automatically compacts earlier context as a session nears its limit. Developers do not write their own compaction logic.
- Efficient tool use: Tool search loads tool definitions only when needed. This reduces token usage and cost while preserving the model’s cache. Programmatic tool calling lets agents run calls in parallel and chain operations. Agents filter or combine results in code, so only relevant data returns into context. Supported tools include MCP, custom functions, and built-in tools like web search.
- Subagents: With multi-agent support, the main agent splits complex tasks into independent pieces. Each subagent keeps its own context. The main agent coordinates them and combines the results.
Agents API vs Agents SDK vs Responses API
OpenAI’s runtime comparison positions the 3 options this way:
| Agents API | Agents SDK | Responses API | |
|---|---|---|---|
| Where the agent runs | OpenAI runs a managed Codex harness | Inside your application | Your application, with optional hosted orchestration |
| Integration effort | Low | Medium | High |
| State between tasks | Saved session configuration, turns, and items | Your storage and SDK sessions | Manual history, response chaining, or Conversations |
| Execution environment | OpenAI-hosted, self-hosted, or no sandbox | Your runtime and sandbox providers | Your own environment |
Early Customer Results
OpenAI published these customer-reported numbers. They are vendor-supplied, not independent benchmarks.
- Ciridae: evaluation score rose from 0.71 to 0.85, with a 4x latency reduction on subagent flows.
- SafetyKit: 60% lower cost per case after migrating its case review workflow.
- Hypha: 86% fewer failed agent responses after separating the harness from the sandbox.
- Nash.ai: runs thousands of long-running agents across global logistics networks.
Key Takeaways
- OpenAI’s Agents API exposes the managed Codex harness as a public beta API.
- Agents run in OpenAI-hosted, self-hosted, or 9 partner sandboxes.
- Compaction, tool search, programmatic tool calling, and subagents come built in.
- There is no extra fee; you pay for tokens, tools, and container time.
- US-only data residency and no ZDR limit regulated workloads for now.