OpenAI Agents SDK integration
Temporal's integration with the OpenAI Agents SDK for Python lets you run agents as Temporal Workflows. Agent orchestration—the agent loop, tool selection, and handoffs—runs inside the Workflow, while model calls run as Activities.
Like with other types of API calls, in a Temporal Application, you make LLM calls in your Activities. This integration handles that for you: model calls are executed as Activities, so they retry durably and are not repeated during Workflow replay. Your agents survive Worker restarts and can run for extended periods without losing state.
Prerequisites
- This guide assumes you are already familiar with the OpenAI Agents SDK. If you aren't, refer to the OpenAI Agents SDK documentation for more details.
- If you are new to Temporal, we recommend you read the Understanding Temporal document or take the Temporal 101 course to understand the basics of Temporal.
- Ensure you have set up your local development environment by following the Set up your local with the Python SDK guide. When you are done, leave the Temporal Development Server running if you want to test your code locally.
Install
uv add temporalio-openai-agents
The temporalio-openai-agents package installs the Temporal Python SDK and OpenAI Agents SDK dependencies. It requires
Python 3.10 or later and Temporal Python SDK 1.33.0 or later.
Two import paths cover most applications. temporalio.openai_agents holds what you configure on the Worker and
Client—including OpenAIAgentsPlugin, ModelActivityParameters, and sandbox providers.