OpenAI Responses

Use OpenAI's Responses API with Agno agents.

OpenAIResponses is a class for interacting with OpenAI models using the Responses API, which is distinct from the Chat Completions API. It supports tool use, file processing, and knowledge retrieval.

Installation

uv pip install -U "agno[openai]"

Authentication

Set your OPENAI_API_KEY environment variable. You can get one from OpenAI here.

export OPENAI_API_KEY=sk-***

Example

Use OpenAIResponses with your Agent:


from agno.agent import Agent
from agno.media import File
from agno.models.openai.responses import OpenAIResponses

agent = Agent(
    model=OpenAIResponses(id="gpt-5-mini"),
    tools=[{"type": "file_search"}, {"type": "web_search_preview"}],
    markdown=True,
)

agent.print_response(
    "Summarize the contents of the attached file and search the web for more information.",
    files=[File(url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf")],
)
View more examples here.

Parameters

See the OpenAI Responses docs.

ParameterTypeDefaultDescription
idstr"gpt-5.4-mini"The id of the OpenAI model to use with Responses API
namestr"OpenAIResponses"The name of the model
providerstr"OpenAI"The provider of the model
includeOptional[List[str]]NoneAdditional output data to include in the response
max_output_tokensOptional[int]NoneMaximum number of output tokens to generate
max_tool_callsOptional[int]NoneMaximum number of tool calls allowed in the response
metadataOptional[Dict[str, Any]]NoneDeveloper-defined metadata to associate with the response
parallel_tool_callsOptional[bool]NoneWhether to enable parallel function calling
reasoningOptional[Dict[str, Any]]NoneReasoning configuration for reasoning models
verbosityOptional[Verbosity]NoneControls verbosity of the model's output
reasoning_effortOptional[ReasoningEffort]NoneReasoning effort level for reasoning models
reasoning_summaryOptional[ReasoningSummary]NoneLevel of detail for reasoning summaries
storeOptional[bool]NoneWhether to store the response for later retrieval
temperatureOptional[float]NoneControls randomness in the model's output (0.0 to 2.0)
top_pOptional[float]NoneControls diversity via nucleus sampling (0.0 to 1.0)
truncationOptional[Literal["auto", "disabled"]]NoneTruncation strategy when context exceeds the window
userOptional[str]NoneA unique identifier representing your end-user
service_tierOptional[ServiceTier]NoneService tier to use for the request
strict_outputboolTrueControls schema adherence for structured outputs
backgroundOptional[bool]NoneEnables background mode for long-running tasks. Not supported for streaming
background_poll_intervalfloat2.0Interval in seconds between polling attempts in background mode
background_max_waitfloat600.0Maximum time in seconds to wait for a background response before cancelling
extra_headersOptional[Any]NoneAdditional headers to include in requests
extra_queryOptional[Any]NoneAdditional query parameters to include in requests
extra_bodyOptional[Any]NoneAdditional body parameters to include in requests
request_paramsOptional[Dict[str, Any]]NoneAdditional parameters to include in the request
api_keyOptional[str]NoneThe API key for authenticating with OpenAI (defaults to OPENAI_API_KEY env var)
organizationOptional[str]NoneThe organization ID to use for requests
base_urlOptional[Union[str, httpx.URL]]NoneThe base URL for the OpenAI API
timeoutOptional[float]NoneRequest timeout in seconds
max_retriesOptional[int]NoneMaximum number of retries for failed requests
default_headersOptional[Dict[str, str]]NoneDefault headers to include in all requests
default_queryOptional[Dict[str, str]]NoneDefault query parameters to include in all requests
http_clientOptional[Union[httpx.Client, httpx.AsyncClient]]NoneHTTP client instance for making requests
client_paramsOptional[Dict[str, Any]]NoneAdditional parameters for client configuration
clientOptional[OpenAI]NoneA pre-configured instance of the OpenAI client
async_clientOptional[AsyncOpenAI]NoneA pre-configured instance of the async OpenAI client
vector_store_namestr"knowledge_base"Name of the vector store created for the file_search built-in tool
role_mapDict[str, str]Maps system to developerMapping of message roles to OpenAI Responses roles

ReasoningEffort, ReasoningSummary, ServiceTier, and Verbosity are string-extensible aliases from agno.models.openai.types. Named effort values are none, minimal, low, medium, high, xhigh, and max; named tiers are auto, default, flex, scale, priority, fast, and ultrafast. Summary values include auto, concise, and detailed; verbosity includes low, medium, and high. Agno forwards these settings, but the selected OpenAI model, endpoint, and account determine which values are accepted.

OpenAIResponses is a subclass of the Model class and has access to the same params.