{"slug": "openai-agents-api", "title": "OpenAI Agents API", "summary": "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.", "body_md": "The Agents API gives your application access to the Codex harness through an OpenAI-managed API.\n\nOpenAI manages sessions, orchestration, context compaction, and recovery while your application provides tools and chooses its execution environment.\n\nAgents can operate in a sandbox where they can execute code, edit files, connect to MCP servers, and produce artifacts.\n\n## Pricing\n\nModel usage is billed at the selected model’s [API rates](/api/docs/pricing). OpenAI tools use their [standard rates](/api/docs/pricing#built-in-tools), and OpenAI-hosted sandboxes use standard [container rates](/api/docs/pricing#built-in-tools).\n\n## Try an example\n\nTry these complete examples:\n\n- [Create and run a directory-tree script](/api/docs/guides/agents-api/quickstart#1-run-a-task) in an OpenAI-hosted sandbox.\n- [Compare release notes with subagents](/api/docs/guides/agents-api/multi-agent#example-compare-release-notes) and combine their findings into one answer.\n\nExplore complete applications:\n\n- [Incident response agent](/showcase/agents-api-sev-bot) : investigate alerts and request approval for recovery actions.\n- [Slack bot](/showcase/agents-api-slack-bot) : investigate requests using connected workplace tools.\n- [Data analyst](/showcase/agents-api-data-analyst) : answer warehouse questions with read-only SQL.\n- [GitHub issue investigator](/showcase/agents-api-github-issues) : reproduce reported bugs and share findings on GitHub.\n- [Document reviewer](/showcase/agents-api-document-review) : review documents with policy skills and specialist agents.\n\n## Core concepts\n\nThe Agents API is built around four main concepts:\n\n- **Agent:** The model, instructions, tools, and MCP servers available to the agent.\n- **Environment:** An optional sandbox or computer where the agent accesses files, loads skills, and runs commands.\n- **Session:** A durable instance of an agent that works on tasks and responds to input.\n- **Events and items:** The inputs sent to an agent and the output produced during a session.\n\n### A session from start to finish\n\nStart with an OpenAI-hosted sandbox in the [quickstart](/api/docs/guides/agents-api/quickstart):\n\n1. **Create a session.** Configure the agent; OpenAI provisions its environment.\n2. **Give it a task.** User input starts a turn of work once the environment is ready.\n3. **Follow progress.** Stream output or use webhooks to learn when the agent finishes or needs input.\n4. **Continue or steer.** Send another task to the same session, or guide the agent during its current turn.\n\nWith 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](/api/docs/guides/agents-api/configuration#environment-settings) for setup and limitations.\n\n## What the managed harness provides\n\nThe managed Codex harness supports:\n\n- Running commands and code in a sandbox.\n- Applying relevant skills and instructions.\n- Connecting to external data through tools or MCP.\n- Steering the agent while it works.\n- Summarizing previous work to manage its context window.\n- Breaking work into subtasks and delegating to subagents.\n- Resuming a session where it left off.\n\nCheck the [quickstart prerequisites](/api/docs/guides/agents-api/quickstart#prerequisites) for API-key permissions and SDK setup. Configure these capabilities when you create a session:\n\n```\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40from openai import OpenAI\n\nclient = OpenAI()\n\nsession = client.beta.agents.sessions.create(\n    agent={\n        \"model\": \"gpt-6-astra\",\n        \"instructions\": \"Use the OpenAI documentation MCP and web search to answer technical questions accurately. Delegate independent research tasks to subagents when useful.\",\n        \"tools\": [\n            {\"type\": \"programmatic_tool_calling\"},\n            {\n                \"type\": \"mcp\",\n                \"server_label\": \"openai_docs\",\n                \"transport\": {\n                    \"type\": \"http\",\n                    \"server_url\": \"https://developers.openai.com/mcp\",\n                },\n            },\n            {\"type\": \"web_search\"},\n        ],\n        \"multi_agent\": {\"enabled\": True, \"max_concurrent_subagents\": 4},\n    },\n    environment={\n        \"type\": \"self_hosted\",\n        \"workspace_directory\": \"/workspace\",\n        \"capability_directories\": [\"/workspace/capabilities/skills\"],\n    },\n    input=[\n        {\n            \"role\": \"user\",\n            \"content\": [\n                {\n                    \"type\": \"input_text\",\n                    \"text\": \"Research how to connect an MCP server to an OpenAI agent, check for recent updates, and summarize the recommended setup.\",\n                }\n            ],\n        }\n    ],\n)\nprint(session.id)\n```\n\nFor a runtime comparison, see the [Agents overview](/api/docs/guides/agents#compare-agent-runtimes).\n\nThe Agents API retains session state so you can continue work across turns without\nrebuilding the conversation context. You can delete sessions and published\nartifacts when you no longer need them.\nThe Agents API currently supports data residency only in the United States and\ndoes not support Zero Data Retention (ZDR). Choosing a self-hosted sandbox does\nnot make the Agents API ZDR-eligible. See [Data controls\nin the OpenAI platform](/api/docs/guides/your-data#storage-requirements-and-retention-controls-per-endpoint)\nfor details on data residency and retention.", "url": "https://wpnews.pro/news/openai-agents-api", "canonical_source": "https://developers.openai.com/api/docs/guides/agents-api/overview", "published_at": "2026-09-10 19:43:22+00:00", "updated_at": "2026-09-10 21:12:35.242144+00:00", "lang": "en", "topics": ["ai-agents", "ai-products", "ai-tools", "developer-tools", "ai-infrastructure"], "entities": ["OpenAI", "Agents API", "Codex", "MCP", "gpt-6-astra", "Slack", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/openai-agents-api", "markdown": "https://wpnews.pro/news/openai-agents-api.md", "text": "https://wpnews.pro/news/openai-agents-api.txt", "jsonld": "https://wpnews.pro/news/openai-agents-api.jsonld"}}