> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-service-account.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI

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

## Parameters

| Parameter                            | Type                                               | Default           | Description                                                                                                        |
| ------------------------------------ | -------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------ |
| `id`                                 | `str`                                              | `"gpt-5.4-mini"`  | The id of the OpenAI model to use                                                                                  |
| `name`                               | `str`                                              | `"OpenAIChat"`    | The name of the model                                                                                              |
| `provider`                           | `str`                                              | `"OpenAI"`        | The provider of the model                                                                                          |
| `collect_metrics_on_completion`      | `bool`                                             | `False`           | Collect token metrics only from the final streaming chunk (for providers with cumulative token counts)             |
| `store`                              | `Optional[bool]`                                   | `None`            | Whether to store the conversation for training purposes                                                            |
| `reasoning_effort`                   | `Optional[str]`                                    | `None`            | The reasoning effort level for o1 models ("low", "medium", "high")                                                 |
| `verbosity`                          | `Optional[Literal["low", "medium", "high"]]`       | `None`            | Controls verbosity level of reasoning models                                                                       |
| `metadata`                           | `Optional[Dict[str, Any]]`                         | `None`            | Developer-defined metadata to associate with the completion                                                        |
| `frequency_penalty`                  | `Optional[float]`                                  | `None`            | Penalizes new tokens based on their frequency in the text so far (-2.0 to 2.0)                                     |
| `logit_bias`                         | `Optional[Any]`                                    | `None`            | Modifies the likelihood of specified tokens appearing in the completion                                            |
| `logprobs`                           | `Optional[bool]`                                   | `None`            | Whether to return log probabilities of the output tokens                                                           |
| `top_logprobs`                       | `Optional[int]`                                    | `None`            | Number of most likely tokens to return log probabilities for (0 to 20)                                             |
| `max_tokens`                         | `Optional[int]`                                    | `None`            | Maximum number of tokens to generate (deprecated, use max\_completion\_tokens)                                     |
| `max_completion_tokens`              | `Optional[int]`                                    | `None`            | Maximum number of completion tokens to generate                                                                    |
| `modalities`                         | `Optional[List[str]]`                              | `None`            | List of modalities to use ("text" and/or "audio")                                                                  |
| `audio`                              | `Optional[Dict[str, Any]]`                         | `None`            | Audio configuration (e.g., `{"voice": "alloy", "format": "wav"}`)                                                  |
| `presence_penalty`                   | `Optional[float]`                                  | `None`            | Penalizes new tokens based on whether they appear in the text so far (-2.0 to 2.0)                                 |
| `seed`                               | `Optional[int]`                                    | `None`            | Random seed for deterministic sampling                                                                             |
| `stop`                               | `Optional[Union[str, List[str]]]`                  | `None`            | Up to 4 sequences where the API will stop generating further tokens                                                |
| `temperature`                        | `Optional[float]`                                  | `None`            | Controls randomness in the model's output (0.0 to 2.0)                                                             |
| `user`                               | `Optional[str]`                                    | `None`            | A unique identifier representing your end-user                                                                     |
| `top_p`                              | `Optional[float]`                                  | `None`            | Controls diversity via nucleus sampling (0.0 to 1.0)                                                               |
| `service_tier`                       | `Optional[str]`                                    | `None`            | Service tier to use ("auto", "default", "flex", "priority")                                                        |
| `strict_output`                      | `bool`                                             | `True`            | Controls schema adherence for structured outputs                                                                   |
| `extra_headers`                      | `Optional[Any]`                                    | `None`            | Additional headers to include in requests                                                                          |
| `extra_query`                        | `Optional[Any]`                                    | `None`            | Additional query parameters to include in requests                                                                 |
| `extra_body`                         | `Optional[Any]`                                    | `None`            | Additional body parameters to include in requests                                                                  |
| `request_params`                     | `Optional[Dict[str, Any]]`                         | `None`            | Additional parameters to include in the request                                                                    |
| `role_map`                           | `Optional[Dict[str, str]]`                         | `None`            | Mapping of message roles to OpenAI roles                                                                           |
| `api_key`                            | `Optional[str]`                                    | `None`            | The API key for authenticating with OpenAI (defaults to OPENAI\_API\_KEY env var)                                  |
| `organization`                       | `Optional[str]`                                    | `None`            | The organization ID to use for requests                                                                            |
| `base_url`                           | `Optional[Union[str, httpx.URL]]`                  | `None`            | The base URL for the OpenAI API                                                                                    |
| `timeout`                            | `Optional[float]`                                  | `None`            | Request timeout in seconds                                                                                         |
| `max_retries`                        | `Optional[int]`                                    | `None`            | Maximum number of retries for failed requests                                                                      |
| `default_headers`                    | `Optional[Any]`                                    | `None`            | Default headers to include in all requests                                                                         |
| `default_query`                      | `Optional[Any]`                                    | `None`            | Default query parameters to include in all requests                                                                |
| `http_client`                        | `Optional[Union[httpx.Client, httpx.AsyncClient]]` | `None`            | HTTP client instance for making requests                                                                           |
| `client_params`                      | `Optional[Dict[str, Any]]`                         | `None`            | Additional parameters for client configuration                                                                     |
| `client`                             | `Optional[OpenAIClient]`                           | `None`            | A pre-configured instance of the OpenAI client                                                                     |
| `async_client`                       | `Optional[AsyncOpenAIClient]`                      | `None`            | A pre-configured instance of the async OpenAI client                                                               |
| `model_type`                         | `ModelType`                                        | `ModelType.MODEL` | Functional role of this model (`MODEL`, `OUTPUT_MODEL`, or `PARSER_MODEL`). Set by the agent during initialization |
| `supports_native_structured_outputs` | `bool`                                             | `True`            | True if the model supports structured outputs natively                                                             |
| `supports_json_schema_outputs`       | `bool`                                             | `False`           | True if the model requires a JSON schema for structured outputs                                                    |
| `system_prompt`                      | `Optional[str]`                                    | `None`            | System prompt from the model added to the Agent                                                                    |
| `instructions`                       | `Optional[List[str]]`                              | `None`            | Instructions from the model added to the Agent                                                                     |
| `tool_message_role`                  | `str`                                              | `"tool"`          | Role used for tool messages                                                                                        |
| `assistant_message_role`             | `str`                                              | `"assistant"`     | Role used for assistant messages                                                                                   |
| `cache_response`                     | `bool`                                             | `False`           | Cache model responses to avoid redundant API calls during development                                              |
| `cache_ttl`                          | `Optional[int]`                                    | `None`            | Time-to-live for cached model responses, in seconds. If None, cache never expires                                  |
| `cache_dir`                          | `Optional[str]`                                    | `None`            | Directory for cached model responses. If None, uses the default cache location                                     |
| `retries`                            | `int`                                              | `0`               | Number of retries to attempt before raising a ModelProviderError                                                   |
| `delay_between_retries`              | `int`                                              | `1`               | Delay between retries, in seconds                                                                                  |
| `exponential_backoff`                | `bool`                                             | `False`           | If True, the delay between retries is doubled each time                                                            |
| `retry_with_guidance`                | `bool`                                             | `True`            | Retry the model invocation with a guidance message for known errors avoidable with extra instructions              |
| `retry_with_guidance_limit`          | `int`                                              | `1`               | Number of times to retry the model invocation with guidance                                                        |
