SpyBara
Go Premium

Documentation 2026-09-24 23:58 UTC to 2026-09-25 23:58 UTC

24 files changed +119 −232. View all changes and history on the product overview
2026
Tue 29 22:57 Mon 28 22:57 Sat 26 23:59 Fri 25 23:58 Thu 24 23:58 Wed 23 23:58 Tue 22 23:57 Mon 21 23:00 Sat 19 23:00 Fri 18 22:59 Thu 17 10:04 Wed 16 20:58 Tue 15 22:59 Mon 14 22:58 Sun 13 15:02 Fri 11 20:00 Thu 10 18:01 Wed 9 23:59 Sat 5 17:01 Fri 4 23:59 Thu 3 23:00 Wed 2 22:59

deprecations.md +1 −1

Details

118| June 3, 2026 | Deprecation announced for Agent Builder. |118| June 3, 2026 | Deprecation announced for Agent Builder. |

119| Nov 30, 2026 | Agent Builder is scheduled to shut down. |119| Nov 30, 2026 | Agent Builder is scheduled to shut down. |

120 120 

121See [Migrate from Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder/migrate-from-agent-builder) to evaluate the Agents API, ChatGPT Workspace Agents, or an existing Agents SDK integration.121See [Migrate from Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder/migrate-from-agent-builder) to continue with the Agents SDK or ChatGPT Workspace Agents.

122 122 

123### 2026-06-02: GPT Image model deprecations123### 2026-06-02: GPT Image model deprecations

124 124 

Details

12 page](https://developers.openai.com/api/docs/deprecations#2026-06-03-agent-builder) for the current12 page](https://developers.openai.com/api/docs/deprecations#2026-06-03-agent-builder) for the current

13 timeline.13 timeline.

14 14 

15This guide covers existing Agent Builder workflows during the transition window. For new agent applications, start with the [Agents API](https://developers.openai.com/api/docs/guides/agents-api/quickstart). For an existing workflow, follow [Migrate from Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder/migrate-from-agent-builder).15Use this guide to learn the process and parts of building agents.

16 16 

17## Agents and workflows17## Agents and workflows

18 18 


28 28 

29 29 

30 30 

31Follow these three main steps to build agents that handle tasks:31There are three main steps in building agents to handle tasks:

32 32 

331. Design a workflow in [Agent Builder](https://platform.openai.com/agent-builder). This defines your agents and how they'll work.331. Design a workflow in [Agent Builder](https://platform.openai.com/agent-builder). This defines your agents and how they'll work.

341. Publish your workflow. It's an object with an ID and versioning.341. Publish your workflow. It's an object with an ID and versioning.


40 40 

41### Examples and templates41### Examples and templates

42 42 

43Agent Builder provides templates for common workflow patterns. Start with a template to see how nodes work together, or create a workflow without a template.43Agent Builder provides templates for common workflow patterns. Start with a template to see how nodes work together, or start from scratch.

44 44 

45Here's a homework helper workflow. It uses agents to take questions, rephrase them for better answers, route them to other specialized agents, and return an answer.45Here's a homework helper workflow. It uses agents to take questions, reframe them for better answers, route them to other specialized agents, and return an answer.

46 46 

47![prompts chat](https://cdn.openai.com/API/docs/images/homework-helper2.png)47![prompts chat](https://cdn.openai.com/API/docs/images/homework-helper2.png)

48 48 


64 64 

65## Publish your workflow65## Publish your workflow

66 66 

67Agent Builder saves your work automatically as you go. When you're happy with your workflow, publish it to create a new major version that acts as a snapshot. You can then use your workflow in [ChatKit](https://developers.openai.com/api/docs/guides/chatkit), an OpenAI framework for embedding chat experiences.67Agent Builder autosaves your work as you go. When you're happy with your workflow, publish it to create a new major version that acts as a snapshot. You can then use your workflow in [ChatKit](https://developers.openai.com/api/docs/guides/chatkit), an OpenAI framework for embedding chat experiences.

68 68 

69You can create new versions or specify an older version in your API calls.69You can create new versions or specify an older version in your API calls.

70 70 


72 72 

73When you're ready to implement the agent workflow you created, click **Code** in the top navigation. You have two options for implementing your workflow in production:73When you're ready to implement the agent workflow you created, click **Code** in the top navigation. You have two options for implementing your workflow in production:

74 74 

75**Existing hosted integration**: Continue using ChatKit with your workflow ID during the transition window. See [ChatKit](https://developers.openai.com/api/docs/guides/chatkit) for hosted integration details and custom server options.75**ChatKit**: Follow the [ChatKit quickstart](https://developers.openai.com/api/docs/guides/chatkit) and pass in your workflow ID to embed this workflow into your application. If you're not sure, we recommend this option.

76 76 

77**Advanced integration**: Export Agents SDK code for an existing SDK integration or use it as a reference when recreating the workflow with the Agents API. The [migration guide](https://developers.openai.com/api/docs/guides/agent-builder/migrate-from-agent-builder) explains the options and limitations. A custom ChatKit server connects your chat interface to the chosen backend.77**Advanced integration**: Copy the workflow code and use it anywhere. You can run ChatKit on your own infrastructure and use the Agents SDK to build and customize agent chat experiences.

78 78 

79## Next steps79## Next steps

80 80 

81Review the migration options to plan how your application will run after the transition window.81Now that you've created an agent workflow, bring it into your product with ChatKit.

82 82 

83- [Migrate from Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder/migrate-from-agent-builder) →83- [ChatKit quickstart](https://developers.openai.com/api/docs/guides/chatkit) →

84- [ChatKit integration options](https://developers.openai.com/api/docs/guides/chatkit) →

85- [Advanced integration](https://developers.openai.com/api/docs/guides/custom-chatkit) →84- [Advanced integration](https://developers.openai.com/api/docs/guides/custom-chatkit) →

Details

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5Use this guide to export an existing Agent Builder workflow as Agents SDK code.5Use this guide to export an existing Agent Builder workflow as Agents SDK code.

6Use the export as a reference when recreating the workflow with the Agents API or as a ChatGPT Workspace Agent, or continue with an existing Agents SDK integration.6You can use the export to recreate the workflow as a ChatGPT Workspace Agent or

7continue with the Agents SDK in your application.

7 8 

8This process does not convert your workflow graph or guarantee that every9This process does not convert your workflow graph or guarantee that every

9behavior transfers unchanged.10behavior transfers unchanged.

10 11 

11## Choose a migration path12## Choose a migration path

12 13 

13- **Agents API**: Recommended for new agent applications. Recreate the workflow using a managed Codex harness; the SDK export is a reference, not directly executable Agents API code.14- **Agents SDK**: Best for building agents through code.

14- **Agents SDK**: Use the export for an existing SDK application or as a short-term option when a required capability is not yet supported by the Agents API. See [SDK support guidance](#continue-with-the-agents-sdk).

15- **ChatGPT Workspace Agents**: Best for building agents through natural15- **ChatGPT Workspace Agents**: Best for building agents through natural

16 language and sharing them with teams.16 language and sharing them with teams.

17 17 


29 29 

30![Agent Builder Code dialog with Agents SDK selected](https://developers.openai.com/images/platform/guides/agent-builder/agents-sdk-export.png)30![Agent Builder Code dialog with Agents SDK selected](https://developers.openai.com/images/platform/guides/agent-builder/agents-sdk-export.png)

31 31 

32## Recreate the workflow with the Agents API32## Option 1: Continue with the Agents SDK

33 33 

34Start with the [Agents API quickstart](https://developers.openai.com/api/docs/guides/agents-api/quickstart), then use the export to identify instructions, tools, state, and control flow. Check whether the Agents API supports the capabilities your workflow requires before recreating the graph and SDK code manually.34Use this option when you want to run the exported workflow in an application

35 35you build and deploy.

36Validate tool permissions, approvals, guardrails, and representative workflow results before replacing the original workflow.

37 

38<a id="option-1-continue-with-the-agents-sdk"></a>

39 

40## Continue with the Agents SDK

41 

42 

43 

44The Agents SDK is [feature

45 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance, security

46 fixes, critical bug fixes, and compatibility work continue, but major new

47 features are not planned. For new agent applications, start with the [Agents

48 API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

49 

50 

51 

52Use this option for an existing SDK application or as a short-term option when a required capability is not yet supported by the Agents API.

53 36 

54Copy the TypeScript or Python export into your application, install and37Copy the TypeScript or Python export into your application, install and

55configure the matching Agents SDK, and test the workflow in your runtime. For38configure the matching Agents SDK, and test the workflow in your runtime. For

56guidance on configuring and running the export, see the39guidance on configuring and running the export, see the

57[Agents SDK overview](https://developers.openai.com/api/docs/guides/agents/sdk) and40[Agents SDK overview](https://developers.openai.com/api/docs/guides/agents) and

58[quickstart](https://developers.openai.com/api/docs/guides/agents/quickstart).41[quickstart](https://developers.openai.com/api/docs/guides/agents/quickstart).

59Validate your application's configuration and behavior before deploying it.42Validate your application's configuration and behavior before deploying it.

60 43 

61<a id="option-2-create-a-workspace-agent-from-the-export"></a>44## Option 2: Create a workspace agent from the export

62 

63## Create a workspace agent from the export

64 45 

65To use this option, you need a ChatGPT Business, Enterprise, or Edu workspace46To use this option, you need a ChatGPT Business, Enterprise, or Edu workspace

66with access to [workspace agents](https://chatgpt.com/agents) and permission to47with access to [workspace agents](https://chatgpt.com/agents) and permission to


110 91 

111- [Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder)92- [Agent Builder](https://developers.openai.com/api/docs/guides/agent-builder)

112- [Safety in building agents](https://developers.openai.com/api/docs/guides/agent-builder-safety)93- [Safety in building agents](https://developers.openai.com/api/docs/guides/agent-builder-safety)

113- [Agents SDK overview](https://developers.openai.com/api/docs/guides/agents/sdk)94- [Agents SDK overview](https://developers.openai.com/api/docs/guides/agents)

114- [Agents SDK quickstart](https://developers.openai.com/api/docs/guides/agents/quickstart)95- [Agents SDK quickstart](https://developers.openai.com/api/docs/guides/agents/quickstart)

115- [Build workspace agents in ChatGPT for repeatable work](https://developers.openai.com/cookbook/articles/chatgpt-agents-sales-meeting-prep)96- [Build workspace agents in ChatGPT for repeatable work](https://developers.openai.com/cookbook/articles/chatgpt-agents-sales-meeting-prep)

Details

6 6 

7Use this page as the decision point for the evaluation surfaces that matter most for agent workflows.7Use this page as the decision point for the evaluation surfaces that matter most for agent workflows.

8 8 

9The trace-grading workflow below uses **Logs** > **Traces** for Agents SDK applications and existing Agent Builder workflows. For Agents API session traces, use **Logs** > **Agents** and follow [Agents API tracing](https://developers.openai.com/api/docs/guides/agents-api/tracing).

10 

11## Start with traces when you are still debugging behavior9## Start with traces when you are still debugging behavior

12 10 

13Trace grading is the fastest way to identify workflow-level issues. A trace captures the end-to-end record of model calls, tool calls, guardrails, and handoffs for one run. Graders let you score those traces with structured criteria so you can find regressions and failure modes at scale.11Trace grading is the fastest way to identify workflow-level issues. A trace captures the end-to-end record of model calls, tool calls, guardrails, and handoffs for one run. Graders let you score those traces with structured criteria so you can find regressions and failure modes at scale.

guides/agents.md +17 −20

Details

2 2 

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5For new agent applications, start with the **[Agents API](https://developers.openai.com/api/docs/guides/agents-api/overview)**. OpenAI runs the Codex harness and manages orchestration, context compaction, and durable sessions. You build the surrounding application, connect tools, and choose where execution happens.5Agents 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.

6 

7Follow the [Agents API quickstart](https://developers.openai.com/api/docs/guides/agents-api/quickstart) to run a task, stream progress, and continue a session.

8 6 

9## Choose your starting point7## Choose your starting point

10 8 

11| You want to | Start here |9| You want to | Start here |

12| --- | --- |10| ------------------------------------------------------------------------------------ | ------------------------------------------------------ |

13| Build a new agent application with a managed runtime | [Agents API quickstart](https://developers.openai.com/api/docs/guides/agents-api/quickstart) |11| Run an agent with the Codex harness managed by OpenAI | [Agents API](https://developers.openai.com/api/docs/guides/agents-api/quickstart) |

14| Run the Codex harness in infrastructure you operate | [Codex SDK](https://developers.openai.com/codex/codex-sdk) |12| Control the agent loop in your application with reusable agents, tools, and handoffs | [Agents SDK](https://developers.openai.com/api/docs/guides/agents/quickstart) |

15| Call models directly or own the agent loop | [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses) |13| Work directly with model responses and control your integration | [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses) |

14| Add an embedded chat experience | [ChatKit](https://developers.openai.com/api/docs/guides/chatkit) |

16 15 

17<a id="agents-sdk-vs-responses-api"></a>16<a id="agents-sdk-vs-responses-api"></a>

18 17 


20 19 

21## Compare agent runtime options20## Compare agent runtime options

22 21 

23Choose based on what OpenAI manages and what your application needs to control.22| | Agents API | Agents SDK | Responses API |

23| ------------------------ | ------------------------------------------------------------------------------- | ------------------------------------------------------------------- | --------------------------------------------------------- |

24| **Use for** | Long-running tasks where OpenAI manages the agent and saves its progress | Building agents with custom tools and workflows in your application | Calling models directly or building an agent from scratch |

25| Where the agent runs | OpenAI runs a managed Codex harness | The SDK runs inside your application | Your application, with optional hosted orchestration |

26| Agent integration effort | Low | Medium | High |

27| State between tasks | Saved session configuration, turns, and items | Your storage and SDK sessions, or Responses conversation state | Manual history, response chaining, or Conversations |

28| Tool execution | Service-connected tools, application function handlers, and an optional sandbox | Tools and integrations configured in your application | Hosted tools and tools your application runs |

29| Execution environment | OpenAI hosted sandbox, self-hosted sandbox, or no sandbox | Your runtime and sandbox provider integrations | Your own execution environment |

30| Start here | [Agents API overview](https://developers.openai.com/api/docs/guides/agents-api/overview) | [Agents SDK overview](https://developers.openai.com/api/docs/guides/agents/sdk) | [Responses guide](https://developers.openai.com/api/docs/guides/migrate-to-responses) |

24 31 

25| Option | What it manages | What you operate |32The 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](https://developers.openai.com/api/docs/guides/agents-api/architecture).

26| --- | --- | --- |

27| **Agents API** | Hosted Codex harness, orchestration, and durable session state | Your application, tool integrations, and choice of execution environment |

28| **Codex SDK** | Codex harness running in your environment | The harness process, hosting, and application lifecycle |

29| **Responses API** | Model responses and configured hosted capabilities | Application logic and any agent loop you build around the API |

30 33 

31Use the [Agents API architecture guide](https://developers.openai.com/api/docs/guides/agents-api/architecture) to understand the boundary between the hosted harness and your execution environment. For direct model integrations, the Responses API also offers hosted tools and state through response chaining or Conversations; follow its guides for the capabilities you use.34The Agents SDK gives your application control over deployment, storage, approvals, and runtime integration. Its runner handles the agent loop and handoffs. See [Running agents](https://developers.openai.com/api/docs/guides/agents/running-agents).

32 35 

33 36 

34 37 


43- Read [Prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching) for shared caching behavior, then [Agents API observability and usage](https://developers.openai.com/api/docs/guides/agents-api/observability) for session accounting.46- Read [Prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching) for shared caching behavior, then [Agents API observability and usage](https://developers.openai.com/api/docs/guides/agents-api/observability) for session accounting.

44 47 

45An 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.48An 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.

46 

47## If you use the Agents SDK

48 

49The [Agents SDK](https://developers.openai.com/api/docs/guides/agents/sdk) is **feature complete**: major new features are not planned, but maintenance, security fixes, critical bug fixes, and compatibility work continue. You can continue using it for existing applications. See also: [SDK support policy](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice).

50 

51For new agent applications, start with the [Agents API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

Details

2 2 

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5The Agents SDK is [feature

6 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance, security

7 fixes, critical bug fixes, and compatibility work continue, but major new

8 features are not planned. For new agent applications, start with the [Agents

9 API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

10 

11 

12 

13An agent is the core unit of an SDK-based workflow. It packages a model, instructions, and optional runtime behavior such as tools, guardrails, MCP servers, handoffs, and structured outputs.5An agent is the core unit of an SDK-based workflow. It packages a model, instructions, and optional runtime behavior such as tools, guardrails, MCP servers, handoffs, and structured outputs.

14 6 

15## What belongs on an agent7## What belongs on an agent

Details

2 2 

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5The Agents SDK is [feature

6 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance, security

7 fixes, critical bug fixes, and compatibility work continue, but major new

8 features are not planned. For new agent applications, start with the [Agents

9 API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

10 

11 

12 

13Use guardrails for automatic checks and human review for approval decisions. Together, they define when a run should continue, pause, or stop.5Use guardrails for automatic checks and human review for approval decisions. Together, they define when a run should continue, pause, or stop.

14 6 

15- **Guardrails** validate input, output, or tool behavior automatically.7- **Guardrails** validate input, output, or tool behavior automatically.

Details

2 2 

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5The Agents SDK is [feature

6 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance, security

7 fixes, critical bug fixes, and compatibility work continue, but major new

8 features are not planned. For new agent applications, start with the [Agents

9 API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

10 

11 

12 

13After the workflow shape is clear, the next questions are which external surfaces should live inside the agent loop and how you will inspect what actually happened at runtime.5After the workflow shape is clear, the next questions are which external surfaces should live inside the agent loop and how you will inspect what actually happened at runtime.

14 6 

15## Choose what lives in the SDK7## Choose what lives in the SDK

Details

2 2 

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5The Agents SDK is [feature

6 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance, security

7 fixes, critical bug fixes, and compatibility work continue, but major new

8 features are not planned. For new agent applications, start with the [Agents

9 API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

10 

11 

12 

13Every SDK run eventually resolves a model and a transport. Most applications should keep that setup straightforward: choose models explicitly, use the standard OpenAI path by default, and reach for provider or transport overrides only when the workflow actually needs them.5Every SDK run eventually resolves a model and a transport. Most applications should keep that setup straightforward: choose models explicitly, use the standard OpenAI path by default, and reach for provider or transport overrides only when the workflow actually needs them.

14 6 

15## Start with explicit model selection7## Start with explicit model selection

Details

2 2 

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5The Agents SDK is [feature

6 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance, security

7 fixes, critical bug fixes, and compatibility work continue, but major new

8 features are not planned. For new agent applications, start with the [Agents

9 API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

10 

11 

12 

13Multi-agent workflows are useful when specialists should own different parts of the job. The first design choice is deciding who owns the final user-facing answer at each branch of the workflow.5Multi-agent workflows are useful when specialists should own different parts of the job. The first design choice is deciding who owns the final user-facing answer at each branch of the workflow.

14 6 

15## Choose the orchestration pattern7## Choose the orchestration pattern

Details

1# Agents SDK quickstart1# Quickstart

2 2 

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5The Agents SDK is [feature

6 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance, security

7 fixes, critical bug fixes, and compatibility work continue, but major new

8 features are not planned. For new agent applications, start with the [Agents

9 API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

10 

11 

12 

13Use this page when you want the shortest path to a working SDK-based agent. The examples below use the same high-level concepts in both JavaScript and Python: define an agent, run it, then add tools and specialist agents as your workflow grows.5Use this page when you want the shortest path to a working SDK-based agent. The examples below use the same high-level concepts in both JavaScript and Python: define an agent, run it, then add tools and specialist agents as your workflow grows.

14 6 

15## Install the SDK7## Install the SDK

Details

2 2 

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5The Agents SDK is [feature

6 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance, security

7 fixes, critical bug fixes, and compatibility work continue, but major new

8 features are not planned. For new agent applications, start with the [Agents

9 API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

10 

11 

12 

13When you run an agent, the result is more than just the final answer. It's also the handoff boundary, the next-turn continuation surface, and the resumable snapshot when a run pauses for review.5When you run an agent, the result is more than just the final answer. It's also the handoff boundary, the next-turn continuation surface, and the resumable snapshot when a run pauses for review.

14 6 

15## Choose the result surface you need7## Choose the result surface you need

Details

2 2 

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5The Agents SDK is [feature

6 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance, security

7 fixes, critical bug fixes, and compatibility work continue, but major new

8 features are not planned. For new agent applications, start with the [Agents

9 API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

10 

11 

12 

13Defining an agent is only the setup step. The runtime questions are what a single run does, how the next turn continues, and how the workflow behaves when it pauses for approvals or tool work.5Defining an agent is only the setup step. The runtime questions are what a single run does, how the next turn continues, and how the workflow behaves when it pauses for approvals or tool work.

14 6 

15## The agent loop7## The agent loop


26 18 

27## Choose one conversation strategy19## Choose one conversation strategy

28 20 

29Choose from four common ways to carry state into the next turn:21There are four common ways to carry state into the next turn:

30 22 

31| Strategy | Where state lives | Best for | What you pass on the next turn |23| Strategy | Where state lives | Best for | What you pass on the next turn |

32| ------------------------------------------------------------------------------------------------------------------ | ------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------- |24| ------------------------------------------------------------------------------------------------------------------ | ------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------- |

Details

2 2 

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5The Agents SDK is [feature

6 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance, security

7 fixes, critical bug fixes, and compatibility work continue, but major new

8 features are not planned. For new agent applications, start with the [Agents

9 API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

10 

11 

12 

13A sandbox gives an agent an isolated, Unix-like execution environment with a5A sandbox gives an agent an isolated, Unix-like execution environment with a

14filesystem, shell, installed packages, mounted data, exposed ports, snapshots,6filesystem, shell, installed packages, mounted data, exposed ports, snapshots,

15and controlled access to external systems.7and controlled access to external systems.

Details

2 2 

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5## Important notice5Agents can plan and complete tasks using tools, work with other agents, and maintain context across steps.

6 

7The Agents SDK is **feature complete**. Maintenance, security fixes, critical bug fixes, and compatibility work continue, but major new features are not planned. For new agent applications, we recommend the **[Agents API](https://developers.openai.com/api/docs/guides/agents-api/quickstart)**, which runs a managed Codex harness.

8 

9You can continue using the Agents SDK for existing applications. For new applications that require capabilities the Agents API does not yet support, the SDK remains a short-term option.

10 

11## Overview

12 

13The OpenAI Agents SDK is an open-source framework for building agent workflows in application code. It builds on [Swarm](https://github.com/openai/swarm), released in 2024 to explore lightweight multi-agent orchestration, and brought those ideas into a framework for production applications with guardrails and built-in tracing. The [Python SDK](https://github.com/openai/openai-agents-python) launched in March 2025, followed by the [TypeScript SDK](https://github.com/openai/openai-agents-js) in June 2025.

14 

15Its agent loop runs in your application, coordinating calls to OpenAI and other models through the Responses and Chat Completions APIs with tool execution, including MCP server tools. Session management preserves conversation context across runs. Human approvals let your application pause tool execution for review.

16 

17For multi-agent workflows, agents can call other agents as tools or transfer control through handoffs. The SDK also supports [realtime voice agents](https://developers.openai.com/api/docs/guides/voice-agents) for low-latency spoken interactions and [sandbox agents](https://developers.openai.com/api/docs/guides/agents/sandboxes) for working with files and commands. These capabilities let you combine text, voice, and sandbox agents within a broader application workflow.

18 6 

19## Get your first agent running7## Get your first agent running

20 8 


43 31 

44| If you want to | Start here | Why |32| If you want to | Start here | Why |

45| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- |33| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- |

46| Set up an Agents SDK integration | [Quickstart](https://developers.openai.com/api/docs/guides/agents/quickstart) | This is the shortest path to a working SDK integration. |34| Build a code-first agent app | [Quickstart](https://developers.openai.com/api/docs/guides/agents/quickstart) | This is the shortest path to a working SDK integration. |

47| Define one specialist cleanly | [Agent definitions](https://developers.openai.com/api/docs/guides/agents/define-agents) | Start here when you are still shaping the contract for a single agent. |35| Define one specialist cleanly | [Agent definitions](https://developers.openai.com/api/docs/guides/agents/define-agents) | Start here when you are still shaping the contract for a single agent. |

48| Choose models, defaults, and transport | [Models and providers](https://developers.openai.com/api/docs/guides/agents/models) | Use this when model choice, provider setup, or transport strategy affects the workflow. |36| Choose models, defaults, and transport | [Models and providers](https://developers.openai.com/api/docs/guides/agents/models) | Use this when model choice, provider setup, or transport strategy affects the workflow. |

49| Understand the runtime loop and state | [Running agents](https://developers.openai.com/api/docs/guides/agents/running-agents) | This is where the agent loop, streaming, and continuation strategies live. |37| Understand the runtime loop and state | [Running agents](https://developers.openai.com/api/docs/guides/agents/running-agents) | This is where the agent loop, streaming, and continuation strategies live. |


57 45 

58## Build with the SDK46## Build with the SDK

59 47 

60In an Agents SDK application, your server manages deployment, tool implementations, state storage, and approval decisions. The SDK runs the agent loop and invokes tools. These guides cover:48Use 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:

61 49 

62- typed application code in TypeScript or Python50- typed application code in TypeScript or Python

63- direct control over tools, MCP servers, and runtime behavior51- direct control over tools, MCP servers, and runtime behavior


75 63 

76## Compare agent runtime options64## Compare agent runtime options

77 65 

78Use the [Agents overview](https://developers.openai.com/api/docs/guides/agents#compare-agent-runtimes) to compare the Agents API, Codex SDK, and Responses API. The Agents SDK runs in your application; the Agents API runs a managed harness in OpenAI's service.66Use the [Agents overview](https://developers.openai.com/api/docs/guides/agents#compare-agent-runtimes) to compare the Agents SDK, Agents API, and Responses API. The Agents SDK runs in your application; the Agents API runs a managed harness in OpenAI's service.

Details

10 10 

11Choose between two ChatKit paths:11Choose between two ChatKit paths:

12 12 

13- **Custom server integration**. Run ChatKit on your own infrastructure. Use the ChatKit Python SDK and connect to any agentic service, including one built with the [Agents SDK](https://developers.openai.com/api/docs/guides/agents/sdk). Use widgets to build the frontend.13- **Custom server integration**. Run ChatKit on your own infrastructure. Use the ChatKit Python SDK and connect to any agentic service, including one built with the [Agents SDK](https://developers.openai.com/api/docs/guides/agents). Use widgets to build the frontend.

14- **Existing Agent Builder-hosted integration**. If you already use ChatKit with an Agent Builder workflow, you can keep using that hosted workflow during the Agent Builder transition window.14- **Existing Agent Builder-hosted integration**. If you already use ChatKit with an Agent Builder workflow, you can keep using that hosted workflow during the Agent Builder transition window.

15 15 

16OpenAI is deprecating Agent Builder. Existing users can continue using it16OpenAI is deprecating Agent Builder. Existing users can continue using it

Details

5When you need full control—custom authentication, data residency, on‑prem deployment, or bespoke agent orchestration—you can run ChatKit on your own infrastructure. Use OpenAI's advanced self‑hosted option to use your own server and customized ChatKit.5When you need full control—custom authentication, data residency, on‑prem deployment, or bespoke agent orchestration—you can run ChatKit on your own infrastructure. Use OpenAI's advanced self‑hosted option to use your own server and customized ChatKit.

6 6 

7Agent Builder-hosted ChatKit workflows are in a transition window. For new7Agent Builder-hosted ChatKit workflows are in a transition window. For new

8 ChatKit apps, use a custom server integration with the ChatKit SDKs. This8 ChatKit apps, build on your own server-side agent implementation with the

9 guide uses ChatKit's Agents SDK adapter. The Agents SDK is [feature9 ChatKit SDKs and the Agents SDK. See [ChatKit transition guidance

10 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance10 →](https://developers.openai.com/api/docs/guides/chatkit)

11 continues, but major new features are not planned. See [ChatKit transition

12 guidance →](https://developers.openai.com/api/docs/guides/chatkit).

13 11 

14## Run ChatKit on your own infrastructure12## Run ChatKit on your own infrastructure

15 13 

Details

102 102 

103![Function Calling Diagram Steps](https://cdn.openai.com/API/docs/images/function-calling-diagram-steps.png)103![Function Calling Diagram Steps](https://cdn.openai.com/API/docs/images/function-calling-diagram-steps.png)

104 104 

105With Responses, your application can continue this flow for as many tool calls as the task requires. For a managed agent loop, start with the [Agents API](https://developers.openai.com/api/docs/guides/agents-api/quickstart). See the [runtime comparison](https://developers.openai.com/api/docs/guides/agents#compare-agent-runtimes) when you need a different level of control.105With Responses, your application can continue this flow for as many tool calls as the task requires. If you want a framework that packages recurring orchestration around that loop, see [how the Responses API compares with the Agents SDK](https://developers.openai.com/api/docs/guides/agents#agents-sdk-vs-responses-api).

106 106 

107## Function tool example107## Function tool example

108 108 

Details

3347 3347 

3348Use the response's `usage` to measure token consumption for your prompts, sizes, and quality settings. Equal token rates don't mean equal cost per image: token consumption can differ by model and quality setting. For older-model pricing examples, see [Earlier GPT Image models](#earlier-gpt-image-models).3348Use the response's `usage` to measure token consumption for your prompts, sizes, and quality settings. Equal token rates don't mean equal cost per image: token consumption can differ by model and quality setting. For older-model pricing examples, see [Earlier GPT Image models](#earlier-gpt-image-models).

3349 3349 

3350### Cached input pricing

3351 

3352For GPT Image 2 and GPT Image 2.5, cached input pricing applies only to the image generation tool in the Responses API. It doesn't apply to direct Images API requests, including `/v1/images/edits`.

3353 

3354Cached image generation inputs are reflected in billing, but their cached token counts aren't included in the Responses API output. The response's `usage` can't verify these cache hits.

3355 

3350 3356 

3351 3357 

3352 3358 

guides/tools.md +2 −12

Details

4 4 

5When generating model responses or building agents, you can extend capabilities using built‑in tools, function calling, Programmatic Tool Calling, tool search, and remote MCP servers. These enable the model to search the web, retrieve from your files, load deferred tool definitions at runtime, call your own functions, compose tool calls in JavaScript, or access third‑party services. Only `gpt-5.4` and later models support `tool_search`.5When generating model responses or building agents, you can extend capabilities using built‑in tools, function calling, Programmatic Tool Calling, tool search, and remote MCP servers. These enable the model to search the web, retrieve from your files, load deferred tool definitions at runtime, call your own functions, compose tool calls in JavaScript, or access third‑party services. Only `gpt-5.4` and later models support `tool_search`.

6 6 

7For new agent applications, start with the [Agents API](https://developers.openai.com/api/docs/guides/agents-api/quickstart). Choose the tool integration for your runtime: configure tools on [Responses API requests](#usage-in-the-api), on [Agents API agents](#agents-api), or in [Agents SDK definitions](#usage-in-the-agents-sdk). Tool availability, configuration, and call handling depend on the integration. The examples below use the Responses API.7Choose the integration for your runtime: configure tools on [Responses API requests](#usage-in-the-api), on [Agents API agents](#agents-api), or in [Agents SDK definitions](#usage-in-the-agents-sdk). Tool availability, configuration, and call handling depend on the integration. The examples below use the Responses API.

8 8 

9 9 

10 10 


1085 1085 

1086## Usage in the Agents SDK1086## Usage in the Agents SDK

1087 1087 

1088 1088In the Agents SDK, the tool semantics stay the same, but the wiring moves into the agent definition and workflow design rather than a single Responses API request.

1089 

1090The Agents SDK is [feature

1091 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance, security

1092 fixes, critical bug fixes, and compatibility work continue, but major new

1093 features are not planned. For new agent applications, start with the [Agents

1094 API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

1095 

1096 

1097 

1098For existing SDK integrations, the tool semantics stay the same, but the wiring moves into the agent definition and workflow design rather than a single Responses API request.

1099 1089 

1100- Attach hosted tools, function tools, or hosted MCP tools directly on the agent when one specialist should call them itself.1090- Attach hosted tools, function tools, or hosted MCP tools directly on the agent when one specialist should call them itself.

1101- Expose a specialist as a tool when a manager should stay in control of the user-facing reply.1091- Expose a specialist as a tool when a manager should stay in control of the user-facing reply.

Details

8 8 

9Use both features to track, analyze, and optimize the performance of groups of agents.9Use both features to track, analyze, and optimize the performance of groups of agents.

10 10 

11The trace-grading workflow below uses **Logs** > **Traces** for Agents SDK applications and existing Agent Builder workflows. For Agents API session traces, use **Logs** > **Agents** and follow [Agents API tracing](https://developers.openai.com/api/docs/guides/agents-api/tracing).

12 

13## Get started with traces11## Get started with traces

14 12 

151. In the dashboard, navigate to Logs > [Traces](https://platform.openai.com/logs?api=traces).131. In the dashboard, navigate to Logs > [Traces](https://platform.openai.com/logs?api=traces).

Details

137 137 

138## Voice agents still use the same core agent building blocks138## Voice agents still use the same core agent building blocks

139 139 

140Choose the audio architecture first. If you use an Agents SDK voice workflow, the following SDK guides cover its supporting capabilities:140The voice surface changes the transport and audio loop, but the core workflow decisions are the same:

141 141 

142- Use [Using tools](https://developers.openai.com/api/docs/guides/tools#usage-in-the-agents-sdk) when the voice agent needs external capabilities.142- Use [Using tools](https://developers.openai.com/api/docs/guides/tools#usage-in-the-agents-sdk) when the voice agent needs external capabilities.

143- Use [Running agents](https://developers.openai.com/api/docs/guides/agents/running-agents) when spoken workflows need streaming, continuation, or durable state.143- Use [Running agents](https://developers.openai.com/api/docs/guides/agents/running-agents) when spoken workflows need streaming, continuation, or durable state.


145- Use [Guardrails and human review](https://developers.openai.com/api/docs/guides/agents/guardrails-approvals) when spoken workflows need safety checks or approvals.145- Use [Guardrails and human review](https://developers.openai.com/api/docs/guides/agents/guardrails-approvals) when spoken workflows need safety checks or approvals.

146- Use [Integrations and observability](https://developers.openai.com/api/docs/guides/agents/integrations-observability) when you need MCP-backed capabilities or want to inspect how the voice workflow behaved.146- Use [Integrations and observability](https://developers.openai.com/api/docs/guides/agents/integrations-observability) when you need MCP-backed capabilities or want to inspect how the voice workflow behaved.

147 147 

148The practical rule is: choose the audio architecture first, then design the rest of the agent workflow the same way you would for text.

149 

148## Next steps150## Next steps

149 151 

150[Audio and voice overview152[Audio and voice overview

libraries.md +11 −18

Details

2 2 

3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

4 4 

5This page covers the main ways to build with the [OpenAI API](https://developers.openai.com/api/reference/overview): official SDKs for application code, the OpenAI CLI for shell-native workflows, or your own preferred HTTP client. For new agent applications, use the [Agents API](https://developers.openai.com/api/docs/guides/agents-api/quickstart) through the official OpenAI SDKs.5This page covers the main ways to build with the [OpenAI API](https://developers.openai.com/api/reference/overview): official SDKs for application code, the OpenAI CLI for shell-native workflows, the Agents SDK for orchestration, or your own preferred HTTP client.

6 6 

7## Create and export an API key7## Create and export an API key

8 8 


173<dependency>173<dependency>

174 <groupId>com.openai</groupId>174 <groupId>com.openai</groupId>

175 <artifactId>openai-java</artifactId>175 <artifactId>openai-java</artifactId>

176 <version>4.69.2</version>176 <version>4.69.3</version>

177</dependency>177</dependency>

178```178```

179 179 


359 359 

360 360 

361 361 

362<a id="use-the-agents-sdk"></a>362## Use the Agents SDK

363 363 

364## Agents SDK364Use the official OpenAI SDKs above for direct API requests. Use the Agents SDK

365when your application needs code-first orchestration for agents, tools,

366handoffs, guardrails, tracing, or sandbox execution.

365 367 

366 368If you are deciding between direct API requests and code-first orchestration,

367 369see [how the Responses API compares with the Agents SDK](https://developers.openai.com/api/docs/guides/agents#agents-sdk-vs-responses-api).

368The Agents SDK is [feature

369 complete](https://developers.openai.com/api/docs/guides/agents/sdk#important-notice): maintenance, security

370 fixes, critical bug fixes, and compatibility work continue, but major new

371 features are not planned. For new agent applications, start with the [Agents

372 API](https://developers.openai.com/api/docs/guides/agents-api/quickstart).

373 

374 

375 

376The Agents API uses the official OpenAI SDKs above. You can continue using the separate Agents SDK for existing applications. For new applications that require capabilities the Agents API does not yet support, the SDK is a short-term option. See the [runtime comparison](https://developers.openai.com/api/docs/guides/agents#compare-agent-runtimes).

377 370 

378[Agents SDK quickstart371[Agents SDK quickstart

379 372 

380 373 

381 374 

382 Set up an integration for an application that needs the Agents SDK.](https://developers.openai.com/api/docs/guides/agents/quickstart)375 Build your first agent with the Agents SDK.](https://developers.openai.com/api/docs/guides/agents/quickstart)

383 376 

384- [OpenAI Agents SDK for TypeScript](https://github.com/openai/openai-agents-js)377- [OpenAI Agents SDK for TypeScript](https://github.com/openai/openai-agents-js)

385- [OpenAI Agents SDK for Python](https://github.com/openai/openai-agents-python)378- [OpenAI Agents SDK for Python](https://github.com/openai/openai-agents-python)


407 400 

408### Dart/Flutter401### Dart/Flutter

409 402 

410- [`openai`](https://github.com/anasfik/openai) by [anasfik](https://github.com/anasfik)403- [openai](https://github.com/anasfik/openai) by [anasfik](https://github.com/anasfik)

411 404 

412### Delphi405### Delphi

413 406 


451## Other OpenAI repositories444## Other OpenAI repositories

452 445 

453- [tiktoken](https://github.com/openai/tiktoken) - counting tokens446- [tiktoken](https://github.com/openai/tiktoken) - counting tokens

454- [`simple-evals`](https://github.com/openai/simple-evals) - evaluation library447- [simple-evals](https://github.com/openai/simple-evals) - simple evaluation library

455- [mle-bench](https://github.com/openai/mle-bench) - library to evaluate machine learning engineer agents448- [mle-bench](https://github.com/openai/mle-bench) - library to evaluate machine learning engineer agents

456- [gym](https://github.com/openai/gym) - reinforcement learning library449- [gym](https://github.com/openai/gym) - reinforcement learning library

457- [swarm](https://github.com/openai/swarm) - educational orchestration repository450- [swarm](https://github.com/openai/swarm) - educational orchestration repository

quickstart.md +50 −41

Details

190<dependency>190<dependency>

191 <groupId>com.openai</groupId>191 <groupId>com.openai</groupId>

192 <artifactId>openai-java</artifactId>192 <artifactId>openai-java</artifactId>

193 <version>4.69.2</version>193 <version>4.69.3</version>

194</dependency>194</dependency>

195```195```

196 196 


382 382 

383 383 

384 384 

385 Start with the Agents API to build agents with a managed Codex harness.](https://developers.openai.com/api/docs/guides/agents-api/quickstart)385 Use the Agents SDK to build, run, and observe agent workflows.](https://developers.openai.com/api/docs/guides/agents)

386 386 

387## Analyze images and files387## Analyze images and files

388 388 


2151 2151 

2152## Build agents2152## Build agents

2153 2153 

2154For new agent applications, start with the [Agents API](https://developers.openai.com/api/docs/guides/agents-api/overview). OpenAI manages the Codex harness, sessions, and orchestration while your application provides tools and chooses where execution happens.2154Use the OpenAI platform to build [agents](https://developers.openai.com/api/docs/guides/agents) capable of taking action—like [controlling computers](https://developers.openai.com/api/docs/guides/tools-computer-use)—on behalf of your users. Use the [Agents SDK](https://developers.openai.com/api/docs/guides/agents) to create orchestration logic on your server.

2155 2155 

2156This example creates an OpenAI-hosted sandbox and asks the agent to write and run a Python script. Follow the [Agents API prerequisites](https://developers.openai.com/api/docs/guides/agents-api/quickstart#prerequisites) for API-key permissions and SDK setup. The Agents API is in beta; these examples use the standard OpenAI client libraries.2156Build a language triage agent

2157 

2158Create and run a directory-tree script

2159 2157 

2160```javascript2158```javascript

2161import OpenAI from "openai";2159import { Agent, run } from "@openai/agents";

2162 2160 

2163const client = new OpenAI();2161const spanishAgent = new Agent({

2164const events = await client.beta.agents.sessions.create({2162 name: "Spanish agent",

2165 agent: {2163 instructions: "You only speak Spanish.",

2166 model: "gpt-6-astra",

2167 instructions: "Write clean code, run it, and report the actual output.",

2168 },

2169 environment: { type: "openai_hosted" },

2170 input:

2171 "Create tree.py, a Python script that prints a readable tree of the files in the current directory. Run it and show me the output.",

2172 stream: true,

2173});2164});

2174try {2165 

2175 for await (const event of events) {2166const englishAgent = new Agent({

2176 console.log(JSON.stringify(event));2167 name: "English agent",

2177 }2168 instructions: "You only speak English",

2178} finally {2169});

2179 events.controller.abort();2170 

2180}2171const triageAgent = new Agent({

2172 name: "Triage agent",

2173 instructions:

2174 "Handoff to the appropriate agent based on the language of the request.",

2175 handoffs: [spanishAgent, englishAgent],

2176});

2177 

2178const result = await run(triageAgent, "Hola, ¿cómo estás?");

2179console.log(result.finalOutput);

2181```2180```

2182 2181 

2183```python2182```python

2184from openai import OpenAI2183from agents import Agent, Runner

2184import asyncio

2185 

2186spanish_agent = Agent(

2187 name="Spanish agent",

2188 instructions="You only speak Spanish.",

2189)

2190 

2191english_agent = Agent(

2192 name="English agent",

2193 instructions="You only speak English",

2194)

2195 

2196triage_agent = Agent(

2197 name="Triage agent",

2198 instructions="Handoff to the appropriate agent based on the language of the request.",

2199 handoffs=[spanish_agent, english_agent],

2200)

2185 2201 

2186with OpenAI() as client:

2187 with client.beta.agents.sessions.create(

2188 agent={

2189 "model": "gpt-6-astra",

2190 "instructions": "Write clean code, run it, and report the actual output.",

2191 },

2192 environment={"type": "openai_hosted"},

2193 input="Create tree.py, a Python script that prints a readable tree of the files in the current directory. Run it and show me the output.",

2194 stream=True,

2195 ) as events:

2196 for event in events:

2197 print(event.to_json(indent=None), flush=True)

2198```

2199 2202 

2203async def main():

2204 result = await Runner.run(triage_agent, input="Hola, ¿cómo estás?")

2205 print(result.final_output)

2206 

2207 

2208if __name__ == "__main__":

2209 asyncio.run(main())

2210```

2200 2211 

2201The stream includes progress and output events. Check the [terminal result](https://developers.openai.com/api/docs/guides/agents-api/quickstart#2-follow-progress), save the session ID for follow-up work, and [delete the session](https://developers.openai.com/api/docs/guides/agents-api/quickstart#4-clean-up) when you no longer need it. Closing the stream does not delete the session.

2202 2212 

2203[Build agents that can take action2213[Build agents that can take action

2204 2214 

2205 2215 

2206 2216 

2207 Follow the Agents API quickstart to run a task, continue the session, and2217 Learn how to use the OpenAI platform to build powerful, capable AI agents.](https://developers.openai.com/api/docs/guides/agents)

2208 clean up.](https://developers.openai.com/api/docs/guides/agents-api/quickstart)