FRIDAY, SEPTEMBER 11, 2026|No. 14572
technology · artificial-intelligence

OpenAI Launches Agents API for Enhanced Automation

OpenAI has introduced its new Agents API, allowing developers to integrate advanced automation capabilities into their applications through a managed harness.

A visual representation of AI agents interacting within a digital network.
A visual representation of AI agents interacting within a digital network. · Photo by Igor Omilaev on Unsplash
1 sources
Pipeline ingest
3 reads
Positive / Neutral / Negative
0 countries
Related coverage

The Agents API provides your application with access to the Codex harness through an OpenAI-managed API. OpenAI handles sessions, orchestration, context compaction, and recovery, while your application supplies tools and selects its execution environment.

Agents can operate within a sandbox, enabling them to execute code, edit files, connect to MCP servers, and produce artifacts.

Pricing

Model usage is billed according to the selected model's API rates. OpenAI tools use their standard rates, and OpenAI-hosted sandboxes use standard container rates.

Try an example

Explore these complete examples:

Explore complete applications:

Core concepts

The Agents API is structured around four primary concepts:

  • Agent: The model, instructions, tools, and MCP servers available to the agent.
  • Environment: An optional sandbox or computer where the agent accesses files, loads skills, and runs commands.
  • Session: A persistent instance of an agent that works on tasks and responds to input.
  • Events and items: The inputs sent to an agent and the output produced during a session.

A session from start to finish

Begin with an OpenAI-hosted sandbox in the quickstart:

  1. Create a session. Configure the agent; OpenAI provisions its environment.
  2. Give it a task. User input initiates a turn of work once the environment is ready.
  3. Follow progress. Stream output or use webhooks to track when the agent completes its work or requires input.
  4. Continue or steer. Send another task to the same session, or guide the agent during its current turn.

With an OpenAI-hosted session, your application sends input and receives events, while OpenAI executes the agent and manages its sandbox. Refer to environment options for setup and limitations.

Your application initiates sessions and receives events and output from the Agents API. OpenAI operates the managed Codex harness and provisions and manages its sandbox.

What the managed harness provides

The managed Codex harness supports:

  • Running commands and code within a sandbox.
  • Applying relevant skills and instructions.
  • Connecting to external data via tools or MCP.
  • Steering the agent during its operation.
  • Summarizing previous work to manage its context window.
  • Decomposing work into subtasks and delegating to subagents.
  • Resuming a session from its previous state.

Consult the quickstart prerequisites for API-key permissions and SDK setup. Configure these capabilities when creating a session:

Configure managed-harness capabilities

Python

import OpenAI from "openai";

const client = new OpenAI();

const session = await client.beta.agents.sessions.create({
 agent: {
 model: "gpt-6-astra",
 instructions:
 "Use the OpenAI documentation MCP and web search to answer technical questions accurately. Delegate independent research tasks to subagents when useful.",
 tools: [
 { type: "programmatic_tool_calling" },
 {
 type: "mcp",
 server_label: "openai_docs",
 transport: {
 type: "http",
 server_url: "https://developers.openai.com/mcp",
 },
 },
 { type: "web_search" },
 ],
 multi_agent: { enabled: true, max_concurrent_subagents: 4 },
 },
 environment: {
 type: "self_hosted",
 workspace_directory: "/workspace",
 capability_directories: ["/workspace/capabilities/skills"],
 },
 input: [
 {
 role: "user",
 content: [
 {
 type: "input_text",
 text: "Research how to connect an MCP server to an OpenAI agent, check for recent updates, and summarize the recommended setup.",
 },
 ],
 },
 ],
});
console.log(session.id);
from openai import OpenAI

client = OpenAI()

session = client.beta.agents.sessions.create(
 agent={
 "model": "gpt-6-astra",
 "instructions": "Use the OpenAI documentation MCP and web search to answer technical questions accurately. Delegate independent research tasks to subagents when useful.",
 "tools": [
 {"type": "programmatic_tool_calling"},
 {
 "type": "mcp",
 "server_label": "openai_docs",
 "transport": {
 "type": "http",
 "server_url": "https://developers.openai.com/mcp",
 },
 },
 {"type": "web_search"},
 ],
 "multi_agent": {"enabled": True, "max_concurrent_subagents": 4},
 },
 environment={
 "type": "self_hosted",
 "workspace_directory": "/workspace",
 "capability_directories": ["/workspace/capabilities/skills"],
 },
 input=[
 {
 "role": "user",
 "content": [
 {
 "type": "input_text",
 "text": "Research how to connect an MCP server to an OpenAI agent, check for recent updates, and summarize the recommended setup.",
 }
 ],
 }
 ],
)
print(session.id)
import (
 "context"
 "fmt"
 "github.com/openai/openai-go/v3"
)

ctx := context.Background()
client := openai.NewClient()
session, err := client.Beta.Agents.Sessions.New(ctx, openai.BetaAgentSessionNewParams{Agent: openai.BetaAgentSessionNewParamsAgent{Model: openai.String("gpt-6-astra"),
 Instructions: openai.String("Use the OpenAI documentation MCP and web search to answer technical questions accurately. Delegate independent research tasks to subagents when useful."),
 Tools: []openai.AgentToolParamUnion{openai.AgentToolParamUnion{OfParamProgrammaticToolCalling: &openai.AgentToolParamProgrammaticToolCalling{}},
 openai.AgentToolParamUnion{OfParamMcp: &openai.AgentToolParamMcp{ServerLabel: "openai_docs",
 Transport: openai.McpTransportParamUnion{OfParamHTTP: &openai.McpTransportParamHTTP{ServerURL: "https://developers.openai.com/mcp"}}}},
 openai.AgentToolParamUnion{OfParamWebSearch: &openai.AgentToolParamWebSearch{}}},
 MultiAgent: openai.MultiAgentConfigParam{Enabled: true,
 MaxConcurrentSubagents: openai.Int(4)}}
 Environment: openai.EnvironmentParamUnion{OfParamSelfHosted: &openai.EnvironmentParamSelfHosted{WorkspaceDirectory: "/workspace",
 CapabilityDirectories: []string{"/workspace/capabilities/skills"}}},
 Input: openai.BetaAgentSessionNewParamsInputUnion{OfArrayOfInputMessages: []openai.AgentSessionInputMessageParam{openai.AgentSessionInputMessageParam{Content: []openai.InputContentParamUnion{openai.InputContentParamUnion{OfParamInputText: &openai.InputContentParamInputText{Text: "Research how to connect an MCP server to an OpenAI agent, check for recent updates, and summarize the recommended setup."}}}}}}})
if err != nil {
 panic(err)
}
fmt.Println(session.ID)
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.agents.AgentToolParam;
import com.openai.models.beta.agents.EnvironmentParam;
import com.openai.models.beta.agents.McpTransportParam;
import com.openai.models.beta.agents.MultiAgentConfigParam;
import com.openai.models.beta.agents.sessions.SessionCreateParams;
import java.util.List;

OpenAIClient client = OpenAIOkHttpClient.fromEnv();
var session =
 client
 .beta()
 .agents()
 .sessions()
 .create(
 SessionCreateParams.builder()
 .agent(
 SessionCreateParams.Agent.builder()
 .model("gpt-6-astra")
 .instructions(
 "Use the OpenAI documentation MCP and web search to answer"
 + " technical questions accurately. Delegate independent"
 + " research tasks to subagents when useful.")
 .addTool(AgentToolParam.ProgrammaticToolCalling.builder().build())
 .addTool(
 AgentToolParam.Mcp.builder()
 .serverLabel("openai_docs")
 .transport(
 McpTransportParam.Http.builder()
 .serverUrl("https://developers.openai.com/mcp")
 .build())
 .build())
 .addTool(AgentToolParam.WebSearch.builder().build())
 .multiAgent(
 MultiAgentConfigParam.builder()
 .enabled(true)
 .maxConcurrentSubagents(4L)
 .build())
 .build())
 .environment(
 EnvironmentParam.SelfHosted.builder()
 .workspaceDirectory("/workspace")
 .capabilityDirectories(List.of("/workspace/capabilities/skills"))
 .build())
 .input(
 "Research how to connect an MCP server to an OpenAI agent, check for recent"
 + " updates, and summarize the recommended setup.")
 .build());
System.out.println(session.id());
require "openai"

client = OpenAI::Client.new

session = client.beta.agents.sessions.create(agent: {model: "gpt-6-astra",
 instructions: "Use the OpenAI documentation MCP and web search to answer technical questions accurately. Delegate independent research tasks to subagents when useful.",
 tools: [{type: "programmatic_tool_calling"},
 {type: "mcp",
 server_label: "openai_docs",
 transport: {type: "http",
 server_url: "https://developers.openai.com/mcp"}},
 {type: "web_search"}],
 multi_agent: {enabled: true,
 max_concurrent_subagents: 4}},
 environment: {type: "self_hosted",
 workspace_directory: "/workspace",
 capability_directories: ["/workspace/capabilities/skills"]},
 input: [{role: "user",
 content: [{type: "input_text",
 text: "Research how to connect an MCP server to an OpenAI agent, check for recent updates, and summarize the recommended setup."}]}
])
puts session.id
curl -sS -X POST "https://api.openai.com/v1/agents/sessions" \
 -H "OpenAI-Beta: agents=v1" \
 -H "Authorization: Bearer $OPENAI_API_KEY" \
 -H "Content-Type: application/json" \
 -d '{
 "agent": {
 "model": "gpt-6-astra",
 "instructions": "Use the OpenAI documentation MCP and web search to answer technical questions accurately. Delegate independent research tasks to subagents when useful.",
 "tools": [
 {
 "type": "programmatic_tool_calling"
 },
 {
 "type": "mcp",
 "server_label": "openai_docs",
 "transport": {
 "type": "http",
 "server_url": "https://developers.openai.com/mcp"
 }
 },
 {
 "type": "web_search"
 }
 ],
 "multi_agent": {
 "enabled": true,
 "max_concurrent_subagents": 4
 }
 },
 "environment": {
 "type": "self_hosted",
 "workspace_directory": "/workspace",
 "capability_directories": ["/workspace/capabilities/skills"]
 },
 "input": [
 {
 "role": "user",
 "content": [
 {
 "type": "input_text",
 "text": "Research how to connect an MCP server to an OpenAI agent, check for recent updates, and summarize the recommended setup."
 }
 ]
 }
 ]
 }'

For a runtime comparison, see the Agents overview.

The Agents API preserves session state, allowing you to continue work across turns without rebuilding the conversation context. You can delete sessions and published artifacts when they are no longer needed.

The Agents API currently supports data residency only in the United States and does not support Zero Data Retention (ZDR). Selecting a self-hosted sandbox does not make the Agents API ZDR-eligible. See Data controls in the OpenAI platform for details on data residency and retention.

PAN's pipeline reviewed approximately 1 open sources for this article. No human editor reviewed this article before publication.

Related Reads

Show on timeline →