Thanks to visit codestin.com
Credit goes to developers.openai.com

Primary navigation

Evaluation

Agents SDK

Build agents in code with the OpenAI Agents SDK and grow into more advanced runtime patterns as needed.

Agents are applications that plan, call tools, collaborate across specialists, and keep enough state to complete multi-step work.

Get your first agent running

Start with the Agents SDK quickstart to install the SDK, define one agent, and run it. Once that works, return here to choose the next capability your application needs.

Get the Agents SDK

Use the GitHub repositories for more examples, issues, and language-specific reference details.

Choose your starting point

If you want toStart hereWhy
Build a code-first agent appQuickstartThis is the shortest path to a working SDK integration.
Define one specialist cleanlyAgent definitionsStart here when you are still shaping the contract for a single agent.
Choose models, defaults, and transportModels and providersUse this when model choice, provider setup, or transport strategy affects the workflow.
Understand the runtime loop and stateRunning agentsThis is where the agent loop, streaming, and continuation strategies live.
Run work in a container-based environmentSandbox agentsUse this when the agent needs files, commands, packages, snapshots, mounts, or provider links.
Design specialist ownershipOrchestration and handoffsUse this when you need more than one agent and must decide who owns the reply.
Add validation or human reviewGuardrails and human reviewUse this when the workflow should block or pause before risky work continues.
Understand what a run returnsResults and stateThis page explains final output, resumable state, and next-turn surfaces.
Add hosted tools, function tools, or MCPUsing tools and Integrations and observabilityTool semantics live in the platform tools docs; SDK-specific MCP and tracing live here.
Inspect and improve runsIntegrations and observability and evaluate agent workflowsUse traces for debugging first, then move into evaluation loops.
Build a voice-first workflowVoice agentsUse the SDK’s voice pipeline and realtime agent patterns.

Build with the SDK

Use the SDK track when your server owns deployment, tool implementations, state storage, and approval decisions, while the SDK runs the agent loop and invokes those tools. That path is the best fit when you want:

  • typed application code in TypeScript or Python
  • direct control over tools, MCP servers, and runtime behavior
  • custom storage or server-managed conversation strategies
  • tight integration with existing product logic or infrastructure

A typical SDK reading order is:

Agents SDK vs. Responses API

Use the Responses API when you want to own the loop. Use the Agents SDK when you want the SDK to run it.

Choose the Responses API when

  • You want direct control over model interactions, output items, tools, state, and orchestration, whether the workflow takes one call or many.
  • You want to implement custom tool routing, loops, or branching directly in your application.

In the Responses function-calling flow, your application receives function calls, executes them, returns their output, and calls the model again.

For example, a Responses API workflow might search a knowledge base and generate a cited answer.

Choose the Agents SDK when

  • You want the SDK to manage the agent loop and recurring orchestration such as repeated tool calls or branching.
  • Different specialists need different instructions, tools, or policies.
  • You want built-in sessions, tracing, guardrails, or resumable approval flows.

The Agents SDK runner performs the tool loop, switches agents after handoffs, and stops when the run finishes or pauses for approval.

For example, an Agents SDK workflow might investigate a support request, hand it to the correct specialist, call internal systems, request approval for a refund, and record the result.

Compare the Responses API and Agents SDK

Responses APIAgents SDK
Best forCustom model-powered features and workflowsBounded conversational or transactional workflows with defined tools and recurring orchestration patterns
Core abstractionA model responseAn agent run
ToolsPlatform tools, function calling, and remote Model Context Protocol (MCP)Platform tools attached to reusable agents, plus tool wrappers, local MCP connections, and agents as tools
Workflow orchestrationYou manage custom loops and branchingThe SDK provides the agent loop and lifecycle
Multi-agent workflowsBuild routing and delegation yourselfBuilt-in agents-as-tools and handoffs
StateManual history, response chaining, or ConversationsThe same options, plus SDK sessions and resumable run state
Safety and approvalsTool-specific approvals; you build broader controlsInput, output, and tool guardrails plus resumable approval flows
Debugging and tracingResponse objects and API logsBuilt-in traces across model calls, tools, agents, guardrails, and handoffs