Unleash the Power of ChatGPT 3.5 with a Sleek Local GUI

Unleash the Power of ChatGPT 3.5 with a Sleek Local GUI

Welcome to the future of AI-driven chat experiences! In this blog post, I'm excited to showcase a project that allows you to harness the power of OpenAI's ChatGPT GPT-3.5 through a sleek and intuitive local GUI. Say goodbye to clunky interfaces and embrace the simplicity of this fantastic new approach. Let's dive in and explore how it works!

Project Overview

My project consists of two main files: gpt_gui.py and test_api_key.py. The first file, gpt_gui.py, contains all the necessary code to create a minimalistic yet effective GUI for interacting with ChatGPT 3.5, while the second file, test_api_key.py, is a quick script to test your API key.

Building the GUI

The GUI is created using the PySimpleGUI library, which offers a straightforward way to build graphical interfaces for your Python applications. Let's take a closer look at the layout and components of the GUI:

sg.set_options(font=("Helvetica", 12))

layout = [
    [sg.Text('Local ChatGPT 3.5', font=("Helvetica", 20), justification='center', size=(40, 1))],
    [sg.Multiline(key='-INPUT-', size=(60, 10))],
    [sg.Button('Send'), sg.Button('Exit')],
    [sg.Text('Response:', font=("Helvetica", 14))],
    [sg.Column([[sg.Multiline(size=(60, 20), key='-OUTPUT-', font=("Helvetica", 12), disabled=True)]], size=(600, 300), scrollable=True)],
    [sg.ProgressBar(100, orientation='h', size=(20, 20), key='-PROGRESS-', visible=False)]

window = sg.Window('ChatGPT 3.5', layout, icon='icon.ico')

The GUI consists of the following elements:

  • A title text: "Local ChatGPT 3.5"
  • A multiline input box to enter your query
  • Two buttons: "Send" to submit the query and "Exit" to close the application
  • A "Response" text label
  • A multiline output box to display the response from ChatGPT 3.5
  • A progress bar, hidden by default, to show the loading status

Interacting with the OpenAI API

Once the GUI is set up, you need to establish communication with the OpenAI API. First, you'll need to replace YOUR-API-KEY-HERE with your actual API key.

openai.api_key = "YOUR-API-KEY-HERE"

I'll be using the text-davinci-002 model engine for this example.

model_engine = "text-davinci-002"

Main Event Loop

The main event loop is where the magic happens. It listens for user input, sends the query to the OpenAI API, and displays the response.

while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == 'Exit':

    prompt = values['-INPUT-']
    window['-PROGRESS-'].update(0, visible=True)

        for i in range(100):

        response = openai.Completion.create(

    except openai.Error as e:
        window['-OUTPUT-'].update(f'Error: {e}')


In the loop, we wait for the user to press either the "Send" or "Exit" button. If the user chooses to exit, we break out of the loop and close the application. If the user submits a query, we send the request to the OpenAI API and display the response in the output box. The progress bar is also shown during the request and hidden once the response is received.

Testing Your API Key

Before diving into the ChatGPT GUI, it's essential to ensure that your API key is working correctly. The `test_api_key.py` script does just that:

import openai

# Set up OpenAI API key
openai.api_key = "YOUR-API-KEY-HERE"

# Test API key
models = openai.Model.list()

Simply replace YOUR-API-KEY-HERE with your actual API key, run the script, and you should see the list of available models printed on your console. If everything is working correctly, you're all set to use the GUI!


Now you have an elegant and easy-to-use local GUI to interact with OpenAI's ChatGPT GPT-3.5! This minimalistic approach makes it simple to engage with the powerful AI capabilities provided by OpenAI's API. The GUI can also be easily customized and extended to suit your specific needs or preferences.

Happy chatting!