An easy-to-install ChatGPT clone you can host on your own web server.
You will need the following in order to use this application:
1. An OpenAI API key: Click here to sign up for an OpenAI account if you don't already have one.
2. Web Hosting and Domain Name (If you don't already have web hosting and domain name, I highly recommend SiteGround. They have the best service and easiest to use IMO.)
Step 1. Download the source zip file.
Step 2. Extract the source files from the zip to a local directory.
Step 3. Add your OpenAI API key to the chat.php file:
// Add your OpenAI API Key below
$chat = new ChatGPT([
'api_key' => 'OPENAI_API_KEY_GOES_HERE',
]);
Step 4. Upload the source files to the root directory of your public HTML web server.
Step 5. Enjoy your personal ChatGPT clone!
To protect your OpenAI API key from being used by the general public, I suggest you incorporate a password or page protection on your Chat's URL through your web host. Most web hosts allow you to password protect specified directories directly from your host dashboard.
If you want to activate a welcome splash screen at first startup:
- Go to the pref.js file in the static/js folder
- Remove the comment lines from the following code and change text as necessary:
/*
if (localStorage.getItem('isFunctionCalled') === 'true') {
console.log('Function Called');
} else {
console.log('Call Function');
window.onload = function() {
var div = document.getElementById("messages");
div.innerHTML = `<div style="margin: auto; width: 50%; align-items: center;"><div class="user">
<img src="static/img/opnai.png" style="display: block; max-width: 100%;"><p> </p>
</div>
<div class="content">
<p><b>Hi!</b></p>
<p> </p>
<p>I am Open AI ChatGPT.</p>
<p> </p>
<p>I will gladly answer all questions.</p>
</div></div>`;
setTimeout(function() {
div.innerHTML = "";
}, 3000);
}
localStorage.setItem('isFunctionCalled', 'true');
}
*/
Once the files have been uploaded to your root directory (or sub-domain or directory), simply navigate to your URL to access the chat from your browser.
Note: Defaults to model 3.5 if you don't have access to the GPT-4 API, regardless of which model you choose.
Most of this was put together by @alexsky177.
I just added web access and model choices, and removed the default splash pop-up.
Files are a combination of the following projects:
HTML & CSS: https://github.com/xtekky/chatgpt-clone
PHP Classes: https://github.com/qiayue/php-openai-gpt-stream-chat-api-webui