OpenAI

Configure OpenAIChat, Agno's model class for OpenAI's Chat Completions API.

The OpenAIChat model provides access to OpenAI models using the Chat Completions API.

Parameters

ParameterTypeDefaultDescription
idstr"gpt-5.4-mini"The id of the OpenAI model to use
namestr"OpenAIChat"The name of the model
providerstr"OpenAI"The provider of the model
collect_metrics_on_completionboolFalseCollect token metrics only from the final streaming chunk (for providers with cumulative token counts)
storeOptional[bool]NoneWhether to retain the completion for use in OpenAI distillation or evals; this field is not a general training-consent setting.
reasoning_effortOptional[ReasoningEffort]NoneModel-dependent reasoning effort; use values supported by the selected provider and model.
verbosityOptional[Verbosity]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 completion-token budget, including visible output and reasoning tokens.
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]NoneBest-effort repeatability; identical requests may still produce different results.
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[ServiceTier]NoneService tier to use ("auto", "default", "flex", "priority")
strict_outputboolTrueRequests strict schema handling when a supported structured-output path is used; provider and model support still apply.
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
clientOptional[OpenAIClient]NoneA pre-configured instance of the OpenAI client
async_clientOptional[AsyncOpenAIClient]NoneA pre-configured instance of the async OpenAI client
model_typeModelTypeModelType.MODELFunctional role of this model (MODEL, OUTPUT_MODEL, or PARSER_MODEL). Set by the agent during initialization
supports_native_structured_outputsboolTrueTrue if the model supports structured outputs natively
supports_json_schema_outputsboolFalseTrue if the model requires a JSON schema for structured outputs
system_promptOptional[str]NoneSystem prompt from the model added to the Agent
instructionsOptional[List[str]]NoneInstructions from the model added to the Agent
tool_message_rolestr"tool"Role used for tool messages
assistant_message_rolestr"assistant"Role used for assistant messages
cache_responseboolFalseCache model responses to avoid redundant API calls during development
cache_ttlOptional[int]NoneTime-to-live for cached model responses, in seconds. If None, cache never expires
cache_dirOptional[str]NoneDirectory for cached model responses. If None, uses the default cache location
retriesint0Number of retries to attempt before raising a ModelProviderError
delay_between_retriesint1Delay between retries, in seconds
exponential_backoffboolFalseIf True, the delay between retries is doubled each time
retry_with_guidanceboolTrueRetry the model invocation with a guidance message for known errors avoidable with extra instructions
retry_with_guidance_limitint1Number of times to retry the model invocation with guidance

The string-compatible types ReasoningEffort, ReasoningSummary, ServiceTier, and Verbosity are defined in agno.models.openai.types. Accepted API values depend on the selected model; see the provider's API reference.