Skip to main content
OpenAIResponses is a class for interacting with OpenAI models using the Responses API. This class provides a streamlined interface for working with OpenAI’s newer Responses API, which is distinct from the traditional Chat API. It supports advanced features like tool use, file processing, and knowledge retrieval.

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

For more information, please refer to the OpenAI Responses docs as well.
ParameterTypeDefaultDescription
idstr"gpt-5-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
instructionsOptional[str]NoneSystem-level instructions for the assistant
response_formatOptional[Union[str, Dict]]NoneResponse format specification for structured outputs
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)
max_completion_tokensOptional[int]NoneMaximum number of completion tokens to generate
truncation_strategyOptional[Dict[str, Any]]NoneStrategy for truncating messages when they exceed context limits
tool_choiceOptional[Union[str, Dict]]NoneControls which function is called by the model
parallel_tool_callsOptional[bool]NoneWhether to enable parallel function calling
metadataOptional[Dict[str, str]]NoneDeveloper-defined metadata to associate with the response
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[Any]NoneDefault headers to include in all requests
http_clientOptional[Union[httpx.Client, httpx.AsyncClient]]NoneHTTP client instance for making requests
OpenAIResponses is a subclass of the Model class and has access to the same params.
I