All guides
OpenAI

Agents

Checked 09/15/2026View original
On this page

For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.

Agents can plan and complete tasks using tools, work with other agents, and maintain context across steps. Choose a runtime based on where you want orchestration to run and who should manage the state between tasks.

Choose your starting point

You want toStart here
Run an agent with the Codex harness managed by OpenAIAgents API
Control the agent loop in your application with reusable agents, tools, and handoffsAgents SDK
Work directly with model responses and control your integrationResponses API
Add an embedded chat experienceChatKit

Compare agent runtime options

Agents APIAgents SDKResponses API
Use forLong-running tasks where OpenAI manages the agent and saves its progressBuilding agents with custom tools and workflows in your applicationCalling models directly or building an agent from scratch
Where the agent runsOpenAI runs a managed Codex harnessThe SDK runs inside your applicationYour application, with optional hosted orchestration
Agent integration effortLowMediumHigh
State between tasksSaved session configuration, turns, and itemsYour storage and SDK sessions, or Responses conversation stateManual history, response chaining, or Conversations
Tool executionService-connected tools, application function handlers, and an optional sandboxTools and integrations configured in your applicationHosted tools and tools your application runs
Execution environmentOpenAI hosted sandbox, self-hosted sandbox, or no sandboxYour runtime and sandbox provider integrationsYour own execution environment
Start hereAgents API overviewAgents SDK overviewResponses guide

The Agents API runs the Codex harness and manages the underlying agent infrastructure so you can focus on what your agents do. It includes automatic context compaction, multi-agent orchestration, programmatic tool calling, and support for MCP servers. See Architecture.

The Agents SDK gives your application control over deployment, storage, approvals, and runtime integration. Its runner handles the agent loop and handoffs. See Running agents.

Add tools, skills, and prompt caching

Tool design, reusable skills, and prompt caching apply across agent workflows. Their configuration and lifecycle can differ by API.

An Agents API session, an SDK session, a Responses conversation, and a sandbox are different resources. Follow the state and cleanup instructions for the runtime you choose.