sdkagent

openai-agents-python API reference

400 public APIs from openai-agents-python (openai/openai-agents-python) — 237 classes, 63 functions, 100 methods. Signatures extracted by static analysis of the actual source.

Repository: openai/openai-agents-python

KindCount
Classes237
Functions63
Methods100

API list

classsrc.agents._mcp_tool_metadata.MCPToolMetadata
Resolved display metadata for an MCP tool.
funcsrc.agents._mcp_tool_metadata.extract_mcp_tool_metadata(tool:Any) -> MCPToolMetadata
Resolve display metadata from an MCP tool-like object.
funcsrc.agents._mcp_tool_metadata.resolve_mcp_tool_description(tool:Any) -> str | None
Return the MCP tool description when present.
funcsrc.agents._tool_identity.get_function_tool_dispatch_name(tool:Any) -> str | None
Return the canonical dispatch key for a function tool.
funcsrc.agents._tool_identity.get_function_tool_namespace(tool:Any) -> str | None
Return the explicit namespace for a function tool, if any.
funcsrc.agents._tool_identity.get_function_tool_public_name(tool:Any) -> str | None
Return the public name exposed for a function tool.
funcsrc.agents._tool_identity.get_function_tool_qualified_name(tool:Any) -> str | None
Return the qualified lookup key for a function tool.
funcsrc.agents._tool_identity.get_function_tool_trace_name(tool:Any) -> str | None
Return the trace display name for a function tool.
funcsrc.agents._tool_identity.get_mapping_or_attr(value:Any, key:str) -> Any
Read a key from either a mapping or object attribute.
funcsrc.agents._tool_identity.get_tool_approval_item_call_id(value:Any) -> str | None
Return the canonical call ID for a tool approval item.
funcsrc.agents._tool_identity.get_tool_call_name(tool_call:Any) -> str | None
Extract a tool name from a tool call payload.
funcsrc.agents._tool_identity.get_tool_call_namespace(tool_call:Any) -> str | None
Extract an optional namespace from a tool call payload.
funcsrc.agents._tool_identity.get_tool_call_qualified_name(tool_call:Any) -> str | None
Return the qualified name for a tool call payload.
funcsrc.agents._tool_identity.get_tool_call_trace_name(tool_call:Any) -> str | None
Return the trace display name for a tool call payload.
funcsrc.agents._tool_identity.get_tool_trace_name_for_tool(tool:Any) -> str | None
Return the trace display name for a tool definition.
funcsrc.agents._tool_identity.has_function_tool_shape(tool:Any) -> bool
Return True when the object looks like a FunctionTool instance.
methodsrc.agents.agent.Agent.clone(**kwargs:Any) -> Agent[TContext]
Make a copy of the agent, with the given arguments changed.
methodsrc.agents.agent.Agent.get_prompt(run_context:RunContextWrapper[TContext]) -> ResponsePromptParam | None
Get the prompt for the agent.
classsrc.agents.agent.AgentBase
Base class for `Agent` and `RealtimeAgent`.
methodsrc.agents.agent.AgentBase.get_all_tools(run_context:RunContextWrapper[TContext]) -> list[Tool]
All agent tools, including MCP tools and function tools.
methodsrc.agents.agent.AgentBase.get_mcp_tools(run_context:RunContextWrapper[TContext]) -> list[Tool]
Fetches the available tools from the MCP servers.
classsrc.agents.agent.MCPConfig
Configuration for MCP servers.
classsrc.agents.agent_tool_input.AgentAsToolInput
Default input schema for agent-as-tool calls.
funcsrc.agents.apply_diff.apply_diff(input:str, diff:str, mode:ApplyDiffMode='default') -> str
Apply a V4A diff to the provided text.
classsrc.agents.computer.AsyncComputer
A computer implemented with async operations.
methodsrc.agents.computer.AsyncComputer.click(x:int, y:int, button:Button) -> None
Click `button` at the given `(x, y)` screen coordinates.
methodsrc.agents.computer.AsyncComputer.double_click(x:int, y:int) -> None
Double-click at the given `(x, y)` screen coordinates.
methodsrc.agents.computer.AsyncComputer.keypress(keys:list[str]) -> None
Press the provided keys, such as `["ctrl", "c"]`.
methodsrc.agents.computer.AsyncComputer.move(x:int, y:int) -> None
Move the mouse cursor to the given `(x, y)` screen coordinates.
methodsrc.agents.computer.AsyncComputer.scroll(x:int, y:int, scroll_x:int, scroll_y:int) -> None
Scroll at `(x, y)` by `(scroll_x, scroll_y)` units.
methodsrc.agents.computer.AsyncComputer.type(text:str) -> None
Type `text` into the currently focused target.
methodsrc.agents.computer.AsyncComputer.wait() -> None
Wait until the computer is ready for the next action.
classsrc.agents.computer.Computer
A computer implemented with sync operations.
methodsrc.agents.computer.Computer.click(x:int, y:int, button:Button) -> None
Click `button` at the given `(x, y)` screen coordinates.
methodsrc.agents.computer.Computer.double_click(x:int, y:int) -> None
Double-click at the given `(x, y)` screen coordinates.
methodsrc.agents.computer.Computer.keypress(keys:list[str]) -> None
Press the provided keys, such as `["ctrl", "c"]`.
methodsrc.agents.computer.Computer.move(x:int, y:int) -> None
Move the mouse cursor to the given `(x, y)` screen coordinates.
methodsrc.agents.computer.Computer.scroll(x:int, y:int, scroll_x:int, scroll_y:int) -> None
Scroll at `(x, y)` by `(scroll_x, scroll_y)` units.
methodsrc.agents.computer.Computer.type(text:str) -> None
Type `text` into the currently focused target.
methodsrc.agents.computer.Computer.wait() -> None
Wait until the computer is ready for the next action.
classsrc.agents.editor.ApplyPatchEditor
Host-defined editor that applies diffs on disk.
classsrc.agents.editor.ApplyPatchResult
Optional metadata returned by editor operations.
funcsrc.agents.enable_verbose_stdout_logging() -> None
Enables verbose logging to stdout.
classsrc.agents.exceptions.AgentsException
Base class for all exceptions in the Agents SDK.
classsrc.agents.exceptions.UserError
Exception raised when the user makes an error using the SDK.
classsrc.agents.extensions.models.litellm_model.LitellmModel
This class enables using any model via LiteLLM.
classsrc.agents.extensions.sandbox.blaxel.mounts.BlaxelDriveMount
A concrete Mount entry for Blaxel Drives.
classsrc.agents.extensions.sandbox.blaxel.sandbox.BlaxelSandboxClientOptions
Client options for the Blaxel sandbox.
classsrc.agents.extensions.sandbox.blaxel.sandbox.BlaxelSandboxSession
Blaxel-backed sandbox session implementation.
classsrc.agents.extensions.sandbox.cloudflare.sandbox.CloudflareSandboxClientOptions
Options for ``CloudflareSandboxClient``.
classsrc.agents.extensions.sandbox.daytona.sandbox.DaytonaSandboxClientOptions
Client options for the Daytona sandbox.
classsrc.agents.extensions.sandbox.e2b.sandbox.E2BSandboxClientOptions
Client options for the E2B sandbox.
classsrc.agents.extensions.sandbox.e2b.sandbox.E2BSandboxSession
E2B-backed sandbox session implementation.
classsrc.agents.extensions.sandbox.e2b.sandbox.E2BSandboxTimeouts
Timeout configuration for E2B operations.
classsrc.agents.extensions.sandbox.e2b.sandbox.E2BSandboxType
Supported E2B sandbox interfaces.
classsrc.agents.extensions.sandbox.runloop.sandbox.RunloopGatewaySpec
Runloop agent gateway binding.
classsrc.agents.extensions.sandbox.runloop.sandbox.RunloopMcpSpec
Runloop MCP gateway binding.
classsrc.agents.extensions.sandbox.runloop.sandbox.RunloopSandboxClientOptions
Client options for the Runloop sandbox.
methodsrc.agents.extensions.sandbox.runloop.sandbox.RunloopSandboxSession.read(path:Path | str, *user:str | User | None=None) -> io.IOBase
Read a file via Runloop's binary file API.
classsrc.agents.extensions.sandbox.runloop.sandbox.RunloopTunnelConfig
Runloop public tunnel configuration.
classsrc.agents.extensions.sandbox.vercel.sandbox.VercelSandboxClient
Vercel-backed sandbox client.
classsrc.agents.guardrail.GuardrailFunctionOutput
The output of a guardrail function.
classsrc.agents.guardrail.InputGuardrailResult
The result of a guardrail run.
classsrc.agents.guardrail.OutputGuardrailResult
The result of a guardrail run.
classsrc.agents.items.CompactionItem
Represents a compaction item from responses.compact.
classsrc.agents.items.HandoffOutputItem
Represents the output of a handoff.
classsrc.agents.items.MCPApprovalRequestItem
Represents a request for MCP approval.
classsrc.agents.items.MCPApprovalResponseItem
Represents a response to an MCP approval request.
classsrc.agents.items.MCPListToolsItem
Represents a call to an MCP server to list tools.
classsrc.agents.items.MessageOutputItem
Represents a message from the LLM.
classsrc.agents.items.ReasoningItem
Represents a reasoning item.
classsrc.agents.items.ToolApprovalItem
Tool call that requires approval before execution.
methodsrc.agents.items.ToolApprovalItem.call_id() -> str | None
Return call identifier from the raw item.
classsrc.agents.items.ToolCallItem
Represents a tool call e.g.
classsrc.agents.items.ToolCallOutputItem
Represents the output of a tool call.
classsrc.agents.items.ToolSearchOutputItem
Represents the output of a Responses API tool search.
classsrc.agents.mcp.server.MCPServer
Base class for Model Context Protocol servers.
methodsrc.agents.mcp.server.MCPServer.call_tool(tool_name:str, arguments:dict[str, Any] | None, meta:dict[str, Any] | None=None) -> CallToolResult
Invoke a tool on the server.
methodsrc.agents.mcp.server.MCPServer.cleanup()
Cleanup the server.
methodsrc.agents.mcp.server.MCPServer.connect()
Connect to the server.
methodsrc.agents.mcp.server.MCPServer.get_prompt(name:str, arguments:dict[str, Any] | None=None) -> GetPromptResult
Get a specific prompt from the server.
methodsrc.agents.mcp.server.MCPServer.list_prompts() -> ListPromptsResult
List the prompts available on the server.
methodsrc.agents.mcp.server.MCPServer.list_resources(cursor:str | None=None) -> ListResourcesResult
List the resources available on the server.
methodsrc.agents.mcp.server.MCPServer.list_tools(run_context:RunContextWrapper[Any] | None=None, agent:AgentBase | None=None) -> list[MCPTool]
List the tools available on the server.
methodsrc.agents.mcp.server.MCPServer.name() -> str
A readable name for the server.
methodsrc.agents.mcp.server.MCPServer.read_resource(uri:str) -> ReadResourceResult
Read the contents of a specific resource by URI.
classsrc.agents.mcp.server.MCPServerSseParams
Mirrors the params in `mcp.client.sse.sse_client`.
classsrc.agents.mcp.server.MCPServerStdio
MCP server implementation that uses the stdio transport.
methodsrc.agents.mcp.server.MCPServerStdio.create_streams() -> AbstractAsyncContextManager[MCPStreamTransport]
Create the streams for the server.
methodsrc.agents.mcp.server.MCPServerStdio.name() -> str
A readable name for the server.
classsrc.agents.mcp.util.HttpClientFactory
Protocol for MCP HTTP client factory functions.
classsrc.agents.mcp.util.MCPToolCustomDataContext
Context passed to MCP tool custom data extractors.
classsrc.agents.mcp.util.ToolFilterContext
Context information available to tool filter functions.
funcsrc.agents.memory.openai_responses_compaction_session.is_openai_model_name(model:str) -> bool
Validate model name follows OpenAI conventions.
funcsrc.agents.memory.openai_responses_compaction_session.select_compaction_candidate_items(items:list[TResponseInputItem]) -> list[TResponseInputItem]
Select compaction candidate items.
classsrc.agents.memory.session.OpenAIResponsesCompactionArgs
Arguments for the run_compaction method.
classsrc.agents.memory.session.Session
Protocol for session implementations.
methodsrc.agents.memory.session.Session.add_items(items:list[TResponseInputItem]) -> None
Add new items to the conversation history.
methodsrc.agents.memory.session.Session.clear_session() -> None
Clear all items for this session.
methodsrc.agents.memory.session.Session.get_items(limit:int | None=None) -> list[TResponseInputItem]
Retrieve the conversation history for this session.
classsrc.agents.memory.session.SessionABC
Abstract base class for session implementations.
methodsrc.agents.memory.session.SessionABC.add_items(items:list[TResponseInputItem]) -> None
Add new items to the conversation history.
methodsrc.agents.memory.session.SessionABC.clear_session() -> None
Clear all items for this session.
methodsrc.agents.memory.session.SessionABC.get_items(limit:int | None=None) -> list[TResponseInputItem]
Retrieve the conversation history for this session.
classsrc.agents.memory.session_settings.SessionSettings
Settings for session operations.
methodsrc.agents.memory.session_settings.SessionSettings.to_dict() -> dict[str, Any]
Convert settings to a dictionary.
classsrc.agents.memory.sqlite_session.SQLiteSession
SQLite-based implementation of session storage.
methodsrc.agents.memory.sqlite_session.SQLiteSession.add_items(items:list[TResponseInputItem]) -> None
Add new items to the conversation history.
methodsrc.agents.memory.sqlite_session.SQLiteSession.clear_session() -> None
Clear all items for this session.
methodsrc.agents.memory.sqlite_session.SQLiteSession.close() -> None
Close the database connection.
classsrc.agents.model_settings.ModelSettings
Settings to use when calling an LLM.
funcsrc.agents.models.default_models.get_default_model() -> str
Returns the default model name.
funcsrc.agents.models.default_models.get_default_model_settings(model:str | None=None) -> ModelSettings
Returns the default model settings.
classsrc.agents.models.interface.Model
The base interface for calling an LLM.
methodsrc.agents.models.interface.Model.close() -> None
Release any resources held by the model.
classsrc.agents.models.interface.ModelProvider
The base interface for a model provider.
methodsrc.agents.models.interface.ModelProvider.aclose() -> None
Release any resources held by the provider.
methodsrc.agents.models.interface.ModelProvider.get_model(model_name:str | None) -> Model
Get a model by name.
classsrc.agents.models.multi_provider.MultiProviderMap
A map of model name prefixes to ModelProviders.
methodsrc.agents.models.multi_provider.MultiProviderMap.get_provider(prefix:str) -> ModelProvider | None
Returns the ModelProvider for the given prefix.
methodsrc.agents.models.multi_provider.MultiProviderMap.has_prefix(prefix:str) -> bool
Returns True if the given prefix is in the mapping.
classsrc.agents.realtime.config.RealtimeAudioConfig
Audio configuration for realtime sessions.
classsrc.agents.realtime.config.RealtimeAudioInputConfig
Configuration for audio input in realtime sessions.
classsrc.agents.realtime.config.RealtimeClientMessage
A raw message to be sent to the model.
classsrc.agents.realtime.config.RealtimeCustomVoice
A custom Realtime voice object.
classsrc.agents.realtime.config.RealtimeInputAudioNoiseReductionConfig
Noise reduction configuration for input audio.
classsrc.agents.realtime.config.RealtimeReasoningConfig
Reasoning configuration for realtime sessions.
classsrc.agents.realtime.config.RealtimeRunConfig
Configuration for running a realtime agent session.
classsrc.agents.realtime.config.RealtimeSessionModelSettings
Model settings for a realtime model session.
classsrc.agents.realtime.config.RealtimeTurnDetectionConfig
Turn detection config.
classsrc.agents.realtime.config.RealtimeUserInputImage
An image input from the user (Realtime).
classsrc.agents.realtime.config.RealtimeUserInputMessage
A message input from the user.
classsrc.agents.realtime.config.RealtimeUserInputText
A text input from the user.
classsrc.agents.realtime.events.RealtimeAgentEndEvent
An agent has ended.
classsrc.agents.realtime.events.RealtimeAgentStartEvent
A new agent has started.
classsrc.agents.realtime.events.RealtimeAudioEnd
Triggered when the agent stops generating audio.
classsrc.agents.realtime.events.RealtimeAudioInterrupted
Triggered when the agent is interrupted.
classsrc.agents.realtime.events.RealtimeError
An error has occurred.
classsrc.agents.realtime.events.RealtimeHandoffEvent
An agent has handed off to another agent.
classsrc.agents.realtime.events.RealtimeHistoryAdded
A new item has been added to the history.
classsrc.agents.realtime.events.RealtimeHistoryUpdated
The history has been updated.
classsrc.agents.realtime.events.RealtimeRawModelEvent
Forwards raw events from the model layer.
classsrc.agents.realtime.events.RealtimeToolEnd
An agent has ended a tool call.
classsrc.agents.realtime.events.RealtimeToolStart
An agent is starting a tool call.
classsrc.agents.realtime.items.AssistantAudio
Audio content from the assistant in realtime responses.
classsrc.agents.realtime.items.AssistantMessageItem
An assistant message item in realtime conversations.
classsrc.agents.realtime.items.AssistantText
Text content from the assistant in realtime responses.
classsrc.agents.realtime.items.InputAudio
Audio input content for realtime messages.
classsrc.agents.realtime.items.InputImage
Image input content for realtime messages.
classsrc.agents.realtime.items.InputText
Text input content for realtime messages.
classsrc.agents.realtime.items.RealtimeResponse
A response from the realtime model.
classsrc.agents.realtime.items.RealtimeToolCallItem
A tool call item in realtime conversations.
classsrc.agents.realtime.items.SystemMessageItem
A system message item in realtime conversations.
classsrc.agents.realtime.items.UserMessageItem
A user message item in realtime conversations.
classsrc.agents.realtime.model.RealtimeModelConfig
Options for connecting to a realtime model.
classsrc.agents.realtime.model.RealtimeModelListener
A listener for realtime transport events.
classsrc.agents.realtime.model_events.RealtimeModelAudioDoneEvent
Audio done.
classsrc.agents.realtime.model_events.RealtimeModelAudioEvent
Raw audio bytes emitted by the model.
classsrc.agents.realtime.model_events.RealtimeModelAudioInterruptedEvent
Audio interrupted.
classsrc.agents.realtime.model_events.RealtimeModelConnectionStatusEvent
Connection status changed.
classsrc.agents.realtime.model_events.RealtimeModelErrorEvent
Represents a transport‑layer error.
classsrc.agents.realtime.model_events.RealtimeModelExceptionEvent
Exception occurred during model operation.
classsrc.agents.realtime.model_events.RealtimeModelInputAudioTimeoutTriggeredEvent
Input audio timeout triggered.
classsrc.agents.realtime.model_events.RealtimeModelInputAudioTranscriptionCompletedEvent
Input audio transcription completed.
classsrc.agents.realtime.model_events.RealtimeModelInputTokensDetails
Modality breakdown for Realtime input tokens.
classsrc.agents.realtime.model_events.RealtimeModelItemDeletedEvent
Item deleted from the history.
classsrc.agents.realtime.model_events.RealtimeModelItemUpdatedEvent
Item added to the history or updated.
classsrc.agents.realtime.model_events.RealtimeModelOtherEvent
Used as a catchall for vendor-specific events.
classsrc.agents.realtime.model_events.RealtimeModelOutputTextDeltaEvent
Partial text output update.
classsrc.agents.realtime.model_events.RealtimeModelOutputTokensDetails
Modality breakdown for Realtime output tokens.
classsrc.agents.realtime.model_events.RealtimeModelRawServerEvent
Raw events forwarded from the server.
classsrc.agents.realtime.model_events.RealtimeModelToolCallEvent
Model attempted a tool/function call.
classsrc.agents.realtime.model_events.RealtimeModelTranscriptDeltaEvent
Partial transcript update.
classsrc.agents.realtime.model_inputs.RealtimeModelInputImageContent
An image to be sent to the model.
classsrc.agents.realtime.model_inputs.RealtimeModelInputTextContent
A piece of text to be sent to the model.
classsrc.agents.realtime.model_inputs.RealtimeModelRawClientMessage
A raw message to be sent to the model.
classsrc.agents.realtime.model_inputs.RealtimeModelSendAudio
Send audio to the model.
classsrc.agents.realtime.model_inputs.RealtimeModelSendInterrupt
Send an interrupt to the model.
classsrc.agents.realtime.model_inputs.RealtimeModelSendRawMessage
Send a raw message to the model.
classsrc.agents.realtime.model_inputs.RealtimeModelSendSessionUpdate
Send a session update to the model.
classsrc.agents.realtime.model_inputs.RealtimeModelSendToolOutput
Send tool output to the model.
classsrc.agents.realtime.model_inputs.RealtimeModelSendUserInput
Send a user input to the model.
classsrc.agents.realtime.model_inputs.RealtimeModelUserInputMessage
A message to be sent to the model.
classsrc.agents.realtime.openai_realtime.OpenAIRealtimeWebSocketModel
A model that uses OpenAI's WebSocket API.
methodsrc.agents.realtime.openai_realtime.OpenAIRealtimeWebSocketModel.add_listener(listener:RealtimeModelListener) -> None
Add a listener to the model.
methodsrc.agents.realtime.openai_realtime.OpenAIRealtimeWebSocketModel.close() -> None
Close the session.
methodsrc.agents.realtime.openai_realtime.OpenAIRealtimeWebSocketModel.remove_listener(listener:RealtimeModelListener) -> None
Remove a listener from the model.
methodsrc.agents.realtime.openai_realtime.OpenAIRealtimeWebSocketModel.send_event(event:RealtimeModelSendEvent) -> None
Send an event to the model.
classsrc.agents.realtime.openai_realtime.TransportConfig
Low-level network transport configuration.
classsrc.agents.realtime.session.RealtimeSession
A connection to a realtime model.
methodsrc.agents.realtime.session.RealtimeSession.approve_tool_call(call_id:str, *always:bool=False) -> None
Approve a pending tool call and resume execution.
methodsrc.agents.realtime.session.RealtimeSession.close() -> None
Close the session.
methodsrc.agents.realtime.session.RealtimeSession.enter() -> RealtimeSession
Enter the async context manager.
methodsrc.agents.realtime.session.RealtimeSession.interrupt() -> None
Interrupt the model.
methodsrc.agents.realtime.session.RealtimeSession.send_audio(audio:bytes, *commit:bool=False) -> None
Send a raw audio chunk to the model.
methodsrc.agents.realtime.session.RealtimeSession.send_message(message:RealtimeUserInput) -> None
Send a message to the model.
funcsrc.agents.repl.run_demo_loop(agent:Agent[Any], *stream:bool=True, *context:TContext | None=None, *max_turns:int | None=DEFAULT_MAX_TURNS) -> None
Run a simple REPL loop with the given agent.
classsrc.agents.result.AgentToolInvocation
Immutable metadata about a nested agent-tool invocation.
methodsrc.agents.result.RunResult.last_agent() -> Agent[Any]
The last agent that was run.
classsrc.agents.result.RunResultStreaming
The result of an agent run in streaming mode.
methodsrc.agents.result.RunResultStreaming.cancel(mode:Literal['immediate', 'after_turn']='immediate') -> None
Cancel the streaming run.
methodsrc.agents.result.RunResultStreaming.last_agent() -> Agent[Any]
The last agent that was run.
classsrc.agents.retry.ModelRetryNormalizedError
Normalized error facts exposed to retry policies.
classsrc.agents.retry.ModelRetrySettings
Opt-in runner-managed retry settings for model calls.
classsrc.agents.retry.RetryDecision
Explicit retry decision returned by retry policies.
classsrc.agents.retry.RetryPolicyContext
Context passed to runtime retry policy callbacks.
classsrc.agents.run_config.ModelInputData
Container for the data that will be sent to the model.
classsrc.agents.run_config.RunConfig
Configures settings for the entire agent run.
classsrc.agents.run_config.RunOptions
Arguments for ``AgentRunner`` methods.
classsrc.agents.run_config.SandboxArchiveLimits
Resource limits for sandbox archive extraction.
classsrc.agents.run_config.SandboxConcurrencyLimits
Concurrency limits for sandbox materialization work.
classsrc.agents.run_config.SandboxRunConfig
Grouped sandbox runtime configuration for `Runner`.
classsrc.agents.run_context.AgentHookContext
Context passed to agent hooks (on_start, on_end).
classsrc.agents.run_error_handlers.RunErrorData
Snapshot of run data passed to error handlers.
classsrc.agents.run_error_handlers.RunErrorHandlerResult
Result returned by an error handler.
classsrc.agents.run_error_handlers.RunErrorHandlers
Error handlers keyed by error kind.
funcsrc.agents.run_internal.agent_runner_helpers.usage_delta(start:Usage, end:Usage) -> Usage
Return the aggregate usage added between two snapshots.
funcsrc.agents.run_internal.items.ensure_input_item_format(item:TResponseInputItem) -> TResponseInputItem
Ensure a single item is normalized for model input.
funcsrc.agents.run_internal.items.extract_mcp_request_id(raw_item:Any) -> str | None
Pull the request id from hosted MCP approval payloads.
funcsrc.agents.run_internal.items.normalize_input_items_for_api(items:list[TResponseInputItem]) -> list[TResponseInputItem]
Normalize input items for API submission.
funcsrc.agents.run_internal.tool_execution.extract_tool_call_id(raw:Any) -> str | None
Return a call ID from tool call payloads or approval items.
funcsrc.agents.run_internal.turn_preparation.get_all_tools(agent:Agent[Any], context_wrapper:RunContextWrapper[Any]) -> list[Tool]
Fetch all tools available to the agent.
funcsrc.agents.run_internal.turn_preparation.get_handoffs(agent:Agent[Any], context_wrapper:RunContextWrapper[Any]) -> list[Handoff]
Return enabled handoffs for the agent.
funcsrc.agents.run_internal.turn_preparation.get_model(agent:Agent[Any], run_config:RunConfig) -> Model
Resolve the model instance for this run.
methodsrc.agents.run_state.RunState.set_trace(trace:Trace | None) -> None
Capture trace metadata for serialization/resumption.
methodsrc.agents.sandbox.capabilities.capability.Capability.bind(session:BaseSandboxSession) -> None
Bind a live session to this plugin (default no-op).
methodsrc.agents.sandbox.capabilities.capability.Capability.clone() -> 'Capability'
Return a per-run copy of this capability.
classsrc.agents.sandbox.config.MemoryReadConfig
Configuration for sandbox-backed memory reads.
methodsrc.agents.sandbox.entries.mounts.base.Mount.unmount(session:BaseSandboxSession, dest:Path, base_dir:Path) -> None
Deactivate this mount for manifest teardown.
classsrc.agents.sandbox.entries.mounts.providers.box.BoxMount
Mount a Box folder using rclone.
classsrc.agents.sandbox.errors.ApplyPatchError
Base class for apply_patch validation errors.
classsrc.agents.sandbox.errors.ApplyPatchFileNotFoundError
Apply patch failed because a file was missing.
classsrc.agents.sandbox.errors.ErrorCode
Stable, machine-readable error codes for `SandboxError`.
classsrc.agents.sandbox.errors.ExecFailureError
Base class for exec()-related failures.
classsrc.agents.sandbox.errors.ExecNonZeroError
exec() returned a non-zero exit status.
classsrc.agents.sandbox.errors.ExecTimeoutError
exec() exceeded its timeout.
classsrc.agents.sandbox.errors.LocalArtifactError
Base class for errors while reading local artifacts.
classsrc.agents.sandbox.errors.LocalChecksumError
Failed to compute a checksum for a local artifact.
classsrc.agents.sandbox.errors.LocalDirReadError
Failed to read a local directory artifact from disk.
classsrc.agents.sandbox.errors.LocalFileReadError
Failed to read a local file artifact from disk.
classsrc.agents.sandbox.errors.MountCommandError
Mount command failed to execute successfully.
classsrc.agents.sandbox.errors.MountConfigError
Mount configuration was invalid or incomplete.
classsrc.agents.sandbox.errors.MountToolMissingError
Required mount tool is missing in the sandbox.
classsrc.agents.sandbox.errors.SandboxError
Base class for structured, user-facing sandbox errors.
methodsrc.agents.sandbox.errors.SandboxError.code() -> str
Backward-compatible alias for `error_code`.
classsrc.agents.sandbox.errors.SandboxRuntimeError
Raised for sandbox failures (e.g., Docker/IO/transport).
classsrc.agents.sandbox.errors.SkillsConfigError
Skills capability configuration was invalid.
classsrc.agents.sandbox.errors.SnapshotError
Raised for snapshot persist/restore errors.
classsrc.agents.sandbox.errors.SnapshotPersistError
Failed to persist snapshot bytes to durable storage.
classsrc.agents.sandbox.errors.WorkspaceIOError
Base class for workspace read/write errors.
classsrc.agents.sandbox.errors.WorkspaceRootNotFoundError
Workspace root is missing on disk (e.g.
classsrc.agents.sandbox.sandbox_agent.SandboxAgent
An `Agent` with sandbox-specific configuration.
classsrc.agents.sandbox.session.events.SandboxSessionEventBase
Shared fields for all sandbox audit events.
classsrc.agents.sandbox.session.events.SandboxSessionFinishEvent
The finish event for an operation.
classsrc.agents.sandbox.session.events.SandboxSessionStartEvent
The start event for an operation.
funcsrc.agents.sandbox.session.events.validate_sandbox_session_event(obj:object) -> SandboxSessionEvent
Parse an event payload (e.g.
classsrc.agents.sandbox.session.sinks.CallbackSink
Deliver events to a user-provided callable.
classsrc.agents.sandbox.session.sinks.ChainedSink
Groups multiple sinks that should run in order.
funcsrc.agents.sandbox.util.checksums.sha256_io(stream:io.IOBase, *chunk_size:int=1024 * 1024) -> str
Hash a readable stream and rewind it when possible.
funcsrc.agents.sandbox.util.github.clone_repo(*repo:str, *ref:str, *dest:Path) -> None
Shallow clone a GitHub repo at a ref (tag/branch/sha).
funcsrc.agents.sandbox.util.tar_utils.safe_extract_tarfile(tar:tarfile.TarFile, *root:Path, *allow_external_symlink_targets:bool=True) -> None
Safely extract a tar archive into `root`.
funcsrc.agents.sandbox.workspace_paths.coerce_posix_path(path:str | PurePath) -> PurePosixPath
Return a POSIX-flavored path for sandbox filesystem paths.
funcsrc.agents.sandbox.workspace_paths.sandbox_path_str(path:str | PurePath) -> str
Return a POSIX string for a sandbox filesystem path.
funcsrc.agents.set_default_openai_agent_registration(config:OpenAIAgentRegistrationConfig | dict[str, Any] | None) -> None
Set the default OpenAI agent registration config.
funcsrc.agents.set_default_openai_api(api:Literal['chat_completions', 'responses']) -> None
Set the default API to use for OpenAI LLM requests.
classsrc.agents.stream_events.RawResponsesStreamEvent
Streaming event from the LLM.
classsrc.agents.stream_events.RunItemStreamEvent
Streaming events that wrap a `RunItem`.
classsrc.agents.tool.ApplyPatchTool
Hosted apply_patch tool.
classsrc.agents.tool.ComputerCreate
Initializes a computer for the current run context.
classsrc.agents.tool.ComputerDispose
Cleans up a computer initialized for a run context.
classsrc.agents.tool.ComputerToolSafetyCheckData
Information about a computer tool safety check.
classsrc.agents.tool.CustomToolCustomDataContext
Context passed to custom-tool custom data extractors.
classsrc.agents.tool.CustomToolOnApprovalFunctionResult
The result of a custom tool on_approval callback.
classsrc.agents.tool.FunctionTool
A tool that wraps a function.
classsrc.agents.tool.HostedMCPTool
A tool that allows the LLM to use a remote MCP server.
classsrc.agents.tool.ImageGenerationTool
A tool that allows the LLM to generate images.
classsrc.agents.tool.LocalShellCommandRequest
A request to execute a command on a shell.
classsrc.agents.tool.LocalShellTool
A tool that allows the LLM to execute commands on a shell.
classsrc.agents.tool.MCPToolApprovalFunctionResult
The result of an MCP tool approval function.
classsrc.agents.tool.MCPToolApprovalRequest
A request to approve a tool call.
classsrc.agents.tool.ShellActionRequest
Action payload for a next-generation shell call.
classsrc.agents.tool.ShellCallData
Normalized shell call data provided to shell executors.
classsrc.agents.tool.ShellCallOutcome
Describes the terminal condition of a shell command.
classsrc.agents.tool.ShellCommandOutput
Structured output for a single shell command execution.
classsrc.agents.tool.ShellCommandRequest
A request to execute a modern shell call.
classsrc.agents.tool.ShellOnApprovalFunctionResult
The result of a shell tool on_approval callback.
classsrc.agents.tool.ShellResult
Result returned by a shell executor.
classsrc.agents.tool.ShellTool
Next-generation shell tool.
classsrc.agents.tool.ShellToolContainerAutoEnvironment
Auto-provisioned hosted container environment.
classsrc.agents.tool.ShellToolContainerNetworkPolicyAllowlist
Allowlist network policy for hosted containers.
classsrc.agents.tool.ShellToolContainerNetworkPolicyDisabled
Disabled network policy for hosted containers.
classsrc.agents.tool.ShellToolContainerReferenceEnvironment
Reference to an existing hosted container.
classsrc.agents.tool.ShellToolInlineSkill
Inline hosted shell skill bundle.
classsrc.agents.tool.ShellToolInlineSkillSource
Inline skill source payload.
classsrc.agents.tool.ShellToolLocalEnvironment
Local shell execution environment.
classsrc.agents.tool.ShellToolLocalSkill
Skill metadata for local shell environments.
classsrc.agents.tool.ShellToolSkillReference
Reference to a hosted shell skill.
classsrc.agents.tool.ToolOutputFileContentDict
TypedDict variant for file content tool outputs.
classsrc.agents.tool.ToolOutputImageDict
TypedDict variant for image tool outputs.
classsrc.agents.tool.ToolOutputTextDict
TypedDict variant for text tool outputs.
classsrc.agents.tool.WebSearchTool
A hosted tool that lets the LLM search the web.
funcsrc.agents.tool.get_function_tool_origin(function_tool:FunctionTool) -> ToolOrigin | None
Return scalar origin metadata for a function tool.
classsrc.agents.tool_context.ToolContext
The context of a tool call.
classsrc.agents.tool_guardrails.AllowBehavior
Allows normal tool execution to continue.
classsrc.agents.tool_guardrails.RaiseExceptionBehavior
Raises an exception to halt execution.
classsrc.agents.tool_guardrails.ToolGuardrailFunctionOutput
The output of a tool guardrail function.
classsrc.agents.tool_guardrails.ToolInputGuardrailData
Input data passed to a tool input guardrail function.
classsrc.agents.tool_guardrails.ToolInputGuardrailResult
The result of a tool input guardrail run.
classsrc.agents.tool_guardrails.ToolOutputGuardrailResult
The result of a tool output guardrail run.
funcsrc.agents.tracing.add_trace_processor(span_processor:TracingProcessor) -> None
Adds a new trace processor.
classsrc.agents.tracing.config.TracingConfig
Configuration for tracing behavior and export.
funcsrc.agents.tracing.create.function_span(name:str, input:str | None=None, output:str | None=None, span_id:str | None=None, parent:Trace | Span[Any] | None=None, disabled:bool=False) -> Span[FunctionSpanData]
Create a new function span.
funcsrc.agents.tracing.create.get_current_span() -> Span[Any] | None
Returns the currently active span, if present.
funcsrc.agents.tracing.create.get_current_trace() -> Trace | None
Returns the currently active trace, if present.
funcsrc.agents.tracing.create.guardrail_span(name:str, triggered:bool=False, span_id:str | None=None, parent:Trace | Span[Any] | None=None, disabled:bool=False) -> Span[GuardrailSpanData]
Create a new guardrail span.
funcsrc.agents.tracing.create.handoff_span(from_agent:str | None=None, to_agent:str | None=None, span_id:str | None=None, parent:Trace | Span[Any] | None=None, disabled:bool=False) -> Span[HandoffSpanData]
Create a new handoff span.
funcsrc.agents.tracing.create.response_span(response:Response | None=None, span_id:str | None=None, parent:Trace | Span[Any] | None=None, disabled:bool=False) -> Span[ResponseSpanData]
Create a new response span.
funcsrc.agents.tracing.create.speech_group_span(input:str | None=None, span_id:str | None=None, parent:Trace | Span[Any] | None=None, disabled:bool=False) -> Span[SpeechGroupSpanData]
Create a new speech group span.
funcsrc.agents.tracing.create.task_span(name:str, span_id:str | None=None, parent:Trace | Span[Any] | None=None, disabled:bool=False) -> Span[TaskSpanData]
Create a new task span.
funcsrc.agents.tracing.create.trace(workflow_name:str, trace_id:str | None=None, group_id:str | None=None, metadata:dict[str, Any] | None=None, tracing:TracingConfig | None=None, disabled:bool=False) -> Trace
Create a new trace.
funcsrc.agents.tracing.create.turn_span(turn:int, agent_name:str, span_id:str | None=None, parent:Trace | Span[Any] | None=None, disabled:bool=False) -> Span[TurnSpanData]
Create a new turn span.
funcsrc.agents.tracing.flush_traces() -> None
Force immediate export of buffered traces and spans.
classsrc.agents.tracing.processor_interface.TracingExporter
Exports traces and spans.
methodsrc.agents.tracing.processor_interface.TracingExporter.export(items:list['Trace | Span[Any]']) -> None
Exports a list of traces and spans.
classsrc.agents.tracing.processors.BatchTraceProcessor
Some implementation notes: 1.
methodsrc.agents.tracing.processors.BatchTraceProcessor.shutdown(timeout:float | None=None)
Called when the application stops.
classsrc.agents.tracing.processors.ConsoleSpanExporter
Prints the traces and spans to the console.
classsrc.agents.tracing.provider.TraceProvider
Interface for creating traces and spans.
methodsrc.agents.tracing.provider.TraceProvider.create_span(span_data:TSpanData, span_id:str | None=None, parent:Trace | Span[Any] | None=None, disabled:bool=False) -> Span[TSpanData]
Create a new span.
methodsrc.agents.tracing.provider.TraceProvider.create_trace(name:str, trace_id:str | None=None, group_id:str | None=None, metadata:dict[str, Any] | None=None, disabled:bool=False, tracing:TracingConfig | None=None) -> Trace
Create a new trace.
methodsrc.agents.tracing.provider.TraceProvider.gen_group_id() -> str
Generate a new group identifier.
methodsrc.agents.tracing.provider.TraceProvider.gen_span_id() -> str
Generate a new span identifier.
methodsrc.agents.tracing.provider.TraceProvider.gen_trace_id() -> str
Generate a new trace identifier.
methodsrc.agents.tracing.provider.TraceProvider.get_current_span() -> Span[Any] | None
Return the currently active span, if any.
methodsrc.agents.tracing.provider.TraceProvider.get_current_trace() -> Trace | None
Return the currently active trace, if any.
methodsrc.agents.tracing.provider.TraceProvider.register_processor(processor:TracingProcessor) -> None
Add a processor that will receive all traces and spans.
methodsrc.agents.tracing.provider.TraceProvider.set_disabled(disabled:bool) -> None
Enable or disable tracing globally.
methodsrc.agents.tracing.provider.TraceProvider.set_processors(processors:list[TracingProcessor]) -> None
Replace the list of processors with ``processors``.
methodsrc.agents.tracing.provider.TraceProvider.shutdown() -> None
Clean up any resources used by the provider.
methodsrc.agents.tracing.provider.TraceProvider.time_iso() -> str
Return the current time in ISO 8601 format.
classsrc.agents.tracing.scope.Scope
Manages the current span and trace in the context.
funcsrc.agents.tracing.set_trace_processors(processors:list[TracingProcessor]) -> None
Set the list of trace processors.
funcsrc.agents.tracing.set_tracing_disabled(disabled:bool) -> None
Set whether tracing is globally disabled.
funcsrc.agents.tracing.set_tracing_export_api_key(api_key:str) -> None
Set the OpenAI API key for the backend exporter.
classsrc.agents.tracing.span_data.AgentSpanData
Represents an Agent Span in the trace.
classsrc.agents.tracing.span_data.CustomSpanData
Represents a Custom Span in the trace.
classsrc.agents.tracing.span_data.FunctionSpanData
Represents a Function Span in the trace.
classsrc.agents.tracing.span_data.GenerationSpanData
Represents a Generation Span in the trace.
classsrc.agents.tracing.span_data.GuardrailSpanData
Represents a Guardrail Span in the trace.
classsrc.agents.tracing.span_data.HandoffSpanData
Represents a Handoff Span in the trace.
classsrc.agents.tracing.span_data.MCPListToolsSpanData
Represents an MCP List Tools Span in the trace.
classsrc.agents.tracing.span_data.ResponseSpanData
Represents a Response Span in the trace.
classsrc.agents.tracing.span_data.SpanData
Represents span data in the trace.
methodsrc.agents.tracing.span_data.SpanData.export() -> dict[str, Any]
Export the span data as a dictionary.
methodsrc.agents.tracing.span_data.SpanData.type() -> str
Return the type of the span.
classsrc.agents.tracing.span_data.SpeechGroupSpanData
Represents a Speech Group Span in the trace.
classsrc.agents.tracing.span_data.SpeechSpanData
Represents a Speech Span in the trace.
classsrc.agents.tracing.span_data.TaskSpanData
Represents one top-level Runner run.
classsrc.agents.tracing.span_data.TranscriptionSpanData
Represents a Transcription Span in the trace.
classsrc.agents.tracing.span_data.TurnSpanData
Represents one agent loop turn.
methodsrc.agents.tracing.spans.Span.ended_at() -> str | None
When the span finished execution.
methodsrc.agents.tracing.spans.Span.error() -> SpanError | None
Any error that occurred during span execution.
methodsrc.agents.tracing.spans.Span.finish(reset_current:bool=False) -> None
Finish the span.
methodsrc.agents.tracing.spans.Span.parent_id() -> str | None
ID of the parent span, if any.
methodsrc.agents.tracing.spans.Span.span_data() -> TSpanData
Operation-specific data for this span.
methodsrc.agents.tracing.spans.Span.span_id() -> str
Unique identifier for this span.
methodsrc.agents.tracing.spans.Span.start(mark_as_current:bool=False)
Start the span.
methodsrc.agents.tracing.spans.Span.started_at() -> str | None
When the span started execution.
methodsrc.agents.tracing.spans.Span.trace_id() -> str
The ID of the trace this span belongs to.
methodsrc.agents.tracing.spans.Span.tracing_api_key() -> str | None
The API key to use when exporting this span.
classsrc.agents.tracing.spans.SpanError
Represents an error that occurred during span execution.
methodsrc.agents.tracing.traces.Trace.export() -> dict[str, Any] | None
Export the trace data as a serializable dictionary.
methodsrc.agents.tracing.traces.Trace.name() -> str
Get the human-readable name of this workflow trace.
methodsrc.agents.tracing.traces.Trace.to_json(*include_tracing_api_key:bool=False) -> dict[str, Any] | None
Serialize trace metadata for persistence or transport.
methodsrc.agents.tracing.traces.Trace.trace_id() -> str
Get the unique identifier for this trace.
classsrc.agents.tracing.traces.TraceImpl
A trace that will be recorded by the tracing library.
classsrc.agents.tracing.traces.TraceState
Serializable trace metadata for run state persistence.
funcsrc.agents.tracing.util.gen_group_id() -> str
Generate a new group ID.
funcsrc.agents.tracing.util.gen_span_id() -> str
Generate a new span ID.
funcsrc.agents.tracing.util.gen_trace_id() -> str
Generate a new trace ID.
funcsrc.agents.tracing.util.time_iso() -> str
Return the current time in ISO 8601 format.
classsrc.agents.usage.RequestUsage
Usage details for a single API request.
methodsrc.agents.usage.Usage.add(other:Usage) -> None
Add another Usage object to this one, aggregating all fields.
funcsrc.agents.usage.deserialize_usage(usage_data:Mapping[str, Any]) -> Usage
Rebuild a Usage object from serialized JSON data.
funcsrc.agents.usage.model_usage_to_span_usage(usage:Usage) -> dict[str, Any]
Serialize full per-model-call usage for tracing span data.
funcsrc.agents.usage.serialize_usage(usage:Usage) -> dict[str, Any]
Serialize a Usage object into a JSON-friendly dictionary.
funcsrc.agents.usage.task_usage_to_span_data(usage:Usage) -> dict[str, int]
Serialize aggregate per-task usage for custom task span data.
funcsrc.agents.usage.turn_usage_to_span_data(usage:Usage) -> dict[str, int]
Serialize aggregate per-turn usage for custom turn span data.
classsrc.agents.voice.events.VoiceStreamEventAudio
Streaming event from the VoicePipeline
classsrc.agents.voice.events.VoiceStreamEventError
Streaming event from the VoicePipeline
classsrc.agents.voice.events.VoiceStreamEventLifecycle
Streaming event from the VoicePipeline
classsrc.agents.voice.input.AudioInput
Static audio to be used as input for the VoicePipeline.
methodsrc.agents.voice.input.AudioInput.to_base64() -> str
Returns the audio data as a base64 encoded string.
classsrc.agents.voice.input.StreamedAudioInput
Audio input represented as a stream of audio data.
methodsrc.agents.voice.input.StreamedAudioInput.add_audio(audio:npt.NDArray[np.int16 | np.float32] | None) -> None
Adds more audio data to the stream.
classsrc.agents.voice.model.STTModelSettings
Settings for a speech-to-text model.
classsrc.agents.voice.model.StreamedTranscriptionSession
A streamed transcription of audio input.
methodsrc.agents.voice.model.StreamedTranscriptionSession.close() -> None
Closes the session.
methodsrc.agents.voice.model.StreamedTranscriptionSession.transcribe_turns() -> AsyncIterator[str]
Yields a stream of text transcriptions.
methodsrc.agents.voice.model.TTSModel.model_name() -> str
The name of the TTS model.

About this data

These signatures were extracted from the public source of openai/openai-agents-python using Python's ast module. Argument names, default values, type annotations and return types are taken verbatim from the code. Implementation bodies are never stored. See how it works for details.

Back to all 805 libraries