cd /news/ai-agents/openai-agents-api · home topics ai-agents article
[ARTICLE · art-126243] src=developers.openai.com ↗ pub= topic=ai-agents verified=true sentiment=· neutral

OpenAI Agents API

OpenAI released the Agents API, giving applications access to the Codex harness through an OpenAI-managed API that handles sessions, orchestration, context compaction, and recovery while the application supplies tools and selects the execution environment. Agents run in a sandbox where they can execute code, edit files, connect to MCP servers, and produce artifacts, with model usage billed at the selected model's API rates, OpenAI tools at standard rates, and OpenAI-hosted sandboxes at standard container rates. The API is built around four core concepts — Agent, Environment, Session, and Events and items — and the managed harness supports running commands and code, applying skills and instructions, connecting to external data via tools or MCP, steering the agent mid-task, summarizing prior work to manage the context window, delegating to subagents, and resuming a session where it left off.

read3 min views1 publishedSep 10, 2026
OpenAI Agents API
Image: Developers (auto-discovered)

The Agents API gives your application access to the Codex harness through an OpenAI-managed API.

OpenAI manages sessions, orchestration, context compaction, and recovery while your application provides tools and chooses its execution environment.

Agents can operate in a sandbox where they can execute code, edit files, connect to MCP servers, and produce artifacts.

Pricing #

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

Try an example #

Try these complete examples:

Explore complete applications:

Core concepts #

The Agents API is built around four main 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 durable 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

Start 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 starts a turn of work once the environment is ready.
  3. Follow progress. Stream output or use webhooks to learn when the agent finishes or needs 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 runs the agent and provisions and manages its sandbox. See environment options for setup and limitations.

What the managed harness provides #

The managed Codex harness supports:

  • Running commands and code in a sandbox.
  • Applying relevant skills and instructions.
  • Connecting to external data through tools or MCP.
  • Steering the agent while it works.
  • Summarizing previous work to manage its context window.
  • Breaking work into subtasks and delegating to subagents.
  • Resuming a session where it left off.

Check the quickstart prerequisites for API-key permissions and SDK setup. Configure these capabilities when you create a session:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40from 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)

For a runtime comparison, see the Agents overview.

The Agents API retains session state so you can continue work across turns without rebuilding the conversation context. You can delete sessions and published artifacts when you no longer need them. The Agents API currently supports data residency only in the United States and does not support Zero Data Retention (ZDR). Choosing 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.

── more in #ai-agents 4 stories · sorted by recency
── more on @openai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/openai-agents-api] indexed:0 read:3min 2026-09-10 ·