# Connect OpenAI to Unsloth: Run GPT Models in Local Chat

Learn how to connect OpenAI models, including GPT-5.5 to [Unsloth](https://github.com/unslothai/unsloth) so you can chat with all of them in an open-source local UI chat interface. By connecting your OpenAI API key, you can run GPT models inside Unsloth with features like reasoning, web search, tool calling, code execution, reusable code containers, and prompt caching.

This guide walks you through creating an OpenAI API key, connecting OpenAI as a provider, loading available models, and troubleshooting common setup issues.

### Setup

{% stepper %}
{% step %}

#### Create an OpenAI API key

Create an API key from the OpenAI dashboard:

<https://platform.openai.com/api-keys>

<figure><img src="/files/PXaINS0IoRIME98oPVwT" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Configure Connections

Next, connect your provider to Unsloth.

1. Open **Settings** → **Connections**, then click **Add Connection.**
2. Select the OpenAI, then paste the API key you copied earlier.
3. Click **Reload Models** to refresh the list with models available to your account.
4. Choose the models you want to enable, then hit save.&#x20;

<figure><img src="/files/wyW65uOZY4CSsSkvex2G" alt=""><figcaption></figcaption></figure>

#### Ready to Chat

The models you enabled will now appear under **Connected** in the **Select Model** dropdown.

<figure><img src="/files/slAfNAB9X34kfWOWUKcC" alt="" width="343"><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### Web Search & Thinking

Provider-side web search is available for supported models from OpenAI.

<figure><img src="/files/9hxbjfC8Cjif2CPpcAlG" alt="" width="563"><figcaption></figcaption></figure>

The **Think** control adapts to the selected model: some models use an on/off toggle, while reasoning-effort models use model specific thinking levels.&#x20;

### Code Execution

When enabled, supported OpenAI models can run code in a provider sandbox to solve problems, analyse data, and work with files.

<figure><img src="/files/u855tCuYk5dXEqW74c2y" alt="" width="563"><figcaption></figcaption></figure>

OpenAI uses reusable shell containers. In **Code Execution** settings, you can set the idle timeout, create containers, select the active container, refresh the list, or delete old containers.

<figure><img src="/files/uQSaDCf9MocZjwTlbJ2u" alt="" width="288"><figcaption></figcaption></figure>

Select the same container in a new thread to continue with its files and state.

### Prompt Caching

Prompt caching reduces latency and cost when requests reuse the same long prefix. It is supported for compatible providers and servers, including OpenAI.

<figure><img src="/files/rd7uqDkUz6YnddW01aRl" alt=""><figcaption></figcaption></figure>

Use the **Prompt caching** setting in the side panel to control caching behaviour for supported connections.

### Troubleshooting

If OpenAI fails to connect, check that the API key is valid and belongs to the correct OpenAI account.

If a model does not appear after clicking **Load Models**, it may not be available for your account. You can enter the model ID manually or choose another model.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://unsloth.ai/docs/integrations/connections/openai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
