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

Params

For more information, please refer to the OpenAI Responses docs as well.

NameTypeDefaultDescription
idstr"gpt-4o"The id of the OpenAI model to use.
namestr"OpenAIResponses"The name of this response model instance.
providerstr"OpenAI"The provider of the model.
includeOptional[List[str]]NoneList of response components to include in the response.
max_output_tokensOptional[int]NoneThe maximum number of tokens to generate in the response output.
metadataOptional[Dict[str, Any]]NoneAdditional metadata to include with the request.
parallel_tool_callsOptional[bool]NoneWhether to allow parallel tool calls.
reasoningOptional[Dict[str, Any]]NoneParameters for enabling and controlling reasoning/thinking in the response.
storeOptional[bool]NoneWhether to store the output of this response request for model distillation or evals.
temperatureOptional[float]NoneControls randomness in the model's output.
top_pOptional[float]NoneControls diversity via nucleus sampling.
truncationOptional[str]NoneHow to handle content that exceeds the token limit.
userOptional[str]NoneA unique identifier representing your end-user.
response_formatOptional[Any]NoneAn object specifying the format that the model must output.
request_paramsOptional[Dict[str, Any]]NoneAdditional parameters to include in the request.
api_keyOptional[str]NoneThe API key for authenticating with OpenAI.
organizationOptional[str]NoneThe organization to use for API requests.
base_urlOptional[Union[str, httpx.URL]]NoneThe base URL for API requests.
timeoutOptional[float]NoneThe timeout for API requests.
max_retriesOptional[int]NoneThe maximum 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[httpx.Client]NoneAn optional pre-configured HTTP client.
client_paramsOptional[Dict[str, Any]]NoneAdditional parameters for client configuration.
vector_store_namestr"knowledge_base"The name of the vector store for file uploads and retrieval.

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