Skip to main content
The GPT models are the best in class LLMs and used as the default LLM by Agents. OpenAI supports a variety of world-class models. See their models here. We recommend experimenting to find the best-suited model for your use-case. Here are some general recommendations:
  • gpt-5-mini is good for most general use-cases.
  • gpt-5-nano model is good for smaller tasks and faster inference.
  • o1 models are good for complex reasoning and multi-step tasks.
  • gpt-5-mini is a strong reasoning model with support for tool-calling and structured outputs, but at a much lower cost.
OpenAI have tier based rate limits. See the docs for more information.

Authentication

Set your OPENAI_API_KEY environment variable. You can get one from OpenAI here.
export OPENAI_API_KEY=sk-***

Example

Use OpenAIChat with your Agent:

from agno.agent import Agent
from agno.models.openai import OpenAIChat

agent = Agent(
    model=OpenAIChat(id="gpt-5-mini"),
    markdown=True
)

# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story.")

View more examples here.

Parameters

For more information, please refer to the OpenAI docs as well.
ParameterTypeDefaultDescription
idstr"gpt-4o"The id of the OpenAI model to use
namestr"OpenAIChat"The name of the model
providerstr"OpenAI"The provider of the model
storeOptional[bool]NoneWhether to store the conversation for training purposes
reasoning_effortOptional[str]NoneThe reasoning effort level for o1 models (“low”, “medium”, “high”)
verbosityOptional[Literal["low", "medium", "high"]]NoneControls verbosity level of reasoning models
metadataOptional[Dict[str, Any]]NoneDeveloper-defined metadata to associate with the completion
frequency_penaltyOptional[float]NonePenalizes new tokens based on their frequency in the text so far (-2.0 to 2.0)
logit_biasOptional[Any]NoneModifies the likelihood of specified tokens appearing in the completion
logprobsOptional[bool]NoneWhether to return log probabilities of the output tokens
top_logprobsOptional[int]NoneNumber of most likely tokens to return log probabilities for (0 to 20)
max_tokensOptional[int]NoneMaximum number of tokens to generate (deprecated, use max_completion_tokens)
max_completion_tokensOptional[int]NoneMaximum number of completion tokens to generate
modalitiesOptional[List[str]]NoneList of modalities to use (“text” and/or “audio”)
audioOptional[Dict[str, Any]]NoneAudio configuration (e.g., {"voice": "alloy", "format": "wav"})
presence_penaltyOptional[float]NonePenalizes new tokens based on whether they appear in the text so far (-2.0 to 2.0)
seedOptional[int]NoneRandom seed for deterministic sampling
stopOptional[Union[str, List[str]]]NoneUp to 4 sequences where the API will stop generating further tokens
temperatureOptional[float]NoneControls randomness in the model’s output (0.0 to 2.0)
userOptional[str]NoneA unique identifier representing your end-user
top_pOptional[float]NoneControls diversity via nucleus sampling (0.0 to 1.0)
service_tierOptional[str]NoneService tier to use (“auto”, “default”, “flex”, “priority”)
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
role_mapOptional[Dict[str, str]]NoneMapping of message roles to OpenAI roles
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
default_queryOptional[Any]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
OpenAIChat is a subclass of the Model class and has access to the same params.
I