SpyBara
Go Premium

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

41 files changed +578 −1,011. 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 continue with the Agents SDK or ChatGPT Workspace Agents.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.

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 

15Use this guide to learn the process and parts of building agents.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).

16 16 

17## Agents and workflows17## Agents and workflows

18 18 


28 28 

29 29 

30 30 

31There are three main steps in building agents to handle tasks:31Follow these three main steps to build agents that 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 start from scratch.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.

44 44 

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.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.

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 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.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.

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**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.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.

76 76 

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.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.

78 78 

79## Next steps79## Next steps

80 80 

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

82 82 

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

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

84- [Advanced integration](https://developers.openai.com/api/docs/guides/custom-chatkit) →85- [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.

6You can use the export to recreate the workflow as a ChatGPT Workspace Agent or6Use 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.

7continue with the Agents SDK in your application.

8 7 

9This process does not convert your workflow graph or guarantee that every8This process does not convert your workflow graph or guarantee that every

10behavior transfers unchanged.9behavior transfers unchanged.

11 10 

12## Choose a migration path11## Choose a migration path

13 12 

14- **Agents SDK**: Best for building agents through code.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**: 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## Option 1: Continue with the Agents SDK32## Recreate the workflow with the Agents API

33 33 

34Use this option when you want to run the exported workflow in an application34Start 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.

35you build and deploy.35 

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.

36 53 

37Copy the TypeScript or Python export into your application, install and54Copy the TypeScript or Python export into your application, install and

38configure the matching Agents SDK, and test the workflow in your runtime. For55configure the matching Agents SDK, and test the workflow in your runtime. For

39guidance on configuring and running the export, see the56guidance on configuring and running the export, see the

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

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

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

43 60 

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

62 

63## Create a workspace agent from the export

45 64 

46To use this option, you need a ChatGPT Business, Enterprise, or Edu workspace65To use this option, you need a ChatGPT Business, Enterprise, or Edu workspace

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


91 110 

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

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

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

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

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

9## Start with traces when you are still debugging behavior11## Start with traces when you are still debugging behavior

10 12 

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.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.

guides/agents.md +20 −17

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 

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.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.

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.

6 8 

7## Choose your starting point9## Choose your starting point

8 10 

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

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

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

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) |14| Run the Codex harness in infrastructure you operate | [Codex SDK](https://developers.openai.com/codex/codex-sdk) |

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

15 16 

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

17 18 


19 20 

20## Compare agent runtime options21## Compare agent runtime options

21 22 

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

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) |

31 24 

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).25| Option | What it manages | What you operate |

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 |

33 30 

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).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.

35 32 

36 33 

37 34 


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.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.

47 44 

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.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.

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

10 10 

11Choose **[webhook-managed](#webhook-managed)** provisioning to start or resume sandboxes from OpenAI events, or **[application-managed](#application-managed)** provisioning to control them from your application. For an interactive quickstart, use the optional [DigitalOcean CLI flow](#try-it-with-the-digitalocean-cli). See [Sandbox lifecycle](https://developers.openai.com/api/docs/guides/agents-api/environments/lifecycle) for connection and recovery behavior.11Choose **[webhook-managed](#webhook-managed)** provisioning to start or resume sandboxes from OpenAI events, or **[application-managed](#application-managed)** provisioning to control them from your application. For an interactive quickstart, use the optional [DigitalOcean CLI flow](#try-it-with-the-digitalocean-cli). See [Sandbox lifecycle](https://developers.openai.com/api/docs/guides/agents-api/environments/lifecycle) for connection and recovery behavior.

12 12 

13M.A.R.S. is in invite-only private preview. Request access through [DigitalOcean's private-preview announcement](https://www.digitalocean.com/blog/managed-agents-runtime-services-private-preview).13DigitalOcean Managed Agents is in public preview. See [DigitalOcean's documentation](https://docs.digitalocean.com/products/managed-agents/) for access and setup.

14 14 

15## Before you begin15## Before you begin

16 16 


18 18 

19Use `OPENAI_API_KEY` for your application or CLI. Set `OPENAI_EXECUTOR_API_KEY` to an [environment key](https://developers.openai.com/api/docs/guides/agents-api/environments/self-hosted#authentication). Pass only the environment key into the sandbox as `CODEX_API_KEY`.19Use `OPENAI_API_KEY` for your application or CLI. Set `OPENAI_EXECUTOR_API_KEY` to an [environment key](https://developers.openai.com/api/docs/guides/agents-api/environments/self-hosted#authentication). Pass only the environment key into the sandbox as `CODEX_API_KEY`.

20 20 

21For webhook controllers or Python applications, set `DIGITALOCEAN_TOKEN` and install the [PyDo beta SDK](https://github.com/digitalocean/pydo/releases) with async support (`pydo[aio]`). Use the [OpenAI SDK](https://developers.openai.com/api/docs/libraries#install-an-official-sdk) for Agents API requests. CLI installation is needed only for the CLI flow.21For webhook controllers or Python applications, set `DIGITALOCEAN_TOKEN` and install the [PyDo SDK](https://github.com/digitalocean/pydo/releases) version 0.41.0 or later with async support (`pydo[aio]`). Use the [OpenAI SDK](https://developers.openai.com/api/docs/libraries#install-an-official-sdk) for Agents API requests. CLI installation is needed only for the CLI flow.

22 22 

23## Webhook-managed23## Webhook-managed

24 24 


33 33 

34The CLI creates both resources and lets you interact with the agent from your terminal. It provisions the sandbox directly, without a webhook controller.34The CLI creates both resources and lets you interact with the agent from your terminal. It provisions the sandbox directly, without a webhook controller.

35 35 

36Install the [`doctl` beta release](https://github.com/digitalocean/doctl/releases) that includes `harness-runtime`, then authenticate:36Install [`doctl`](https://github.com/digitalocean/doctl/releases) version 1.170.0 or later, which includes `harness-runtime`, then authenticate:

37 37 

38```bash38```bash

39doctl auth init39doctl auth init

40```40```

41 41 

42Save this manifest as `agents.yaml`:42Save this manifest as `environment.yaml`:

43 43 

44```yaml44```yaml

45name: openai-codex-session45name: openai-codex-session


65Create the session and sandbox:65Create the session and sandbox:

66 66 

67```bash67```bash

68doctl harness-runtime create --spec agents.yaml68doctl harness-runtime create --spec environment.yaml

69```69```

70 70 

71The command waits up to 300 seconds for readiness by default. Save the OpenAI session ID and DigitalOcean session ID from the session details, then attach:71The command waits up to 300 seconds for readiness by default. Save the OpenAI session ID and DigitalOcean session ID from the session details, then attach:


222 222 

223## References223## References

224 224 

225- Read [DigitalOcean sandbox setup](https://github.com/digitalocean/pydo/tree/v0.40.0-beta.8/examples/agents/doc_python_sdk)225- Read [DigitalOcean sandbox setup](https://github.com/digitalocean/pydo/tree/main/examples/agents/doc_python_sdk)

226- Read [DigitalOcean Python SDK](https://github.com/digitalocean/pydo)226- Read [DigitalOcean Python SDK](https://github.com/digitalocean/pydo)

227- Read [DigitalOcean CLI beta release](https://github.com/digitalocean/doctl/releases)227- Read [DigitalOcean CLI releases](https://github.com/digitalocean/doctl/releases)

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 

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.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.

6 14 

7## What belongs on an agent15## 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 

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

6 14 

7- **Guardrails** validate input, output, or tool behavior automatically.15- **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 

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.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.

6 14 

7## Choose what lives in the SDK15## 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 

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.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.

6 14 

7## Start with explicit model selection15## 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 

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.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.

6 14 

7## Choose the orchestration pattern15## Choose the orchestration pattern

Details

1# Quickstart1# Agents SDK 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 

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.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.

6 14 

7## Install the SDK15## 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 

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.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.

6 14 

7## Choose the result surface you need15## 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 

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.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.

6 14 

7## The agent loop15## The agent loop


18 26 

19## Choose one conversation strategy27## Choose one conversation strategy

20 28 

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

22 30 

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

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

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 

5A sandbox gives an agent an isolated, Unix-like execution environment with a13A sandbox gives an agent an isolated, Unix-like execution environment with a

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

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


11commands, previews, and resumable work all need an environment the agent can19commands, previews, and resumable work all need an environment the agent can

12inspect and change.20inspect and change.

13 21 

14Sandbox agents are available in the TypeScript and Python Agents SDKs. They22Sandbox agents are available in the TypeScript and Python Agents SDKs.

15 are in beta, so API details, defaults, and supported capabilities may change.

16 23 

17This guide covers sandboxes in the Agents SDK, where your application runs the harness. For an OpenAI-managed harness, use [Agents API: Connect a sandbox](https://developers.openai.com/api/docs/guides/agents-api/environments/self-hosted).24This guide covers sandboxes in the Agents SDK, where your application runs the harness. For an OpenAI-managed harness, use [Agents API: Connect a sandbox](https://developers.openai.com/api/docs/guides/agents-api/environments/self-hosted).

18 25 

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 

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

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.

6 18 

7## Get your first agent running19## Get your first agent running

8 20 


31 43 

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

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

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. |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. |

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. |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. |

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. |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. |

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. |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. |


45 57 

46## Build with the SDK58## Build with the SDK

47 59 

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: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:

49 61 

50- typed application code in TypeScript or Python62- typed application code in TypeScript or Python

51- direct control over tools, MCP servers, and runtime behavior63- direct control over tools, MCP servers, and runtime behavior


63 75 

64## Compare agent runtime options76## Compare agent runtime options

65 77 

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.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.

guides/batch.md +0 −13

Details

111. Running evaluations111. Running evaluations

122. Classifying large datasets122. Classifying large datasets

133. Embedding content repositories133. Embedding content repositories

144. Queuing large offline video-render jobs

15 14 

16The Batch API offers a straightforward set of endpoints that allow you to collect a set of requests into a single file, kick off a batch processing job to execute these requests, query for the status of that batch while the underlying requests execute, and eventually retrieve the collected results when the batch is complete.15The Batch API offers a straightforward set of endpoints that allow you to collect a set of requests into a single file, kick off a batch processing job to execute these requests, query for the status of that batch while the underlying requests execute, and eventually retrieve the collected results when the batch is complete.

17 16 


34- `/v1/moderations` ([Moderation guide](https://developers.openai.com/api/docs/guides/moderation))33- `/v1/moderations` ([Moderation guide](https://developers.openai.com/api/docs/guides/moderation))

35- `/v1/images/generations` ([Images API](https://developers.openai.com/api/reference/resources/images))34- `/v1/images/generations` ([Images API](https://developers.openai.com/api/reference/resources/images))

36- `/v1/images/edits` ([Images API](https://developers.openai.com/api/reference/resources/images))35- `/v1/images/edits` ([Images API](https://developers.openai.com/api/reference/resources/images))

37- `/v1/videos` ([Video generation guide](https://developers.openai.com/api/docs/guides/video-generation))

38 36 

39For a given input file, the parameters in each line's `body` field are the same as the parameters for the underlying endpoint. Each request must include a unique `custom_id` value, which you can use to reference results after completion. Here's an example of an input file with 2 requests. Note that each input file can only include requests to a single model.37For a given input file, the parameters in each line's `body` field are the same as the parameters for the underlying endpoint. Each request must include a unique `custom_id` value, which you can use to reference results after completion. Here's an example of an input file with 2 requests. Note that each input file can only include requests to a single model.

40 38 

41For video generation in Batch:

42 

43- Batch currently supports `POST /v1/videos` only.

44- Batch requests for videos must use JSON, not multipart.

45- Upload assets ahead of time and pass supported asset references in the request body rather than using multipart uploads.

46- Use `input_reference` for image-guided generations in Batch. In JSON requests, pass `input_reference` as an object with either `file_id` or `image_url`.

47- Multipart `input_reference` uploads, including video reference inputs, aren't supported in Batch.

48- Batch-generated videos are available for download for up to `24` hours after the batch completes.

49 

50When targeting `/v1/moderations`, include an `input` field in every request body. Batch accepts plain-text inputs and content arrays with text or image inputs using `omni-moderation-latest`. The Batch worker rejects requests that set `stream=true`, matching the synchronous moderation endpoint.39When targeting `/v1/moderations`, include an `input` field in every request body. Batch accepts plain-text inputs and content arrays with text or image inputs using `omni-moderation-latest`. The Batch worker rejects requests that set `stream=true`, matching the synchronous moderation endpoint.

51 40 

52```jsonl41```jsonl


507 496 

508The output `.jsonl` file will have one response line for every successful request line in the input file. Any failed requests in the batch will have their error information written to an error file that can be found via the batch's `error_file_id`.497The output `.jsonl` file will have one response line for every successful request line in the input file. Any failed requests in the batch will have their error information written to an error file that can be found via the batch's `error_file_id`.

509 498 

510For `/v1/videos`, a completed batch result contains video objects that have already reached a terminal state such as `completed`, `failed`, or `expired`. You can use the returned video IDs to download final assets immediately after the batch finishes.

511 

512Note that the output line order **may not match** the input line order.499Note that the output line order **may not match** the input line order.

513 Instead of relying on order to process your results, use the custom_id field500 Instead of relying on order to process your results, use the custom_id field

514 which will be present in each line of your output file and allow you to map501 which will be present in each line of your output file and allow you to map

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). 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/sdk). 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, build on your own server-side agent implementation with the8 ChatKit apps, use a custom server integration with the ChatKit SDKs. This

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

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

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

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

11 13 

12## Run ChatKit on your own infrastructure14## Run ChatKit on your own infrastructure

13 15 

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 

5| Contents | Expected impact |5| Contents | Expected impact |

6| ------------------------------------------------------------------------------- | ----------------------------------- |6| ------------------------------------------------------------------------------------------------------- | ----------------------------------- |

7| [Use the Responses API](#use-the-responses-api) | Quality, cost, latency, reliability |7| [Use the Responses API](#use-the-responses-api) | Quality, cost, latency, reliability |

8| [Choose a GPT-5.6 model](#choose-a-gpt-56-model) | Quality, cost, latency |8| [Choose a model for the workload](#choose-a-model-for-the-workload) | Quality, cost, latency |

9| [Set up `reasoning.effort`](#set-up-reasoningeffort) | Quality, cost, latency |9| [Set up `reasoning.effort`](#set-up-reasoningeffort) | Quality, cost, latency |

10| [Change reasoning effort mid-conversation](#change-reasoning-effort-mid-conversation) | Quality, cost, latency |

10| [Set up `text.verbosity`](#set-up-textverbosity) | Quality, cost, latency |11| [Set up `text.verbosity`](#set-up-textverbosity) | Quality, cost, latency |

11| [Set up the assistant `phase` parameter](#set-up-the-assistant-phase-parameter) | Quality, cost |12| [Set up the assistant `phase` parameter](#set-up-the-assistant-phase-parameter) | Quality, cost |

12| [Use `tool_search`](#use-toolsearch) | Cost, latency |13| [Use `tool_search`](#use-toolsearch) | Cost, latency |

13| [Use Programmatic Tool Calling](#use-programmatic-tool-calling) | Quality, cost, latency |14| [Use Programmatic Tool Calling](#use-programmatic-tool-calling) | Quality, cost, latency |

14| [Use Multi-agent for parallel work](#use-multi-agent-for-parallel-work) | Quality, cost, latency |15| [Use Multi-agent for parallel work](#use-multi-agent-for-parallel-work) | Quality, cost, latency |

16| [Use async tool calling](#use-async-tool-calling) | Latency |

15| [Leverage built-in tools](#leverage-built-in-tools) | Quality |17| [Leverage built-in tools](#leverage-built-in-tools) | Quality |

16| [Leverage compaction](#leverage-compaction) | Cost |18| [Leverage compaction](#leverage-compaction) | Cost |

17| [Optimize prompt caching](#optimize-prompt-caching) | Latency, cost |19| [Optimize prompt caching](#optimize-prompt-caching) | Latency, cost |

18| [Use `reasoning.encrypted_content`](#use-reasoningencryptedcontent) | Quality, latency |20| [Use `reasoning.encrypted_content`](#use-reasoningencryptedcontent) | Quality, latency |

19| [Set image detail intentionally](#set-image-detail-intentionally) | Quality, cost, latency |21| [Set image detail intentionally](#set-image-detail-intentionally) | Quality, cost, latency |

20| [Send a safety identifier](#send-a-safety-identifier) | Safety, reliability |22| [Send a safety identifier](#send-a-safety-identifier) | Safety, reliability |

21| [Use `background=True`](#use-backgroundtrue) | Resuming work |23| [Handle misalignment monitoring](#handle-misalignment-monitoring) | Safety, reliability |

24| [Handle rapid traffic increases and model overload](#handle-rapid-traffic-increases-and-model-overload) | Reliability |

25| [Use `background=True`](#use-backgroundtrue) | Task continuity |

22| [Use WebSocket mode](#use-websocket-mode) | Latency |26| [Use WebSocket mode](#use-websocket-mode) | Latency |

27| [Use mid-turn steering](#use-mid-turn-steering) | Quality |

23 28 

24## Use the Responses API29## Use the Responses API

25 30 


28API and the best place to access the newest model behavior, built-in tools,33API and the best place to access the newest model behavior, built-in tools,

29stateful workflows, and agent features.34stateful workflows, and agent features.

30 35 

31## Choose a GPT-5.6 model36## Choose a model for the workload

32 37 

33Choose a [GPT-5.6 model](https://developers.openai.com/api/docs/guides/latest-model?model=gpt-5.6) for the workload instead38Evaluate the [GPT-6 model family](https://developers.openai.com/api/docs/guides/latest-model?model=gpt-6-astra)

34of routing every request to the most capable tier. Use `gpt-5.6` or39for your workload. Use [`gpt-6-astra`](https://developers.openai.com/api/docs/models/gpt-6-astra) for the

35`gpt-5.6-sol` for flagship capability, `gpt-5.6-terra` for strong performance40highest capability, [`gpt-6-sol`](https://developers.openai.com/api/docs/models/gpt-6-sol) for demanding

36at a lower price, and `gpt-5.6-luna` for efficient, high-volume workloads.41reasoning and coding, and [`gpt-6-luna`](https://developers.openai.com/api/docs/models/gpt-6-luna) for

37 42efficient, repeatable work. Choose the model that performs well on representative

38When migrating, preserve the current model's workload role and effective43tasks rather than routing every request to the most capable model.

39reasoning effort for the first comparison. Run representative evals before44 

40changing prompts or adding new capabilities. Compare task success, latency,45When migrating to GPT-6, preserve your current model's workload role and

41input, output, reasoning, and cache-write tokens, and cost per successful task.46effective reasoning effort where supported. Use the Responses API for reasoning

47with tools. GPT-6 Astra requires Responses for tool calling; GPT-6 Sol and Luna

48support function calling in Chat Completions only with `reasoning_effort: "none"`.

49When reasoning effort is not `none`, remove `temperature`, `top_p`, and

50`top_logprobs`; also remove `logprobs` from Chat Completions requests and

51`message.output_text.logprobs` from the Responses `include` array. With EU data

52residency, use Standard processing for all three models. See the

53[model migration guidance](https://developers.openai.com/api/docs/guides/latest-model?model=gpt-6-astra#migration-quickstart)

54for other compatibility checks. Run representative evals before changing prompts or adding new

55capabilities. Compare task success, latency, input, output, reasoning, and

56cache-write tokens, and cost per successful task.

42 57 

43## Set up `reasoning.effort`58## Set up `reasoning.effort`

44 59 

45Use `reasoning.effort` to decide how much thinking the model should do before it60Use `reasoning.effort` to decide how much thinking the model should do before it

46answers.61answers.

47 62 

48For GPT-5.6 models, the supported values are `none`, `low`, `medium`, `high`,63GPT-6 Astra, Sol, and Luna support `low`, `medium`, `high`, `xhigh`, and

49`xhigh`, and `max`. The default is `medium`. Lower effort is faster and uses64`max`. Sol and Luna also support `none`; Astra does not. Lower effort is faster and uses fewer

50fewer reasoning tokens. Higher effort gives the model more time for planning,65reasoning tokens. Higher effort gives the model more time for planning,

51debugging, synthesis, and multi-step tradeoffs.66debugging, synthesis, and multi-step tradeoffs.

52 67 

53Use `low` when the job is mostly extraction, routing, classification, or a68Use `low` when the job is mostly extraction, routing, classification, or a

54routine rewrite. Use `medium` or `high` when the model needs to diagnose a69routine rewrite. Use `medium` or `high` when the model needs to diagnose a

55problem, compare options, write a plan, or reason through code. Use `xhigh` or70problem, compare options, write a plan, or reason through code. Use `xhigh` or

56`max` only when representative evals show that the quality gain justifies the71`max` only when representative evals show that the quality gain justifies the

57extra latency and cost. When migrating from GPT-5.5 or GPT-5.4, start with the72extra latency and cost. When migrating from `minimal`, or from `none` to GPT-6

58current effort and compare the same setting with one level lower. GPT-5.6 can73Astra, start with `low` and compare results. Otherwise, preserve your current effective

59often maintain or improve quality with fewer reasoning tokens, so the lower74effort and test changes against your quality, latency, and cost targets.

60setting may also reduce latency and cost.

61 75 

62For the hardest quality-first workloads, also compare76For the hardest quality-first workloads, also compare

63[`reasoning.mode: "pro"`](https://developers.openai.com/api/docs/guides/reasoning#reasoning-mode) with77[`reasoning.mode: "pro"`](https://developers.openai.com/api/docs/guides/reasoning#reasoning-mode) with


203```217```

204 218 

205 219 

220## Change reasoning effort mid-conversation

221 

222For GPT-6 models in standard, single-agent mode, add a

223[`configuration_update`](https://developers.openai.com/api/docs/guides/reasoning#change-reasoning-mid-conversation)

224input item before the next user message to change effort between responses.

225Leave the request-level `reasoning.effort` unchanged so the original prompt

226prefix remains eligible for caching. The update applies to the next response

227and continues until another update overrides it. Configuration updates cannot

228be combined with automatic compaction or truncation, and `/responses/compact`

229rejects histories containing them. To compact the history, include a

230`compaction_trigger` item and add a fresh update afterward.

231 

206## Set up `text.verbosity`232## Set up `text.verbosity`

207 233 

208`text.verbosity` is the main lever for balancing brevity against completeness.234`text.verbosity` is the main lever for balancing brevity against completeness.


214For coding, `medium` and `high` tend to produce longer, more organized output240For coding, `medium` and `high` tend to produce longer, more organized output

215with clearer structure. `low` keeps the answer tighter and more minimal.241with clearer structure. `low` keeps the answer tighter and more minimal.

216 242 

217GPT-5.6 tends to be more concise by default than GPT-5.5. When migrating, check243When migrating, check whether broad instructions like "Be concise" still help.

218whether broad instructions like "Be concise" still help. In some cases, they may244Prefer `text.verbosity` to control the default level of detail, then use the

219make responses too brief. Keep them only when they still help, and prefer using245prompt to specify required content, structure, and length.

220`text.verbosity` to control the default level of detail; then use the prompt to246 

221specify required content, structure, and a more specific length, if applicable.247Prompts also affect quality, token usage, cost, and latency. Review the

248[latest-model prompting best practices](https://developers.openai.com/api/docs/guides/latest-model#prompting-best-practices)

249alongside your verbosity setting, including its testing and verification

250guidance for coding agents.

222 251 

223Set lower verbosity for compact output252Set lower verbosity for compact output

224 253 


381progress updates from the final result. This helps reduce early stopping, making410progress updates from the final result. This helps reduce early stopping, making

382the agent more likely to continue until it reaches the final answer.411the agent more likely to continue until it reaches the final answer.

383 412 

413<a id="use-toolsearch" className="scroll-mt-[110px]"></a>

414 

384## Use `tool_search`415## Use `tool_search`

385 416 

386Instead of loading the full tool catalog into every request, use417Instead of loading the full tool catalog into every request, use


403**Start with hosted tool search** unless your app really needs to control434**Start with hosted tool search** unless your app really needs to control

404discovery itself.435discovery itself.

405 436 

406Group your tools by user intent. Use namespaces or MCP servers when you can. It437Group your tools by user intent. Use a namespace or an MCP server when you can. It

407is easier for the model to choose between a few clear groups than a long flat438is easier for the model to choose between a few clear groups than a long flat

408list of functions. We recommend keeping each namespace under about 10 functions439list of functions. We recommend keeping each namespace under about 10 functions

409for optimal token efficiency and model performance.440for optimal token efficiency and model performance.


722## Use Programmatic Tool Calling753## Use Programmatic Tool Calling

723 754 

724[Programmatic Tool Calling](https://developers.openai.com/api/docs/guides/tools-programmatic-tool-calling)755[Programmatic Tool Calling](https://developers.openai.com/api/docs/guides/tools-programmatic-tool-calling)

725lets GPT-5.6 write JavaScript that calls eligible tools and reduces their756lets supported models write JavaScript that calls eligible tools and reduces

726intermediate results inside a hosted runtime. Use it for bounded stages where757their intermediate results inside a hosted runtime. Use it for bounded stages where

727code can filter, join, rank, remove duplicates, combine, or check large tool758code can filter, join, rank, remove duplicates, combine, or check large tool

728results before returning a smaller structured result to the model.759results before returning a smaller structured result to the model.

729 760 


747 778 

748## Use Multi-agent for parallel work779## Use Multi-agent for parallel work

749 780 

750[Multi-agent](https://developers.openai.com/api/docs/guides/responses-multi-agent) is a GPT-5.6 feature that781[Multi-agent](https://developers.openai.com/api/docs/guides/responses-multi-agent) lets supported models,

751lets a root agent delegate independent workstreams to subagents and synthesize782including GPT-6 models, delegate independent workstreams to subagents and

752their results. Use it when you can split research, analysis, or implementation783synthesize their results. Use it when you can split research, analysis, or implementation

753into concrete, bounded tasks that use separate context and run in parallel.784into concrete, bounded tasks that use separate context and run in parallel.

754 785 

755Set `multi_agent.enabled` to `true` in the request. For HTTP, use the beta786Set `multi_agent.enabled` to `true` in the request. For HTTP, use the beta


769supported. The server automatically compacts the root context and every800supported. The server automatically compacts the root context and every

770subagent context.801subagent context.

771 802 

803## Use async tool calling

804 

805On GPT-6 models, set `async: true` on a function or custom tool when the model

806can keep working while your application runs it. Start slow tool calls early and

807let the model handle independent work. Your application still executes and

808tracks the call, then returns the result in a later Responses request with the

809original `call_id`. Async execution does not apply to built-in tools or

810programmatic tool calls. In Multi-agent mode, do not combine async tools with

811parallel tool calls. See [async tool calling](https://developers.openai.com/api/docs/guides/async-tool-calling)

812for the full flow.

813 

772## Leverage built-in tools814## Leverage built-in tools

773 815 

774[Built-in tools](https://developers.openai.com/api/docs/guides/tools) are native capabilities of the API.816[Built-in tools](https://developers.openai.com/api/docs/guides/tools) are native capabilities of the API.


1057the breakpoints you provide and no implicit breakpoint. Earlier models continue1099the breakpoints you provide and no implicit breakpoint. Earlier models continue

1058to use automatic prompt caching only.1100to use automatic prompt caching only.

1059 1101 

1102When migrating from GPT-5.5 or earlier, replace `prompt_cache_retention` with

1103`prompt_cache_options.ttl: "30m"`. See the [prompt caching model

1104differences](https://developers.openai.com/api/docs/guides/prompt-caching#summary-of-model-differences)

1105before changing cache settings.

1106 

1060On GPT-5.6 models and later model families, cache writes cost 1.25× the1107On GPT-5.6 models and later model families, cache writes cost 1.25× the

1061uncached input token rate. Log `cached_tokens` and `cache_write_tokens`, then1108uncached input token rate. Log `cached_tokens` and `cache_write_tokens`, then

1062compare write volume with later cache reads to measure net cost and tune1109compare write volume with later cache reads to measure net cost and tune


1216```1263```

1217 1264 

1218 1265 

1266<a id="use-reasoningencryptedcontent" className="scroll-mt-[110px]"></a>

1267 

1219## Use `reasoning.encrypted_content`1268## Use `reasoning.encrypted_content`

1220 1269 

1221GPT-5.6 can [preserve reasoning across1270Supported models, including GPT-6 models, can [preserve reasoning across

1222calls](https://developers.openai.com/api/docs/guides/reasoning#preserve-reasoning-across-calls). Use1271calls](https://developers.openai.com/api/docs/guides/reasoning#preserve-reasoning-across-calls). Use

1223`reasoning.context: "all_turns"` when the task's goals, assumptions, and1272`reasoning.context: "all_turns"` when the task's goals, assumptions, and

1224priorities remain stable. Use `current_turn` when earlier reasoning is no longer1273priorities remain stable. Use `current_turn` when earlier reasoning is no longer


1480 1529 

1481## Set image detail intentionally1530## Set image detail intentionally

1482 1531 

1483On GPT-5.6 models, omitted image `detail` and `detail: "auto"` use the same1532Image `detail` defaults to `auto`, and its sizing behavior depends on the model.

1484sizing behavior as `original`. The service preserves the input dimensions,1533Large images can use more input tokens and add latency. Check the [sizing table

1485except that images larger than 65,535 pixels on either side are scaled down to1534for listed models](https://developers.openai.com/api/docs/guides/images-vision#model-sizing-behavior), and

1486fit that limit. The API rejects images that still exceed the1535measure image token use and limits with your selected model before deployment.

1487[30,000-patch limit](https://developers.openai.com/api/docs/guides/images-vision#image-input-requirements),

1488rather than resizing them to fit it. Large images can use more input tokens and

1489add latency as a result.

1490 1536 

1491Choose [`detail`](https://developers.openai.com/api/docs/guides/images-vision#choose-an-image-detail-level)1537Choose [`detail`](https://developers.openai.com/api/docs/guides/images-vision#choose-an-image-detail-level)

1492for the task. Resize the image, use `low` when fine visual detail is not1538for the task. Resize the image, use `low` when fine visual detail is not

1493important, or use `high` for standard high-fidelity image understanding. Keep1539important, or use `high` for standard high-fidelity image understanding. Use

1494`original` for large, dense, coordinate-sensitive, OCR, localization, or1540`original` where supported for large, dense, coordinate-sensitive, OCR,

1495visual-inspection tasks where the extra detail improves quality. Measure1541localization, or visual-inspection tasks where the extra detail improves quality.

1496worst-case image tokens and latency before deployment.1542Measure worst-case image tokens and latency before deployment.

1497 1543 

1498## Send a safety identifier1544## Send a safety identifier

1499 1545 


1507Hash the user's username or email address instead of sending identifying1553Hash the user's username or email address instead of sending identifying

1508information. For logged-out experiences, use a stable session ID.1554information. For logged-out experiences, use a stable session ID.

1509 1555 

1556## Handle misalignment monitoring

1557 

1558For GPT-6 Astra agent workflows, plan for [misalignment

1559monitoring](https://developers.openai.com/api/docs/guides/safety-checks/misalignment-monitoring). If a request

1560returns `403` with `misalignment_policy_violation`, stop dispatching actions for

1561that conversation and do not automatically retry the blocked workflow. Handle

1562errors during streaming too, and review any actions that may already have run.

1563Subscribe to `safety.alert.created` if your team needs project alerts; the

1564webhook does not replace request error handling. Check the guide for which

1565Responses requests can be stopped automatically.

1566 

1567## Handle rapid traffic increases and model overload

1568 

1569Check the HTTP status and `error.code` before choosing a recovery action. A

1570`429` with `slow_down` means the request rate increased too quickly: follow

1571`Retry-After` when present, reduce traffic, then ramp gradually. A `503` with

1572`server_is_overloaded` means the requested model is temporarily overloaded:

1573follow `Retry-After` when present, then retry. If the header is missing, increase

1574retry delays exponentially with jitter and bound your retries. Billing, spend, and

1575quota errors require action before retrying; do not treat every `429` as a

1576temporary rate limit. See [rate limits](https://developers.openai.com/api/docs/guides/rate-limits#handle-rapid-traffic-increases-and-model-overload)

1577and [error codes](https://developers.openai.com/api/docs/guides/error-codes).

1578 

1510## Use `background=True`1579## Use `background=True`

1511 1580 

1512Use [`background=True`](https://developers.openai.com/api/docs/guides/background) for requests that may take1581Use [`background=True`](https://developers.openai.com/api/docs/guides/background) for requests that may take


1697[WebSocket mode](https://developers.openai.com/api/docs/guides/websocket-mode) is built for long-running,1766[WebSocket mode](https://developers.openai.com/api/docs/guides/websocket-mode) is built for long-running,

1698tool-call-heavy workflows where you keep a persistent connection open and1767tool-call-heavy workflows where you keep a persistent connection open and

1699continue by sending only new input items plus `previous_response_id`. For1768continue by sending only new input items plus `previous_response_id`. For

1700runs with 20 or more tool calls, this approach is roughly 40% faster1769workflows with 20 or more tool calls, we have seen up to roughly 40% faster

1701end-to-end.1770end-to-end execution.

1702 1771 

1703**How this works**: The first message will look like a normal Responses request:1772**How this works**: The first message will look like a normal Responses request:

1704model, instructions, tools, and user input. The server streams events back. If1773model, instructions, tools, and user input. The server streams events back. If


1708comes from. In plain HTTP, every follow-up is a fresh request. In WebSocket mode,1777comes from. In plain HTTP, every follow-up is a fresh request. In WebSocket mode,

1709the connection stays open and the most recent response state stays warm in1778the connection stays open and the most recent response state stays warm in

1710memory on that connection. When the next turn continues from that response, the1779memory on that connection. When the next turn continues from that response, the

1711backend has to do less setup work.1780service has to do less setup work.

1712 1781 

1713If your workflow is one request, one answer, then **keep HTTP**. If your1782If your workflow is one request, one answer, then **keep HTTP**. If your

1714workflow behaves like a long-running agent, try WebSocket mode.1783workflow behaves like a long-running agent, try WebSocket mode.

1715 1784 

1716A single WebSocket connection handles one in-flight response at a time, so1785Use different `stream_id` values for parallel conversations on one connection;

1717parallel work needs multiple connections. Connections currently top out at 601786route interleaved events by `stream_id`. A connection supports up to 16 active

1718minutes. Continuation uses the same `previous_response_id` semantics as HTTP1787responses, while requests on the same stream run in order. Connections last up

1719mode, with a connection-local cache for the most recent response.1788to 60 minutes. Continuation uses the same `previous_response_id` semantics as

1789HTTP mode, with a connection-local cache for the latest response in each stream.

1720 1790 

1721Note: WebSocket mode works with ZDR because your data is not stored to disk,1791Note: WebSocket mode works with ZDR because your data is not stored to disk,

1722only stored in memory.1792only stored in memory.


1866```1936```

1867 1937 

1868 1938 

1939## Use mid-turn steering

1940 

1941If users may add requirements while a GPT-6 model is working, use a WebSocket

1942connection to the Responses API. Send `response.steer` with the active response

1943ID in `previous_response_id` and the new user input. Keep reading events for

1944the continuation; `response.steer.accepted` means the update is queued.

1945Steering does not change output already sent to your application or undo tools

1946that have started. See [mid-turn steering](https://developers.openai.com/api/docs/guides/steering) for the

1947event flow and tool-result handling.

1948 

1869## Final takeaway1949## Final takeaway

1870 1950 

1871Responses API is the foundation for building smarter, more capable OpenAI1951Responses API is the foundation for building smarter, more capable OpenAI

guides/evals.md +2 −2

Details

433 433 

434### Uploading test data434### Uploading test data

435 435 

436There are several ways to provide test data for eval runs, but it may be convenient to upload a [JSONL](https://jsonlines.org/) file that contains data in the schema we specified when we created our eval. A sample JSONL file that conforms to the schema we set up is below:436You can provide test data for eval runs in several ways, but it may be convenient to upload a [JSONL](https://jsonlines.org/) file that contains data in the schema we specified when we created our eval. A sample JSONL file that conforms to the schema we set up is below:

437 437 

438```json438```json

439{ "item": { "ticket_text": "My monitor won't turn on!", "correct_label": "Hardware" } }439{ "item": { "ticket_text": "My monitor won't turn on!", "correct_label": "Hardware" } }


849 849 

850The API response contains granular information about test criteria results, API usage for generating model responses, and a `report_url` property that takes you to a page in the dashboard where you can explore the results visually.850The API response contains granular information about test criteria results, API usage for generating model responses, and a `report_url` property that takes you to a page in the dashboard where you can explore the results visually.

851 851 

852In our simple test, the model reliably generated the content we wanted for a small test case sample. In reality, you will often have to run your eval with more criteria, different prompts, and different data sets. But the process above gives you all the tools you need to build robust evals for your LLM apps!852In our test, the model reliably generated the content we wanted for a small test case sample. In reality, you will often have to run your eval with more criteria, different prompts, and different data sets. But the process above gives you all the tools you need to build robust evals for your LLM apps!

853 853 

854## Next steps854## Next steps

855 855 

Details

36 36 

37### Uploading a CSV37### Uploading a CSV

38 38 

39We have a simple CSV containing company names and actual values for their revenue from past quarters.39We have a CSV containing company names and actual values for their revenue from past quarters.

40 40 

41<video41<video

42 src="https://openaiassets.blob.core.windows.net/$web/platform-docs/evals/csv-upload.mp4"42 src="https://openaiassets.blob.core.windows.net/$web/platform-docs/evals/csv-upload.mp4"


91 91 

92 You’ll see a new special **output** column in the dataset begin to populate with results. This column contains the results from running your prompt on each row in your dataset.92 You’ll see a new special **output** column in the dataset begin to populate with results. This column contains the results from running your prompt on each row in your dataset.

93 93 

941. Once your generated outputs are ready, annotate them. Open the annotation view by clicking the **output**, **rating**, or **output_feedback** column.941. Once your generated outputs are ready, annotate them. Open the annotation view by clicking the **output**, **rating**, or **`output_feedback`** column.

95 95 

96 Annotate as little or as much as you want. Datasets are designed to work with any degree and type of annotation, but the higher quality of information you can provide, the better your results will be.96 Annotate as little or as much as you want. Datasets are designed to work with any degree and type of annotation, but the higher quality of information you can provide, the better your results will be.

97 97 


104- Enables diagnosing prompt shortcomings, particularly in subtle or infrequent cases104- Enables diagnosing prompt shortcomings, particularly in subtle or infrequent cases

105- Helps ensure that graders are aligned with your intent105- Helps ensure that graders are aligned with your intent

106 106 

107You can choose to annotate as little or as much as you want. Datasets are designed to work with any degree and type of annotation, but the higher quality of information you can provide, the better your results will be. Additionally, if you’re not an expert on the contents of your dataset, we recommend that a subject matter expert performs the annotation — this is the most valuable way for their expertise to be incorporated into your optimization process. Explore [our cookbook](https://developers.openai.com/cookbook/examples/evaluation/building_resilient_prompts_using_an_evaluation_flywheel) to learn more about what we have found to be most effective in using evals to improve our prompt resilience.107You can choose to annotate as little or as much as you want. Datasets are designed to work with any degree and type of annotation, but the higher quality of information you can provide, the better your results will be. Additionally, if you’re not an expert on the contents of your dataset, we recommend that a subject matter expert performs the annotation—this is the most valuable way for their expertise to be incorporated into your optimization process. Explore [our cookbook](https://developers.openai.com/cookbook/examples/evaluation/building_resilient_prompts_using_an_evaluation_flywheel) to learn more about what we have found to be most effective in using evals to improve our prompt resilience.

108 108 

109### Annotation starting points109### Annotation starting points

110 110 

111Here are a few types of annotations you can use to get started:111Here are a few types of annotations you can use to get started:

112 112 

113- A Good/Bad rating, indicating your judgment of the output113- A Good/Bad rating, indicating your judgment of the output

114- A text critique in the **output_feedback** section114- A text critique in the **`output_feedback`** section

115- Custom annotation categories that you added in the **Columns** dropdown in the top right115- Custom annotation categories that you added in the **Columns** dropdown in the top right

116 116 

117### Incorporate expert annotations117### Incorporate expert annotations

Details

64Once you have configured an external model, you can use it for evals on the by selecting it from the model picker in your [dataset](https://platform.openai.com/evaluation) or your [evaluation](https://platform.openai.com/evaluation?tab=evals). Note that tool calls are currently not supported.64Once you have configured an external model, you can use it for evals on the by selecting it from the model picker in your [dataset](https://platform.openai.com/evaluation) or your [evaluation](https://platform.openai.com/evaluation?tab=evals). Note that tool calls are currently not supported.

65 65 

66| Model type | Datasets | Evals |66| Model type | Datasets | Evals |

67| ----------- | :---------------------------: | :---------------------------: |67| ----------- | :-------------------------: | :-------------------------: |

68| Third-party | | |68| Third-party | | |

69| Custom | | |69| Custom | | |

70 70 

Details

22- Scrutinize existing examples for issues.22- Scrutinize existing examples for issues.

23 - If your model has grammar, logic, or style issues, check if your data has any of the same issues. For instance, if the model now says "I will schedule this meeting for you" (when it shouldn't), see if existing examples teach the model to say it can do new things that it can't do23 - If your model has grammar, logic, or style issues, check if your data has any of the same issues. For instance, if the model now says "I will schedule this meeting for you" (when it shouldn't), see if existing examples teach the model to say it can do new things that it can't do

24- Consider the balance and diversity of data.24- Consider the balance and diversity of data.

25 - If 60% of the assistant responses in the data says "I cannot answer this", but at inference time only 5% of responses should say that, you will likely get an overabundance of refusals.25 - If 60% of the assistant responses in the data says "I cannot answer this," but at inference time only 5% of responses should say that, you will likely get an overabundance of refusals.

26- Make sure your training examples contain all of the information needed for the response.26- Make sure your training examples contain all of the information needed for the response.

27 - If we want the model to compliment a user based on their personal traits and a training example includes assistant compliments for traits not found in the preceding conversation, the model may learn to hallucinate information.27 - If we want the model to compliment a user based on their personal traits and a training example includes assistant compliments for traits not found in the preceding conversation, the model may learn to hallucinate information.

28- Look at the agreement and consistency in the training examples.28- Look at the agreement and consistency in the training examples.


31 31 

32### Iterating on data quantity32### Iterating on data quantity

33 33 

34Once you're satisfied with the quality and distribution of the examples, you can consider scaling up the number of training examples. This tends to help the model learn the task better, especially around possible "edge cases". We expect a similar amount of improvement every time you double the number of training examples. You can loosely estimate the expected quality gain from increasing the training data size by:34Once you're satisfied with the quality and distribution of the examples, you can consider scaling up the number of training examples. This tends to help the model learn the task better, especially around possible "edge cases." We expect a similar amount of improvement every time you double the number of training examples. You can loosely estimate the expected quality gain from increasing the training data size by:

35 35 

36- Fine-tuning on your current dataset36- Fine-tuning on your current dataset

37- Fine-tuning on half of your current dataset37- Fine-tuning on half of your current dataset

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. 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).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.

106 106 

107## Function tool example107## Function tool example

108 108 

Details

1# API organization blocking

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.

4 

5API organization blocking lets you restrict which API organizations users can access from your network. Configure an allowlist of organization IDs through your proxy or Secure Access Service Edge (SASE) service.

6 

7## How it works

8 

9- **Custom allowlist header:** You configure which API organizations you want to allow by adding a custom HTTP header, `OpenAI-Allowed-Organization-Ids`, to your network configuration. You can specify one or more organization IDs (for example, `org-…`) in the header, separated by commas without spaces.

10- **API Platform enforces the allowlist:**

11 - When a user logs in to API Platform from your network, OpenAI reads the header and checks if the API organization that the user is trying to access matches one of the organization IDs listed in the `OpenAI-Allowed-Organization-Ids` header.

12 - If the user tries to access an organization not listed in the header, OpenAI automatically rejects this request with an error that has status code `403`, blocking access to that organization. Only the organizations listed in the header will be accessible.

13 

14## Setup

15 

16### Step 1: Find your organization IDs

17 

18To allow access to specific organizations, copy the organization ID for each organization you want to allow. You can find this ID on the API Platform Organization settings page:

19 

20- Log in to your API Platform account and switch to the desired organization.

21- Navigate to the Organization settings page and note the Organization ID (example value: `org-Tkxfm8owx4zIPaJGNDVrPs6m`).

22 

23### Step 2: Configure the header

24 

25Customers should configure their network, via a proxy or Secure Access Service Edge (SASE) service, to send the header.

26 

27- **To allow multiple organizations**, enter the organization IDs separated by commas without spaces.

28- **Specify URL targeting:**

29 - Configure your proxy or SASE service to apply the header only to requests made to `https://api.openai.com/*`.

30 

31### Step 3: Verify the configuration

32 

33After configuring the header, test access from a device connected to the network where the rule applies.

34 

351. Sign in to API Platform with an account that has access to both:

36 - An organization included in the allowlist.

37 - An organization that is not included in the allowlist.

382. Open the organization included in the allowlist. Confirm that you can access it.

393. Try to open the organization that is not included in the allowlist. Confirm that access is blocked and the error has status code `403`.

404. If you allow multiple organizations, confirm that you can access each one.

41 

42If the results differ from what you expect, check that your proxy or SASE rule applies to the test device and that the header contains the correct organization IDs.

43 

44### Troubleshoot access errors

45 

46- **Status code 403:** If a user attempts to access an API organization that is not allowed, they will see an error. The error will have status code `403`, and a message will indicate they are not authorized to access that organization.

47- **Status code 400:** If the header value is malformed (for example, if the organization ID is invalid), all requests with that header will fail with an error that has status code `400`.

Details

97 97 

98 98 

99 99 

100Connect your own AWS S3 bucket or Azure Blob container to an OpenAI project. Follow the setup steps for your cloud, then register and validate the connection.100Connect your own AWS S3 bucket, Azure Blob container, or Google Cloud Storage bucket to an OpenAI project. Follow the setup steps for your cloud, then register and validate the connection.

101 101 

102ZDR with PSP is enabled per project. Once enabled, the PSP policy applies to all API traffic in that project, including requests to models that do not otherwise require PSP. To use ZDR without PSP for eligible models, send those requests through a separate project configured for ZDR without PSP.102ZDR with PSP is enabled per project. Once enabled, the PSP policy applies to all API traffic in that project, including requests to models that do not otherwise require PSP. To use ZDR without PSP for eligible models, send those requests through a separate project configured for ZDR without PSP.

103 103 


110### Open storage setup in the API console110### Open storage setup in the API console

111 111 

1121. Open **Organization settings > Data controls > Data retention**, then select **Connect storage**.1121. Open **Organization settings > Data controls > Data retention**, then select **Connect storage**.

1132. In **Connect external storage**, choose **AWS** or **Azure** and select your project. You can also open **Connect storage** from **Project Settings > Data retention**.1132. In **Connect external storage**, choose **AWS**, **Azure**, or **GCP** and select your project. You can also open **Connect storage** from **Project Settings > Data retention**.

1143. Complete the cloud setup below. Then enter your storage details in the modal and select **Connect and validate**.1143. Complete the cloud setup below. Then enter your storage details in the modal and select **Connect and validate**.

115 115 

116### Cloud-specific Setups116### Cloud-specific Setups


125 125 

126 126 

127 127 

128Complete these steps if you're using AWS. For Azure, skip to **Azure Blob Storage**.128Complete these steps if you're using AWS. For other clouds, skip to **Azure Blob Storage** or **Google Cloud Storage**.

129 129 

130#### 1. Create the bucket130#### 1. Create the bucket

131 131 


288 288 

289 289 

290 290 

291 

292 

293<a id="google-cloud-storage"></a>

294 

295 

296 

297#### Google Cloud Storage

298 

299 

300 

301#### 1. Create the bucket

302 

303Create a bucket in **Cloud Storage > Buckets** in a location compatible with your OpenAI project's data residency, with:

304 

305- **Public access prevention**: On.

306- **Access control**: Uniform.

307 

308You can optionally disable the default **Soft delete policy (For data recovery)**; the next step configures lifecycle deletion.

309 

310For Global projects, repeat this GCP setup for each region you intend to use.

311 

312![Google Cloud bucket access settings showing Public access prevention On, Access control Uniform, and IP filtering Not configured.](https://developers.openai.com/images/platform/guides/private-safety-processing/setup-gcp-bucket-access-controls.webp)

313 

314#### 2. Set the lifecycle rule

315 

316In your bucket's **Lifecycle** tab, add a **Delete object** rule with these conditions:

317 

318- **Object name matches prefix**: `openai/`.

319- **Age**: 30 days.

320 

321![Google Cloud lifecycle rule showing Delete object, the openai/ object prefix, and Age 30.](https://developers.openai.com/images/platform/guides/private-safety-processing/setup-gcp-lifecycle-rule.webp)

322 

323#### 3. Find your Google Cloud project number

324 

325In **IAM & Admin > Settings**, copy the numeric **Project number** for the project containing your workload identity pool as `<CUSTOMER_GCP_PROJECT_NUMBER>`.

326 

327#### 4. Create the workload identity pool and provider

328 

329In **IAM & Admin > Workload Identity Federation**, create a workload identity pool and add an **OpenID Connect (OIDC)** provider with:

330 

331- **Issuer (URL)**: `https://accounts.google.com`.

332- **Allowed audiences**: `<CUSTOMER_PROJECT_ID>` (your OpenAI project ID).

333 

334![Google Cloud OIDC provider setup showing the Google issuer URL and an OpenAI project ID as the allowed audience.](https://developers.openai.com/images/platform/guides/private-safety-processing/setup-gcp-oidc-provider.webp)

335 

336Configure these attribute mappings:

337 

338| Google attribute | OIDC value |

339| -------------------------- | --------------- |

340| `google.subject` | `assertion.sub` |

341| `attribute.openai_project` | `assertion.aud` |

342 

343Set the attribute condition below. **Keep OpenAI's production identity subject `112981926705442324573` unchanged.**

344 

345```text

346assertion.sub == '112981926705442324573' && assertion.aud == '<CUSTOMER_PROJECT_ID>'

347```

348 

349![Google Cloud provider attributes mapping google.subject to assertion.sub and attribute.openai_project to assertion.aud, with the condition restricting the OpenAI production subject and project audience.](https://developers.openai.com/images/platform/guides/private-safety-processing/setup-gcp-provider-attributes.webp)

350 

351Record the pool and provider IDs as `<CUSTOMER_GCP_POOL_ID>` and `<CUSTOMER_GCP_PROVIDER_ID>`.

352 

353**Multiple OpenAI projects**

354 

355For projects belonging to the same customer, you can reuse the pool and provider. Add each project ID to **Allowed audiences** and update the attribute condition:

356 

357```text

358assertion.sub == '112981926705442324573' &&

359(assertion.aud == '<CUSTOMER_PROJECT_ID_1>' || assertion.aud == '<CUSTOMER_PROJECT_ID_2>')

360```

361 

362Complete the bucket grant and storage registration for each project separately.

363 

364#### 5. Create the custom storage role

365 

366In **IAM & Admin > Roles**, create a custom role in the bucket's Google Cloud project with these permissions:

367 

368```text

369storage.buckets.get

370storage.objects.create

371storage.objects.get

372storage.objects.delete

373```

374 

375#### 6. Grant OpenAI access to the bucket

376 

377In your bucket's **Permissions > Grant access**, add this principal:

378 

379```text

380principalSet://iam.googleapis.com/projects/<CUSTOMER_GCP_PROJECT_NUMBER>/locations/global/workloadIdentityPools/<CUSTOMER_GCP_POOL_ID>/attribute.openai_project/<CUSTOMER_PROJECT_ID>

381```

382 

383Select the custom role you created in step 5.

384 

385![Google Cloud bucket access form with the OpenAI project principal set and the custom storage role selected.](https://developers.openai.com/images/platform/guides/private-safety-processing/setup-gcp-bucket-access.webp)

386 

387Continue to **Register your storage**.

388 

389 

390 

391 

392 

291### Register your storage393### Register your storage

292 394 

293After completing the cloud setup above, use either the API console or the Management API to register and validate your storage. You only need to use one method.395After completing the cloud setup above, use either the API console or the Management API to register and validate your storage. You only need to use one method.


304 406 

305##### 2. Enter your storage details407##### 2. Enter your storage details

306 408 

307Choose **AWS** or **Azure**, then select the project. If you opened the modal from project settings, that project is already selected. If **Registered storage** appears, choose **Connect new storage** to add a destination.409Choose **AWS**, **Azure**, or **GCP**, then select the project. If you opened the modal from project settings, that project is already selected. If **Registered storage** appears, choose **Connect new storage** to add a destination.

308 410 

309For **AWS**, enter the **Bucket ARN** and **IAM role ARN** from your cloud setup.411For **AWS**, enter the **Bucket ARN** and **IAM role ARN** from your cloud setup.

310 412 


314 416 

315![Connect external storage dialog for Azure showing the project and Azure storage configuration fields.](https://developers.openai.com/images/platform/guides/private-safety-processing/setup-08-platform-azure-connect.webp)417![Connect external storage dialog for Azure showing the project and Azure storage configuration fields.](https://developers.openai.com/images/platform/guides/private-safety-processing/setup-08-platform-azure-connect.webp)

316 418 

419For **GCP**, select the OpenAI project whose ID you used in the audience, attribute condition, and bucket grant. Enter these four fields:

420 

421| Field | Value from your Google Cloud setup |

422| ------------------------------------ | -------------------------------------------------------------------------------------------- |

423| **Bucket name** | `<CUSTOMER_GCP_BUCKET_NAME>` |

424| **Workload identity project number** | `<CUSTOMER_GCP_PROJECT_NUMBER>`: the numeric Google Cloud project number containing the pool |

425| **Workload identity pool ID** | `<CUSTOMER_GCP_POOL_ID>` |

426| **Workload identity provider ID** | `<CUSTOMER_GCP_PROVIDER_ID>` |

427 

317##### 3. Connect and validate428##### 3. Connect and validate

318 429 

319Select **Connect and validate**. The API console registers the storage, runs validation, and refreshes the storage status and project policy. Registration alone doesn't change the policy.430Select **Connect and validate**. The API console registers the storage, runs validation, and refreshes the storage status and project policy. Registration alone doesn't change the policy.


383 }'494 }'

384```495```

385 496 

497**Google Cloud Storage**

498 

499```bash

500curl --fail-with-body -sS -X POST "$OPENAI_STORAGE_URL" \

501 -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \

502 -H "OpenAI-Organization: $OPENAI_ORG_ID" \

503 -H 'Content-Type: application/json' \

504 --data-binary '{

505 "project_id": "<CUSTOMER_PROJECT_ID>",

506 "provider": {

507 "type": "gcp",

508 "bucket": "<CUSTOMER_GCP_BUCKET_NAME>",

509 "workload_identity_project_number": "<CUSTOMER_GCP_PROJECT_NUMBER>",

510 "workload_identity_pool_id": "<CUSTOMER_GCP_POOL_ID>",

511 "workload_identity_provider_id": "<CUSTOMER_GCP_PROVIDER_ID>"

512 }

513 }'

514```

515 

386The response contains an `id` beginning with `extstorage_` and `status: "pending"`. Keep the ID for validation. The API console shows **Pending validation** and leaves the project's retention policy unchanged.516The response contains an `id` beginning with `extstorage_` and `status: "pending"`. Keep the ID for validation. The API console shows **Pending validation** and leaves the project's retention policy unchanged.

387 517 

388##### 3. Verify your setup518##### 3. Verify your setup

Details

19The prompt optimizer can use the following from your dataset to improve your prompt:19The prompt optimizer can use the following from your dataset to improve your prompt:

20 20 

21- Annotations (Good/Bad and additional custom annotation columns you add)21- Annotations (Good/Bad and additional custom annotation columns you add)

22- Text critiques written in **output_feedback**22- Text critiques written in **`output_feedback`**

23- Results from graders23- Results from graders

24 24 

25For effective results, add annotations containing a Good/Bad rating _and_ detailed, specific critiques. Create [graders](https://developers.openai.com/api/docs/guides/evaluation-getting-started#add-graders) that precisely capture the properties that you desire from your prompt.25For effective results, add annotations containing a Good/Bad rating _and_ detailed, specific critiques. Create [graders](https://developers.openai.com/api/docs/guides/evaluation-getting-started#add-graders) that precisely capture the properties that you desire from your prompt.

guides/rbac.md +6 −7

Details

15- **Project**: A workspace for keys, files, and resources. Project roles grant access within only that project.15- **Project**: A workspace for keys, files, and resources. Project roles grant access within only that project.

16- **Groups**: Collections of users you can assign roles to. Groups can be synced from your identity provider (via SCIM) to keep membership up to date automatically.16- **Groups**: Collections of users you can assign roles to. Groups can be synced from your identity provider (via SCIM) to keep membership up to date automatically.

17- **Roles**: Bundles of permissions (like Models Request or Files Write). Roles can be created for the organization under **Organization settings**, or created for a specific project under that project's settings. Once created, organization or project roles can be assigned to users or groups. Users can have multiple roles, and their access is the union of those roles.17- **Roles**: Bundles of permissions (like Models Request or Files Write). Roles can be created for the organization under **Organization settings**, or created for a specific project under that project's settings. Once created, organization or project roles can be assigned to users or groups. Users can have multiple roles, and their access is the union of those roles.

18- **Permissions**: The specific actions a role allows (e.g., make request to models, read files, write files, manage keys).18- **Permissions**: The specific actions a role allows (for example, make requests to models, read files, write files, manage keys).

19 19 

20### Permissions20### Permissions

21 21 


52| Project Administration | Manage project users, service accounts, API keys, and rate limits via management API | `Read`, `Write` | | `Read`, `Write` | | | |52| Project Administration | Manage project users, service accounts, API keys, and rate limits via management API | `Read`, `Write` | | `Read`, `Write` | | | |

53| Batch | Create and manage batch jobs | `Read`, `Write` | `Read`, `Write` | `Read`, `Write` | `Read`, `Write` | `Read` | |53| Batch | Create and manage batch jobs | `Read`, `Write` | `Read`, `Write` | `Read`, `Write` | `Read`, `Write` | `Read` | |

54| Service Accounts | View and manage project service accounts | `Read`, `Write` | | `Read`, `Write` | | | |54| Service Accounts | View and manage project service accounts | `Read`, `Write` | | `Read`, `Write` | | | |

55| Videos | Create and retrieve videos | `Read`, `Write` | `Read`, `Write` | `Read`, `Write` | `Read`, `Write` | | |

56| Voices | Create and retrieve voices | `Read`, `Write` | `Read`, `Write` | `Read`, `Write` | `Read`, `Write` | `Read` | |55| Voices | Create and retrieve voices | `Read`, `Write` | `Read`, `Write` | `Read`, `Write` | `Read`, `Write` | `Read` | |

57| Agent Builder | Create and manage agents and workflows in Agent Builder | `Read`, `Write` | `Read` | `Read`, `Write` | `Read`, `Write` | `Read` | ✓ |56| Agent Builder | Create and manage agents and workflows in Agent Builder | `Read`, `Write` | `Read` | `Read`, `Write` | `Read`, `Write` | `Read` | ✓ |

58 57 


64Batch permissions include access required to prepare batch input files, execute requests, and retrieve results. This effective access is separate from the endpoints that can be submitted inside a batch, which are listed in the [Batch API guide](https://developers.openai.com/api/docs/guides/batch#1-prepare-your-batch-file).63Batch permissions include access required to prepare batch input files, execute requests, and retrieve results. This effective access is separate from the endpoints that can be submitted inside a batch, which are listed in the [Batch API guide](https://developers.openai.com/api/docs/guides/batch#1-prepare-your-batch-file).

65 64 

66| Batch permission | Additional access granted |65| Batch permission | Additional access granted |

67| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |66| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

68| Read (`api.batch.read`) | Files Read (`api.files.read`) for `/v1/files` |67| Read (`api.batch.read`) | Files Read (`api.files.read`) for `/v1/files` |

69| Write (`api.batch.write`) | Batch Read<br />List models (`api.model.read` and `model.read`) for `/v1/models`<br />Files Read and Write (`api.files.read` and `api.files.write`) for `/v1/files`<br />Model capabilities Request (`api.model.request` and `model.request`) for `/v1/audio`, `/v1/chat/completions`, `/v1/embeddings`, `/v1/images`, `/v1/moderations`, `/v1/realtime`, and `/v1/responses`<br />Videos Read and Write (`api.videos.read` and `api.videos.write`) for `/v1/videos` |68| Write (`api.batch.write`) | Batch Read<br />List models (`api.model.read` and `model.read`) for `/v1/models`<br />Files Read and Write (`api.files.read` and `api.files.write`) for `/v1/files`<br />Model capabilities Request (`api.model.request` and `model.request`) for `/v1/audio`, `/v1/chat/completions`, `/v1/embeddings`, `/v1/images`, `/v1/moderations`, `/v1/realtime`, and `/v1/responses` |

70 69 

71## Setting up RBAC70## Setting up RBAC

72 71 

73Allow up to **30 minutes** for role changes and group sync to propagate.72Allow up to **30 minutes** for role changes and group sync to propagate.

74 73 

751. **Create groups**741. **Create groups**

76 Add groups for teams (e.g., “Data Science”, “Support”). If you use an IdP, enable SCIM sync so group membership stays current.75 Add groups for teams (for example, **Data Science** and **Support**). If you use an IdP, enable SCIM sync so group membership stays current.

77 76 

782. **Create custom roles**772. **Create custom roles**

79 Start from least privilege. For example:78 Start from least privilege. For example:


90 Use a non-owner account to confirm expected access (API and Dashboard). Adjust roles if users can see more than they need.89 Use a non-owner account to confirm expected access (API and Dashboard). Adjust roles if users can see more than they need.

91 90 

92Use the principle of least privilege. Start with the minimum permissions91Use the principle of least privilege. Start with the minimum permissions

93 required for a task, then add more only as needed.92 required for a task, then add permissions only as needed.

94 93 

95## Access configuration examples94## Access configuration examples

96 95 


101 100 

102### Larger org101### Larger org

103 102 

104- Sync groups from your IdP (e.g., “Research”, “Support”, “Finance”).103- Sync groups from your IdP (for example, **Research**, **Support**, and **Finance**).

105- Create custom roles per function and assign at the org level; or only grant project-specific roles when a project needs tighter controls.104- Create custom roles per function and assign at the org level; or only grant project-specific roles when a project needs tighter controls.

106 105 

107### Contractors & vendors106### Contractors & vendors

Details

59 output: {59 output: {

60 format: {60 format: {

61 type: "audio/pcm",61 type: "audio/pcm",

62 rate: 24000,

62 },63 },

63 voice: "marin",64 voice: "marin",

64 },65 },

Details

487 487 

488For reinforcement fine-tuning jobs, the primary metrics are the per-step **reward** metrics. These metrics indicate how well your model is performing on the training data. They're calculated by the graders you defined in your job configuration. These are two separate top-level reward metrics:488For reinforcement fine-tuning jobs, the primary metrics are the per-step **reward** metrics. These metrics indicate how well your model is performing on the training data. They're calculated by the graders you defined in your job configuration. These are two separate top-level reward metrics:

489 489 

490- `train_reward_mean`: The average reward across the samples taken from all datapoints in the current step. Because the specific datapoints in a batch change with each step, `train_reward_mean` values across different steps are not directly comparable and the specific values can fluctuate drastically from step to step.490- `train_reward_mean`: The average reward across the samples taken from all data points in the current step. Because the specific data points in a batch change with each step, `train_reward_mean` values across different steps are not directly comparable and the specific values can fluctuate drastically from step to step.

491- `valid_reward_mean`: The average reward across the samples taken from all datapoints in the validation set, which is a more stable metric.491- `valid_reward_mean`: The average reward across the samples taken from all data points in the validation set, which is a more stable metric.

492 492 

493![Reward Metric Graph](https://cdn.openai.com/API/images/guides/RFT_Reward_Chart.png)493![Reward Metric Graph](https://cdn.openai.com/API/images/guides/RFT_Reward_Chart.png)

494 494 


878 878 

879You can find the eval associated with your fine-tuning job by viewing your job on the fine-tuning dashboard, or by finding the `eval_id` field on the [fine-tuning job object](https://developers.openai.com/api/reference/resources/fine_tuning).879You can find the eval associated with your fine-tuning job by viewing your job on the fine-tuning dashboard, or by finding the `eval_id` field on the [fine-tuning job object](https://developers.openai.com/api/reference/resources/fine_tuning).

880 880 

881The evals product is useful for inspecting the outputs of the model on specific datapoints, to get an understanding for how the model is behaving in different scenarios. It can help you figure out which slice of your dataset the model is performing poorly on which can help you identify areas for improvement in your training data.881The evals product is useful for inspecting the outputs of the model on specific data points, to get an understanding for how the model is behaving in different scenarios. It can help you figure out which slice of your dataset the model is performing poorly on which can help you identify areas for improvement in your training data.

882 882 

883The evals product can also help you find areas of improvement for your graders by finding areas where the grader is either overly lenient or overly harsh on the model outputs.883The evals product can also help you find areas of improvement for your graders by finding areas where the grader is either overly lenient or overly harsh on the model outputs.

884 884 


892 892 

893If you are training your model to [perform tool calls](https://developers.openai.com/api/docs/guides/function-calling), you will need to:893If you are training your model to [perform tool calls](https://developers.openai.com/api/docs/guides/function-calling), you will need to:

894 894 

8951. Provide the set of tools available for your model to call on each datapoint in the RFT training dataset. More info here in the [dataset API reference](https://developers.openai.com/api/reference/resources/fine_tuning).8951. Provide the set of tools available for your model to call on each data point in the RFT training dataset. More info here in the [dataset API reference](https://developers.openai.com/api/reference/resources/fine_tuning).

8962. Configure your grader to assign rewards based on the contents of the tool calls made by the model. Information on grading tools calls can be found [here in the grading docs](https://developers.openai.com/api/docs/guides/graders/#sample-namespace)8962. Configure your grader to assign rewards based on the contents of the tool calls made by the model. Information on grading tools calls can be found [here in the grading docs](https://developers.openai.com/api/docs/guides/graders/#sample-namespace)

897 897 

898### Billing details898### Billing details


903 903 

904### Training errors904### Training errors

905 905 

906Reinforcement fine-tuning is a complex process with many moving parts, and there are many places where things can go wrong. We publish various error metrics to help you understand what is going wrong in your job, and how to fix it. In general, we try to avoid failing a job entirely unless a very serious error occurs. When errors do occur, they often happen during the grading step. Errors during grading often happen either to the model outputting a sample that the grader doesn't know how to handle, the grader failing to execute properly due to some sort of system error, or due to a bug in the grading logic itself.906Reinforcement fine-tuning is a complex process with many moving parts, and there are many places where things can go wrong. We publish various error metrics to help you understand what is going wrong in your job, and how to fix it. In general, we try to avoid failing a job entirely unless a particularly serious error occurs. When errors do occur, they often happen during the grading step. Errors during grading often happen either to the model outputting a sample that the grader doesn't know how to handle, the grader failing to execute properly due to some sort of system error, or due to a bug in the grading logic itself.

907 907 

908The error metrics are available under the `event.data.errors` object, and are aggregated into counts and rates rolled up per-grader. We also display rates and counts of errors on the fine-tuning dashboard.908The error metrics are available under the `event.data.errors` object, and are aggregated into counts and rates rolled up per-grader. We also display rates and counts of errors on the fine-tuning dashboard.

909 909 


918The grader errors are broken down into the following categories, and they exist in both `train_` (for training data) and `valid_` (for validation data) versions:918The grader errors are broken down into the following categories, and they exist in both `train_` (for training data) and `valid_` (for validation data) versions:

919 919 

920- `sample_parse_error_mean`: The average number of samples that failed to parse correctly. This often happens when the model fails to output valid JSON or adhere to a provided response format correctly. A small percentage of these errors, especially early in the training process, is normal. If you see a large number of these errors, it is likely that the response format of the model is not configured correctly or that your graders are misconfigured and looking for incorrect fields.920- `sample_parse_error_mean`: The average number of samples that failed to parse correctly. This often happens when the model fails to output valid JSON or adhere to a provided response format correctly. A small percentage of these errors, especially early in the training process, is normal. If you see a large number of these errors, it is likely that the response format of the model is not configured correctly or that your graders are misconfigured and looking for incorrect fields.

921- `invalid_variable_error_mean`: These errors occur when you attempt to reference a variable via a template that cannot be found either in the current datapoint or in the current model sample. This can happen if the model fails to provide output in the correct response format, or if your grader is misconfigured.921- `invalid_variable_error_mean`: These errors occur when you attempt to reference a variable via a template that cannot be found either in the current data point or in the current model sample. This can happen if the model fails to provide output in the correct response format, or if your grader is misconfigured.

922- `other_error_mean`: This is a catch-all for any other errors that occur during grading. These errors are often caused by bugs in the grading logic itself, or by system errors that occur during grading.922- `other_error_mean`: This is a catch-all for any other errors that occur during grading. These errors are often caused by bugs in the grading logic itself, or by system errors that occur during grading.

923 923 

924#### Python grading errors924#### Python grading errors

Details

474 474 

475### Use checkpoints if needed475### Use checkpoints if needed

476 476 

477Checkpoints are models you can use. We create a full model checkpoint for you at the end of each training epoch. They're useful in cases where your fine-tuned model improves early on but then memorizes the dataset instead of learning generalizable knowledge—called \_overfitting. Checkpoints provide versions of your customized model from various moments in the process.477Checkpoints are models you can use. We create a full model checkpoint for you at the end of each training epoch. They're useful in cases where your fine-tuned model improves early on but then memorizes the dataset instead of learning generalizable knowledge—called overfitting. Checkpoints provide versions of your customized model from various moments in the process.

478 478 

479 479 

480 480 

guides/tools.md +12 −2

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 

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.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.

8 8 

9 9 

10 10 


1085 1085 

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

1087 1087 

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.1088 

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.

1089 1099 

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

1091- Expose a specialist as a tool when a manager should stay in control of the user-facing reply.1101- 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 

11## Get started with traces13## Get started with traces

12 14 

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

guides/video-generation.md +0 −790 deleted

File Deleted View Diff

1# Video generation with Sora

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.

4 

5## Overview

6 

7Sora is OpenAI’s newest frontier in generative media – a state-of-the-art video model capable of creating richly detailed, dynamic clips with audio from natural language or images. Built on years of research into multimodal diffusion and trained on diverse visual data, Sora brings a deep understanding of 3D space, motion, and scene continuity to text-to-video generation.

8 

9The [Videos API](https://developers.openai.com/api/reference/resources/videos) exposes these capabilities to developers for the first time, enabling programmatic creation, extension, editing, and management of videos.

10 

11You can use it to:

12 

13- Create new videos from prompts.

14- Guide a generation with an image reference.

15- Reuse character assets across multiple generations for stronger visual consistency.

16- Continue a completed clip with video extensions.

17- Edit an existing video with targeted changes.

18- Download finished videos and supporting assets.

19- Submit large offline render queues through the [Batch API](https://developers.openai.com/api/docs/guides/batch).

20 

21## Models

22 

23The second generation Sora model comes in two variants, each tailored for different use cases.

24 

25### Sora 2

26 

27`sora-2` is designed for **speed and flexibility**. It’s ideal for the exploration phase, when you’re experimenting with tone, structure, or visual style and need quick feedback rather than perfect fidelity.

28 

29It generates good quality results quickly, making it well suited for rapid iteration, concepting, and rough cuts. `sora-2` is often more than sufficient for social media content, prototypes, and scenarios where turnaround time matters more than ultra-high fidelity.

30 

31### Sora 2 Pro

32 

33`sora-2-pro` produces higher quality results. It’s the better choice when you need **production-quality output**.

34 

35`sora-2-pro` takes longer to render and is more expensive to run, but it produces more polished, stable results. It’s best for high-resolution cinematic footage, marketing assets, and any situation where visual precision is critical.

36 

37Use `sora-2-pro` when you need 1080p exports in `1920x1080` or `1080x1920`.

38 

39Both `sora-2` and `sora-2-pro` support `16`- and `20`-second generations.

40 

41## Generate a video

42 

43Generating a video is an **asynchronous** process:

44 

451. When you call the `POST /videos` endpoint, the API returns a job object with a job `id` and an initial `status`.

46 

472. You can either poll the `GET /videos/{video_id}` endpoint until the status transitions to completed, or – for a more efficient approach – use webhooks (see the webhooks section below) to be notified automatically when the job finishes.

48 

493. Once the job has reached the `completed` state you can fetch the final MP4 file with `GET /videos/{video_id}/content`.

50 

51### Start a render job

52 

53Start by calling `POST /videos` with a text prompt and the required parameters. The prompt defines the creative look and feel – subjects, camera, lighting, and motion – while parameters like `size` and `seconds` control the video's resolution and length.

54 

55Create a video

56 

57```javascript

58import OpenAI from "openai";

59 

60const openai = new OpenAI();

61 

62let video = await openai.videos.create({

63 model: "sora-2",

64 prompt: "A video of the words 'Thank you' in sparkling letters",

65});

66 

67console.log("Video generation started: ", video);

68```

69 

70```python

71from openai import OpenAI

72 

73openai = OpenAI()

74 

75video = openai.videos.create(

76 model="sora-2",

77 prompt="A video of a cool cat on a motorcycle in the night",

78)

79 

80print("Video generation started:", video)

81```

82 

83```go

84package main

85 

86import (

87 "context"

88 "fmt"

89 

90 "github.com/openai/openai-go/v3"

91)

92 

93func main() {

94 client := openai.NewClient()

95 video, err := client.Videos.New(context.Background(), openai.VideoNewParams{

96 Model: openai.VideoModelSora2,

97 Prompt: "A video of the words 'Thank you' in sparkling letters",

98 })

99 if err != nil {

100 panic(err)

101 }

102 fmt.Println("Video generation started:", video)

103}

104```

105 

106```java

107import com.openai.client.OpenAIClient;

108import com.openai.client.okhttp.OpenAIOkHttpClient;

109import com.openai.models.videos.VideoCreateParams;

110 

111var video =

112 client

113 .videos()

114 .create(

115 VideoCreateParams.builder()

116 .model("sora-2")

117 .prompt("A paper airplane flying over a forest")

118 .build());

119 

120System.out.println(video.id());

121```

122 

123```ruby

124require "openai"

125 

126client = OpenAI::Client.new

127video = client.videos.create(model: "sora-2", prompt: "A paper airplane flying over a forest")

128puts(video.id)

129```

130 

131```bash

132curl -X POST "https://api.openai.com/v1/videos" \

133 -H "Authorization: Bearer $OPENAI_API_KEY" \

134 -H "Content-Type: multipart/form-data" \

135 -F prompt="Wide tracking shot of a teal coupe driving through a desert highway, heat ripples visible, hard sun overhead." \

136 -F model="sora-2-pro" \

137 -F size="1280x720" \

138 -F seconds="8" \

139```

140 

141 

142The response is a JSON object with a unique id and an initial status such as `queued` or `in_progress`. This means the render job has started.

143 

144```shell

145{

146 "id": "video_68d7512d07848190b3e45da0ecbebcde004da08e1e0678d5",

147 "object": "video",

148 "created_at": 1758941485,

149 "status": "queued",

150 "model": "sora-2-pro",

151 "progress": 0,

152 "seconds": "8",

153 "size": "1280x720"

154}

155```

156 

157### Choose size and duration

158 

159Pick the smallest format that meets your production needs:

160 

161- Use shorter clips when you are iterating on prompt, motion, or composition.

162- Generate videos up to `20` seconds when you need longer beats, fuller scenes, or fuller spots.

163- Use `sora-2-pro` for higher-resolution exports in `1920x1080` or `1080x1920`.

164 

165Longer durations and 1080p jobs can take materially longer to complete than short 720p or 480p renders, so plan for higher latency in user-facing flows.

166 

167### Guardrails and restrictions

168 

169The API enforces several content restrictions:

170 

171- Only content suitable for audiences under 18 (a setting to bypass this restriction will be available in the future).

172- Copyrighted characters and copyrighted music will be rejected.

173- Real people—including public figures—cannot be generated.

174- Character uploads that depict human likeness are blocked by default.

175- Input images with faces of humans are currently rejected.

176 

177Make sure prompts, reference images, and transcripts respect these rules to avoid failed generations.

178 

179### Effective prompting

180 

181For best results, describe **shot type, subject, action, setting, and lighting**. For example:

182 

183- _“Wide shot of a child flying a red kite in a grassy park, golden hour sunlight, camera slowly pans upward.”_

184- _“Close-up of a steaming coffee cup on a wooden table, morning light through blinds, soft depth of field.”_

185 

186This level of specificity helps the model produce consistent results without inventing unwanted details. For more advanced prompting techniques, please refer to our dedicated Sora 2 [prompting guide](https://developers.openai.com/cookbook/examples/sora/sora2_prompting_guide).

187 

188### Monitor progress

189 

190Video generation takes time. Depending on model, API load and resolution, **a single render may take several minutes**.

191 

192To manage this efficiently, you can poll the API to request status updates or you can get notified via a webhook.

193 

194#### Poll the status endpoint

195 

196Call `GET /videos/{video_id}` with the id returned from the create call. The response shows the job’s current status, progress percentage (if available), and any errors.

197 

198Typical states are `queued`, `in_progress`, `completed`, and `failed`. Poll at a reasonable interval (for example, every 10–20 seconds), use exponential backoff if necessary, and provide feedback to users that the job is still in progress.

199 

200Poll the status endpoint

201 

202```javascript

203import OpenAI from "openai";

204import { setTimeout as sleep } from "node:timers/promises";

205 

206const openai = new OpenAI();

207 

208async function main() {

209 let video = await openai.videos.create({

210 model: "sora-2",

211 prompt: "A video of the words 'Thank you' in sparkling letters",

212 });

213 

214 while (video.status === "queued" || video.status === "in_progress") {

215 await sleep(2000);

216 video = await openai.videos.retrieve(video.id);

217 }

218 

219 if (video.status === "completed") {

220 console.log("Video successfully completed: ", video);

221 } else {

222 console.log("Video creation failed. Status: ", video.status);

223 }

224}

225 

226main();

227```

228 

229```python

230import asyncio

231 

232from openai import AsyncOpenAI

233 

234client = AsyncOpenAI()

235 

236 

237async def main() -> None:

238 video = await client.videos.create_and_poll(

239 model="sora-2",

240 prompt="A video of a cat on a motorcycle",

241 )

242 

243 if video.status == "completed":

244 print("Video successfully completed: ", video)

245 else:

246 print("Video creation failed. Status: ", video.status)

247 

248 

249asyncio.run(main())

250```

251 

252```go

253package main

254 

255import (

256 "context"

257 "fmt"

258 

259 "github.com/openai/openai-go/v3"

260)

261 

262func main() {

263 client := openai.NewClient()

264 video, err := client.Videos.NewAndPoll(context.Background(), openai.VideoNewParams{

265 Model: openai.VideoModelSora2,

266 Prompt: "A video of the words 'Thank you' in sparkling letters",

267 }, 2000)

268 if err != nil {

269 panic(err)

270 }

271 if video.Status == openai.VideoStatusCompleted {

272 fmt.Println("Video successfully completed:", video)

273 return

274 }

275 fmt.Println("Video creation failed. Status:", video.Status)

276}

277```

278 

279```java

280import com.openai.client.OpenAIClient;

281import com.openai.client.okhttp.OpenAIOkHttpClient;

282import com.openai.models.videos.Video;

283import com.openai.models.videos.VideoCreateParams;

284 

285var video =

286 client

287 .videos()

288 .create(

289 VideoCreateParams.builder()

290 .model("sora-2")

291 .prompt("A paper airplane flying over a forest")

292 .build());

293 

294while (video.status().equals(Video.Status.QUEUED)

295 || video.status().equals(Video.Status.IN_PROGRESS)) {

296 Thread.sleep(1000);

297 video = client.videos().retrieve(video.id());

298}

299if (!video.status().equals(Video.Status.COMPLETED)) {

300 throw new IllegalStateException("Video generation failed: " + video.status());

301}

302System.out.println("Video completed: " + video.id());

303```

304 

305```ruby

306require "openai"

307 

308client = OpenAI::Client.new

309video = client.videos.create(model: "sora-2", prompt: "A paper airplane flying over a forest")

310 

311while [:queued, :in_progress].include?(video.status)

312 sleep(2)

313 video = client.videos.retrieve(video.id)

314end

315 

316unless video.status == OpenAI::Models::Video::Status::COMPLETED

317 raise "Video creation failed. Status: #{video.status}"

318end

319 

320puts("Video successfully completed: #{video.id}")

321```

322 

323 

324Response example:

325 

326```shell

327{

328 "id": "video_68d7512d07848190b3e45da0ecbebcde004da08e1e0678d5",

329 "object": "video",

330 "created_at": 1758941485,

331 "status": "in_progress",

332 "model": "sora-2-pro",

333 "progress": 33,

334 "seconds": "8",

335 "size": "1280x720"

336}

337```

338 

339#### Use webhooks for notifications

340 

341Instead of polling job status repeatedly with `GET`, register a [webhook](https://developers.openai.com/api/docs/guides/webhooks) to be notified automatically when a video generation completes or fails.

342 

343Webhooks can be configured in your [webhook settings page](https://platform.openai.com/settings/project/webhooks). When a job finishes, the API emits one of two event types: `video.completed` and `video.failed`. Each event includes the ID of the job that triggered it.

344 

345Example webhook payload:

346 

347```

348{

349 "id": "evt_abc123",

350 "object": "event",

351 "created_at": 1758941485,

352 "type": "video.completed", // or "video.failed"

353 "data": {

354 "id": "video_abc123"

355 }

356}

357```

358 

359### Retrieve results

360 

361#### Download the MP4

362 

363Once the job reaches status `completed`, fetch the MP4 with `GET /videos/{video_id}/content`. This endpoint streams the binary video data and returns standard content headers, so you can either save the file directly to disk or pipe it to cloud storage.

364 

365Download the MP4

366 

367```javascript

368import { writeFileSync } from "node:fs";

369 

370import OpenAI from "openai";

371 

372const openai = new OpenAI();

373 

374let video = await openai.videos.create({

375 model: "sora-2",

376 prompt: "A video of the words 'Thank you' in sparkling letters",

377});

378 

379console.log("Video generation started: ", video);

380let progress = video.progress ?? 0;

381 

382while (video.status === "in_progress" || video.status === "queued") {

383 video = await openai.videos.retrieve(video.id);

384 progress = video.progress ?? 0;

385 

386 // Display progress bar

387 const barLength = 30;

388 const filledLength = Math.floor((progress / 100) * barLength);

389 // Simple ASCII progress visualization for terminal output

390 const bar = "=".repeat(filledLength) + "-".repeat(barLength - filledLength);

391 const statusText = video.status === "queued" ? "Queued" : "Processing";

392 

393 process.stdout.write(`${statusText}: [${bar}] ${progress.toFixed(1)}%`);

394 

395 await new Promise((resolve) => setTimeout(resolve, 2000));

396}

397 

398// Clear the progress line and show completion

399process.stdout.write("\n");

400 

401if (video.status === "failed") {

402 throw new Error("Video generation failed");

403}

404 

405console.log("Video generation completed: ", video);

406 

407console.log("Downloading video content...");

408 

409const content = await openai.videos.downloadContent(video.id);

410 

411const body = content.arrayBuffer();

412const buffer = Buffer.from(await body);

413 

414writeFileSync("video.mp4", buffer);

415 

416console.log("Wrote video.mp4");

417```

418 

419```python

420from openai import OpenAI

421import sys

422import time

423 

424 

425openai = OpenAI()

426 

427video = openai.videos.create(

428 model="sora-2",

429 prompt="A video of a cool cat on a motorcycle in the night",

430)

431 

432print("Video generation started:", video)

433 

434progress = getattr(video, "progress", 0)

435bar_length = 30

436 

437while video.status in ("in_progress", "queued"):

438 # Refresh status

439 video = openai.videos.retrieve(video.id)

440 progress = getattr(video, "progress", 0)

441 

442 filled_length = int((progress / 100) * bar_length)

443 bar = "=" * filled_length + "-" * (bar_length - filled_length)

444 status_text = "Queued" if video.status == "queued" else "Processing"

445 

446 sys.stdout.write(f"\r{status_text}: [{bar}] {progress:.1f}%")

447 sys.stdout.flush()

448 time.sleep(2)

449 

450# Move to next line after progress loop

451sys.stdout.write("\n")

452 

453if video.status == "failed":

454 message = getattr(

455 getattr(video, "error", None), "message", "Video generation failed"

456 )

457 raise RuntimeError(message)

458 

459print("Video generation completed:", video)

460print("Downloading video content...")

461 

462content = openai.videos.download_content(video.id, variant="video")

463content.write_to_file("video.mp4")

464 

465print("Wrote video.mp4")

466```

467 

468```go

469package main

470 

471import (

472 "context"

473 "fmt"

474 "io"

475 "os"

476 

477 "github.com/openai/openai-go/v3"

478)

479 

480func main() {

481 client := openai.NewClient()

482 video, err := client.Videos.NewAndPoll(context.Background(), openai.VideoNewParams{

483 Model: openai.VideoModelSora2,

484 Prompt: "A video of the words 'Thank you' in sparkling letters",

485 }, 2000)

486 if err != nil {

487 panic(err)

488 }

489 if video.Status != openai.VideoStatusCompleted {

490 panic(fmt.Errorf("video generation failed with status %s", video.Status))

491 }

492 

493 response, err := client.Videos.DownloadContent(context.Background(), video.ID, openai.VideoDownloadContentParams{})

494 if err != nil {

495 panic(err)

496 }

497 defer response.Body.Close()

498 file, err := os.Create("video.mp4")

499 if err != nil {

500 panic(err)

501 }

502 if _, err := io.Copy(file, response.Body); err != nil {

503 panic(err)

504 }

505 if err := file.Close(); err != nil {

506 panic(err)

507 }

508 fmt.Println("Wrote video.mp4")

509}

510```

511 

512```java

513import com.openai.client.OpenAIClient;

514import com.openai.client.okhttp.OpenAIOkHttpClient;

515import com.openai.models.videos.Video;

516import com.openai.models.videos.VideoCreateParams;

517import java.nio.file.Files;

518import java.nio.file.Path;

519import java.nio.file.StandardCopyOption;

520 

521var video =

522 client

523 .videos()

524 .create(

525 VideoCreateParams.builder()

526 .model("sora-2")

527 .prompt("A video of the words 'Thank you' in sparkling letters")

528 .build());

529 

530while (video.status().equals(Video.Status.QUEUED)

531 || video.status().equals(Video.Status.IN_PROGRESS)) {

532 Thread.sleep(1000);

533 video = client.videos().retrieve(video.id());

534}

535if (!video.status().equals(Video.Status.COMPLETED)) {

536 throw new IllegalStateException("Video generation failed: " + video.status());

537}

538try (var content = client.videos().downloadContent(video.id())) {

539 Files.copy(content.body(), Path.of("video.mp4"), StandardCopyOption.REPLACE_EXISTING);

540}

541System.out.println("Wrote video.mp4");

542```

543 

544```ruby

545require "openai"

546 

547client = OpenAI::Client.new

548video = client.videos.create(

549 model: "sora-2",

550 prompt: "A video of the words 'Thank you' in sparkling letters"

551)

552pending_statuses = [

553 OpenAI::Models::Video::Status::QUEUED,

554 OpenAI::Models::Video::Status::IN_PROGRESS

555]

556while pending_statuses.include?(video.status)

557 sleep(2)

558 video = client.videos.retrieve(video.id)

559end

560raise "Video generation failed" if video.status == OpenAI::Models::Video::Status::FAILED

561 

562content = client.videos.download_content(video.id)

563File.binwrite("video.mp4", content.read)

564puts("Wrote video.mp4")

565```

566 

567```bash

568curl -L "https://api.openai.com/v1/videos/video_abc123/content" \

569 -H "Authorization: Bearer $OPENAI_API_KEY" \

570 --output video.mp4

571```

572 

573 

574You now have the final video file ready for playback, editing, or distribution. Download URLs are valid for a maximum of 1 hour after generation. If you need long-term storage, copy the file to your own storage system promptly.

575 

576#### Download supporting assets

577 

578For each completed video, you can also download a **thumbnail** and a **spritesheet**. These are lightweight assets useful for previews, scrubbers, or catalog displays. Use the `variant` query parameter to specify what you want to download. The default is `variant=video` for the MP4.

579 

580```bash

581# Download a thumbnail

582curl -L "https://api.openai.com/v1/videos/video_abc123/content?variant=thumbnail" \

583 -H "Authorization: Bearer $OPENAI_API_KEY" \

584 --output thumbnail.webp

585 

586# Download a spritesheet

587curl -L "https://api.openai.com/v1/videos/video_abc123/content?variant=spritesheet" \

588 -H "Authorization: Bearer $OPENAI_API_KEY" \

589 --output spritesheet.jpg

590```

591 

592 

593## Use image references

594 

595You can guide a generation with an input image, which acts as **the first frame of your video**. This is useful if you need the output video to preserve the look of a brand asset, a character, or a specific environment.

596 

597Choose the `input_reference` format based on the request type:

598 

599- Use `input_reference` with an uploaded image in `multipart/form-data` requests.

600- Use `input_reference` with a JSON object in `application/json` requests, including Batch. The JSON form accepts either `file_id` or `image_url`.

601 

602The image must match the target video's resolution (`size`).

603 

604Supported file formats are `image/jpeg`, `image/png`, and `image/webp`.

605 

606```bash

607curl -X POST "https://api.openai.com/v1/videos" \

608 -H "Authorization: Bearer $OPENAI_API_KEY" \

609 -H "Content-Type: multipart/form-data" \

610 -F prompt="She turns around and smiles, then slowly walks out of the frame." \

611 -F model="sora-2-pro" \

612 -F size="1280x720" \

613 -F seconds="8" \

614 -F input_reference="@sample_720p.jpeg;type=image/jpeg"

615```

616 

617 

618| Input image generated with [OpenAI GPT Image](https://developers.openai.com/api/docs/guides/image-generation) | Generated video using Sora 2 (converted to GIF) |

619| :---------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------: |

620| ![][sora_woman_skyline_original][Download this image](https://cdn.openai.com/API/docs/images/sora/woman_skyline_original_720p.jpeg) | ![][sora_woman_skyline_video] Prompt: _“She turns around and smiles, then slowly walks out of the frame.”_ |

621| ![][sora_monster_original_jpeg][Download this image](https://cdn.openai.com/API/docs/images/sora/monster_original_720p.jpeg) | ![][sora_monster_original_gif] Prompt: _“The fridge door opens. A cute, chubby purple monster comes out of it.”_ |

622 

623## Use characters for consistency

624 

625Characters let you upload a reusable non-human subject and reference it across multiple generations. This is useful when you want an animal, mascot, or object to keep the same core appearance, styling, and screen presence across several shots.

626 

627Character uploads currently work best with short `2`- to `4`-second clips in

628 `16:9` or `9:16`, at `720p` to `1080p`. Character source videos work best when

629 they match the aspect ratio of the requested output. If the aspect ratios

630 differ, the character can appear stretched or distorted. A single video can

631 include up to two characters.

632 

633Characters are different from `input_reference`. An image reference conditions

634the opening frame of a single generation, while a character asset can be reused

635across future video requests.

636 

637Create the character by uploading a short MP4 clip to `POST /v1/videos/characters`, then include the returned character ID in the `characters` array when you create a video.

638 

639Character uploads that depict human likeness are blocked by default. Contact

640 your account manager or [reach out to our sales

641 team](https://openai.com/contact-sales/) to learn more about eligibility for

642 human-likeness access.

643 

644```bash

645curl -X POST "https://api.openai.com/v1/videos/characters" \

646 -H "Authorization: Bearer $OPENAI_API_KEY" \

647 -H "Content-Type: multipart/form-data" \

648 -F "video=@character.mp4;type=video/mp4" \

649 -F "name=Mossy"

650```

651 

652 

653Mention the character name verbatim in your prompt. Passing the character ID

654alone isn't enough to reliably preserve the character in the shot.

655 

656Characters can be combined with `input_reference`. Extensions don't support

657characters.

658 

659```bash

660curl -X POST "https://api.openai.com/v1/videos" \

661 -H "Authorization: Bearer $OPENAI_API_KEY" \

662 -H "Content-Type: application/json" \

663 -d '{

664 "model": "sora-2",

665 "prompt": "A cinematic tracking shot of Mossy, a moss-covered teapot mascot, weaving through a lantern-lit market at dusk.",

666 "size": "1280x720",

667 "seconds": "8",

668 "characters": [

669 { "id": "char_123" }

670 ]

671 }'

672```

673 

674 

675## Extend completed videos

676 

677Video extensions let you continue an existing completed video and create a new stitched result. Provide the source video in the `video` field to `POST /v1/videos/extensions`, add a prompt describing how the scene should continue, and the API generates the next segment using the full source clip as context.

678 

679Use extensions when you want to preserve motion, camera direction, and scene continuity. If you only need to control the opening frame of a new generation, use `input_reference` instead.

680 

681Each extension can add up to `20` seconds. A single video can be extended up

682 to six times, for a maximum total length of `120` seconds. Extensions

683 currently accept only a source video and prompt. They don't support characters

684 or image references.

685 

686```bash

687curl -X POST "https://api.openai.com/v1/videos/extensions" \

688 -H "Authorization: Bearer $OPENAI_API_KEY" \

689 -H "Content-Type: application/json" \

690 -d '{

691 "video": {

692 "id": "video_abc123"

693 },

694 "prompt": "Continue the scene as the camera rises over the rooftops and reveals the sunrise.",

695 "seconds": "8"

696 }'

697```

698 

699 

700## Edit existing videos

701 

702Editing lets you take an existing video and make targeted adjustments without regenerating everything from scratch. Send `POST /v1/videos/edits` with a prompt and a `video` reference, and the system reuses the original structure, continuity, and composition while applying the modification. This works best when you make a single, well-defined change because smaller, focused edits preserve more of the original fidelity and reduce the risk of introducing artifacts.

703 

704Video generations could previously be edited using the remix endpoint, which

705 is being deprecated. Use the edits endpoint for new integrations.

706 

707The `video` field accepts either a video ID or an uploaded video. If you pass a

708video ID, the API infers the model from the source video.

709 

710Editing uploaded videos is only available to eligible customers. Contact your

711 account manager or [reach out to our sales

712 team](https://openai.com/contact-sales/) if you need this workflow.

713 

714```bash

715curl -X POST "https://api.openai.com/v1/videos/edits" \

716 -H "Authorization: Bearer $OPENAI_API_KEY" \

717 -H "Content-Type: application/json" \

718 -d '{

719 "video": {

720 "id": "video_abc123"

721 },

722 "prompt": "Shift the color palette to teal, sand, and rust, with a warm backlight."

723 }'

724```

725 

726 

727If you upload a new video instead of editing an existing generation, set

728`model` explicitly in the request.

729 

730```bash

731curl -X POST "https://api.openai.com/v1/videos/edits" \

732 -H "Authorization: Bearer $OPENAI_API_KEY" \

733 -H "Content-Type: multipart/form-data" \

734 -F "video=@source.mp4;type=video/mp4" \

735 -F "model=sora-2-pro" \

736 -F "prompt=Shift the color palette to teal, sand, and rust, with a warm backlight."

737```

738 

739 

740Editing is especially valuable for iteration because it lets you refine without discarding what already works. By constraining each edit to one clear adjustment, you keep the visual style, subject consistency, and camera framing stable, while still exploring variations in mood, palette, or staging. This makes it far easier to build polished sequences through small, reliable steps.

741 

742| Original video | Edited generated video |

743| :----------------------------: | :-----------------------------------------------------------------------------: |

744| ![][sora_monster_original_gif] | ![][sora_monster_orange] Prompt: _“Change the color of the monster to orange.”_ |

745| ![][sora_monster_original_gif] | ![][sora_monster_2monsters] Prompt: _“A second monster comes out right after.”_ |

746 

747## Run video jobs through the Batch API

748 

749Use the [Batch API](https://developers.openai.com/api/docs/guides/batch) when you need to queue many video renders for offline processing, review pipelines, or studio workflows. Each line in the batch input file uses the same JSON request body you would send to `POST /v1/videos`, which makes it a good fit for shot lists and scheduled render queues.

750 

751For video generation in Batch:

752 

753- Batch currently supports `POST /v1/videos` only.

754- Batch requests must use JSON, not multipart.

755- Upload assets ahead of time and reference them from the JSON request body.

756- Use `input_reference` for image-guided generations in Batch. In JSON requests, pass `input_reference` as an object with either `file_id` or `image_url`.

757- Multipart `input_reference` uploads, including video reference inputs, aren't supported in Batch.

758- Batch-generated videos are available for download for up to `24` hours after the batch completes.

759 

760```jsonl

761{"custom_id":"shot-001","method":"POST","url":"/v1/videos","body":{"model":"sora-2-pro","prompt":"Slow dolly shot through a miniature paper city at blue hour, soft fog, practical window lights flickering on.","size":"1920x1080","seconds":"20"}}

762{"custom_id":"shot-002","method":"POST","url":"/v1/videos","body":{"model":"sora-2-pro","prompt":"Portrait close-up of a red panda chef plating noodles in a stainless-steel kitchen, shallow depth of field.","size":"1080x1920","seconds":"16"}}

763```

764 

765When a batch reaches `completed`, the video jobs in its output have already reached a terminal state such as `completed`, `failed`, or `expired`. Use stable `custom_id` values so you can map batch results back to your internal shot IDs, editorial queue, or asset pipeline, then download final assets with the returned video IDs.

766 

767## Maintain your library

768 

769Use `GET /videos` to enumerate your videos. The endpoint supports optional query parameters for pagination and sorting.

770 

771```bash

772curl "https://api.openai.com/v1/videos?limit=20&after=video_123&order=asc" \

773 -H "Authorization: Bearer $OPENAI_API_KEY" | jq .

774```

775 

776 

777Use `DELETE /videos/{video_id}` to remove videos you no longer need from OpenAI’s storage.

778 

779```bash

780curl -X DELETE "https://api.openai.com/v1/videos/REPLACE_WITH_YOUR_VIDEO_ID" \

781 -H "Authorization: Bearer $OPENAI_API_KEY" | jq .

782```

783 

784 

785[sora_woman_skyline_original]: https://cdn.openai.com/API/docs/images/sora/sora_woman_skyline_original_2.jpeg

786[sora_woman_skyline_video]: https://cdn.openai.com/API/docs/images/sora/sora_woman_skyline_video.gif

787[sora_monster_original_jpeg]: https://cdn.openai.com/API/docs/images/sora/sora_monster_original_2.jpeg

788[sora_monster_original_gif]: https://cdn.openai.com/API/docs/images/sora/sora_monster_original.gif

789[sora_monster_orange]: https://cdn.openai.com/API/docs/images/sora/sora_monster_orange.gif

790[sora_monster_2monsters]: https://cdn.openai.com/API/docs/images/sora/sora_monster_2monsters.gif

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 

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

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 

150## Next steps148## Next steps

151 149 

152[Audio and voice overview150[Audio and voice overview

Details

95| `/v1/completions` | No | 30 days | None | Yes | No |95| `/v1/completions` | No | 30 days | None | Yes | No |

96| `/v1/live/sessions` | No | 30 days | None, or 30 days if stored | Yes, with limitations below | No |96| `/v1/live/sessions` | No | 30 days | None, or 30 days if stored | Yes, with limitations below | No |

97| `/v1/realtime` | No | 30 days | None | Yes | No |97| `/v1/realtime` | No | 30 days | None | Yes | No |

98| `/v1/videos` | No | 30 days | None | No | No |

99 98 

100#### `/v1/chat/completions`99#### `/v1/chat/completions`

101 100 


131 130 

132- Files can be manually deleted via the API or the dashboard, or can be automatically deleted by setting the `expires_after` parameter. See [here](https://developers.openai.com/api/reference/resources/files/methods/create#files_create-expires_after) for more information.131- Files can be manually deleted via the API or the dashboard, or can be automatically deleted by setting the `expires_after` parameter. See [here](https://developers.openai.com/api/reference/resources/files/methods/create#files_create-expires_after) for more information.

133 132 

134#### `/v1/videos`133#### Historical Videos API retention

135 134 

136- The `v1/videos` API includes a workflow that saves data to disk while processing and retains it for 48 hours to allow the caller to download the produced video and then for 30 days for abuse monitoring. `v1/videos` is currently blocked for MAM or ZDR requests. If your organization has data retention controls enabled, configure a project with its retention setting set to **None** as described in [Configuring data retention controls](#configuring-data-retention-controls) to use `/v1/videos` with that project.135Before the September 24, 2026 shutdown, the Videos API documentation specified 48 hours for downloading generated videos, followed by 30 days of retention for abuse monitoring. These periods describe the policy documented before shutdown; they do not promise download access after shutdown. See the [Videos API shutdown notice](https://developers.openai.com/api/docs/deprecations#2026-03-24-sora-2-video-generation-models-and-videos-api).

137 136 

138#### Image and file inputs137#### Image and file inputs

139 138 

libraries.md +18 −11

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, the Agents SDK for orchestration, or your own preferred HTTP client.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.

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.0</version>176 <version>4.69.2</version>

177</dependency>177</dependency>

178```178```

179 179 


359 359 

360 360 

361 361 

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

363 363 

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

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

366handoffs, guardrails, tracing, or sandbox execution.

367 365 

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

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

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).

370 377 

371[Agents SDK quickstart378[Agents SDK quickstart

372 379 

373 380 

374 381 

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

376 383 

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

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


400 407 

401### Dart/Flutter408### Dart/Flutter

402 409 

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

404 411 

405### Delphi412### Delphi

406 413 


444## Other OpenAI repositories451## Other OpenAI repositories

445 452 

446- [tiktoken](https://github.com/openai/tiktoken) - counting tokens453- [tiktoken](https://github.com/openai/tiktoken) - counting tokens

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

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

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

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

models.md +0 −2

Details

112- [o4-mini](/api/docs/models/o4-mini.md): Fast, cost-efficient reasoning model, succeeded by GPT-5 Mini112- [o4-mini](/api/docs/models/o4-mini.md): Fast, cost-efficient reasoning model, succeeded by GPT-5 Mini

113- [o4-mini-deep-research](/api/docs/models/o4-mini-deep-research.md): Faster, more affordable deep research model113- [o4-mini-deep-research](/api/docs/models/o4-mini-deep-research.md): Faster, more affordable deep research model

114- [omni-moderation](/api/docs/models/omni-moderation-latest.md): Identify potentially harmful content in text and images114- [omni-moderation](/api/docs/models/omni-moderation-latest.md): Identify potentially harmful content in text and images

115- [Sora 2](/api/docs/models/sora-2.md): Flagship video generation with synced audio

116- [Sora 2 Pro](/api/docs/models/sora-2-pro.md): Most advanced synced-audio video generation

117- [text-embedding-3-large](/api/docs/models/text-embedding-3-large.md): Most capable embedding model115- [text-embedding-3-large](/api/docs/models/text-embedding-3-large.md): Most capable embedding model

118- [text-embedding-3-small](/api/docs/models/text-embedding-3-small.md): Small embedding model116- [text-embedding-3-small](/api/docs/models/text-embedding-3-small.md): Small embedding model

119- [text-embedding-ada-002](/api/docs/models/text-embedding-ada-002.md): Older embedding model117- [text-embedding-ada-002](/api/docs/models/text-embedding-ada-002.md): Older embedding model

models/all.md +0 −2

Details

112- [o4-mini](/api/docs/models/o4-mini.md): Fast, cost-efficient reasoning model, succeeded by GPT-5 Mini112- [o4-mini](/api/docs/models/o4-mini.md): Fast, cost-efficient reasoning model, succeeded by GPT-5 Mini

113- [o4-mini-deep-research](/api/docs/models/o4-mini-deep-research.md): Faster, more affordable deep research model113- [o4-mini-deep-research](/api/docs/models/o4-mini-deep-research.md): Faster, more affordable deep research model

114- [omni-moderation](/api/docs/models/omni-moderation-latest.md): Identify potentially harmful content in text and images114- [omni-moderation](/api/docs/models/omni-moderation-latest.md): Identify potentially harmful content in text and images

115- [Sora 2](/api/docs/models/sora-2.md): Flagship video generation with synced audio

116- [Sora 2 Pro](/api/docs/models/sora-2-pro.md): Most advanced synced-audio video generation

117- [text-embedding-3-large](/api/docs/models/text-embedding-3-large.md): Most capable embedding model115- [text-embedding-3-large](/api/docs/models/text-embedding-3-large.md): Most capable embedding model

118- [text-embedding-3-small](/api/docs/models/text-embedding-3-small.md): Small embedding model116- [text-embedding-3-small](/api/docs/models/text-embedding-3-small.md): Small embedding model

119- [text-embedding-ada-002](/api/docs/models/text-embedding-ada-002.md): Older embedding model117- [text-embedding-ada-002](/api/docs/models/text-embedding-ada-002.md): Older embedding model

quickstart.md +41 −50

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.0</version>193 <version>4.69.2</version>

194</dependency>194</dependency>

195```195```

196 196 


382 382 

383 383 

384 384 

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

386 386 

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

388 388 


2151 2151 

2152## Build agents2152## Build agents

2153 2153 

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.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.

2155 2155 

2156Build a language triage agent2156This 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.

2157 2157 

2158```javascript2158Create and run a directory-tree script

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

2160 

2161const spanishAgent = new Agent({

2162 name: "Spanish agent",

2163 instructions: "You only speak Spanish.",

2164});

2165 2159 

2166const englishAgent = new Agent({2160```javascript

2167 name: "English agent",2161import OpenAI from "openai";

2168 instructions: "You only speak English",

2169});

2170 2162 

2171const triageAgent = new Agent({2163const client = new OpenAI();

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

2173 instructions:2165 agent: {

2174 "Handoff to the appropriate agent based on the language of the request.",2166 model: "gpt-6-astra",

2175 handoffs: [spanishAgent, englishAgent],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,

2176});2173});

2177 2174try {

2178const result = await run(triageAgent, "Hola, ¿cómo estás?");2175 for await (const event of events) {

2179console.log(result.finalOutput);2176 console.log(JSON.stringify(event));

2177 }

2178} finally {

2179 events.controller.abort();

2180}

2180```2181```

2181 2182 

2182```python2183```python

2183from agents import Agent, Runner2184from openai import OpenAI

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)

2201 

2202 

2203async def main():

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

2205 print(result.final_output)

2206 

2207 2185 

2208if __name__ == "__main__":2186with OpenAI() as client:

2209 asyncio.run(main())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)

2210```2198```

2211 2199 

2212 2200 

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 

2213[Build agents that can take action2203[Build agents that can take action

2214 2204 

2215 2205 

2216 2206 

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

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