# OpenAI (https://www.librechat.ai/docs/configuration/pre_configured_ai/openai)

To get your OpenAI API key, you need to:

- Go to **[https://platform.openai.com/account/api-keys](https://platform.openai.com/account/api-keys)**
- Create an account or log in with your existing one
- Add a payment method to your account
- Go to https://platform.openai.com/api-keys to get a key.
- You will need to set the following environment variable to your key, or you can set it to `user_provided` for users to provide their own.

```bash filename=".env"
OPENAI_API_KEY=user_provided
```

<Callout type="info" title="Where users enter their own key">

With `user_provided`, you supply no key at all: each user enters their own from the chat UI. Open the endpoint menu, and next to **OpenAI** there is a gear icon labelled **Set API Key**. Clicking it opens a dialog with a field for the key and a dropdown for how long it should be kept: 30 minutes, 2 hours, 12 hours (the default), 1 day, 7 days, 30 days, or never expire.

The key is encrypted and stored server-side against that user's account, so it is entered once rather than per conversation, and it is never shared with other users. The same dialog has a **Revoke** action, plus **Revoke All** to clear every key that user has stored.

If the endpoint menu is hidden, for example because a model spec disables `modelSelect`, the same dialog is reachable from **Settings** under **Data controls**, in the **API keys** section.

Until a user sets a key, the endpoint is visible but unusable for them.

</Callout>

- You can determine which models you would like to have available with `OPENAI_MODELS`
  - When `OPENAI_API_KEY` is set to `user_provided` → only the models put in this list will be available
    - ⚠️New models won't automatically show up; you'll need to add them to this list first
  - When `OPENAI_API_KEY` is set to the actual API key value → as long as `OPENAI_MODELS` is left commented-out, it will do an API call to find out what models are available, which should include any new ones

```bash filename=".env"
OPENAI_MODELS=gpt-5.6,gpt-5.6-terra,gpt-5.6-luna,gpt-5.5,gpt-5.5-pro,chat-latest,gpt-5.4,gpt-5.4-pro,gpt-5.4-mini,gpt-5.4-nano,gpt-5.3-codex,gpt-5.2,gpt-5,gpt-5-codex,gpt-5-mini,gpt-5-nano,o3-pro,o3,o4-mini,gpt-4.1,gpt-4.1-mini,gpt-4.1-nano,o3-mini,o1-pro,o1,gpt-4o,gpt-4o-mini
```

**Notes:**

- Internal OpenAI defaults include `gpt-5.6`, `gpt-5.6-terra`, and `gpt-5.6-luna`, followed by the existing GPT-5 catalog. `gpt-5.6` is the Sol tier alias; LibreChat assigns all three GPT-5.6 tiers a 1,050,000-token context window and 128,000-token maximum output. Deprecated legacy defaults are no longer included unless you add them explicitly with `OPENAI_MODELS`.
- GPT-5.6 supports the Responses API-only `reasoning_mode` values `standard` and `pro`, plus `reasoning_context` values `auto`, `current_turn`, and `all_turns`. These can be configured in [model specs](/docs/configuration/librechat_yaml/object_structure/model_specs#reasoning_mode).
- For a GPT-5.6 model with a non-`none` `reasoning_effort`, LibreChat defaults the canonical OpenAI endpoint to the Responses API so function tools remain compatible. An explicit `useResponsesApi: false` keeps Chat Completions. Azure OpenAI, OpenRouter, and custom or reverse-proxy base URLs are not switched automatically.
- Selecting a vision model for messages with attachments is not necessary as it will be switched behind the scenes for you. If you didn't outright select a vision model, it will only be used for the vision request and you should still see the non-vision model you had selected after the request is successful
- OpenAI Vision models allow for messages without attachments
- OpenAI endpoint supports all [Shared Endpoint Settings](/docs/configuration/librechat_yaml/object_structure/shared_endpoint_settings) via the `librechat.yaml` configuration file, including `streamRate`, `headers`, `titleModel`, `titleMethod`, `titlePrompt`, `titlePromptTemplate`, and `titleEndpoint`
