Self hosted gpt 4 is possible as long as you follow this tutorial!
ChatGPT is a powerful natural language processing model developed by OpenAI. It is trained on massive text corpora, enabling it to automatically understand and generate human language. It uses a Transformer neural network architecture and can handle various tasks like question answering, text generation, translation, summarization, and dialog. The current version is ChatGPT-4, and OpenAI has announced plans to release ChatGPT-5 in November 2023, which is quite exciting! But today we will first teach you how to deploy your own ChatGPT on a VPS!
Self Hosted GPT 4 Preparations
1. Apply for your OpenAI API key [Click to get API key]. If you don't have an OpenAI account yet, please register for free first.
2. You will need a VPS. Even a low-spec one is enough for use. If you don't have one, I recommend this: Browse Website Hosting Plans as Low as $10 a Month(3-day Trial Link). I'm using the same VPS in this tutorial.
Get The API key
After having an OpenAI account, open https://platform.openai.com/overview, click on your username in the top right corner, and select "view API keys" in the prompt that pops up.

Click "Create new secret key"

Make a copy of your key and keep it locally to prevent loss and have a backup.

SSH Connection
Log in to your Cloudways Platform using your email address and password.
From the top menu bar, open Servers.
Then, choose the server you just bought.

Under Server Management, you can find your username and password. Be sure to take note of it.
Tip
Click on a credential (e.g., password) to copy it to the clipboard.

Next, return to your target server page.

Click Launch SSH Terminal. This will open a new tab in your web browser.

You may see a security certificate warning in your web browser, this is due to the self-signed SSL certificate hired to protect your SSH connection. Simply bypass the warning and Proceed.

Then you need to input your master username, which you previously noted.
Tip
The terminal screen will only work with arrow keys for navigation, not with a mouse.

Next, enter your password. Please note that no characters will appear as you type the password due to security reasons.

You are now connected to your server via SSH.
Environment Set-Up
Install Docker with the following command:
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

The installation will take some time. Please be patient and wait for the following results to appear.

Next Step
Please make sure the Docker daemon is running. You can check its status by running the following command:
systemctl status docker

The above check results show it's not running,
If the Docker daemon is not running, you can start it with the following command:
sudo systemctl enable docker
sudo systemctl start docker

After running the above command, you can check the Docker service status again to confirm if it is running:

Install ChatGPT
Use this command:
docker run \
--name chatgpt-web \
-p 3002:3002 \
--env OPENAI_API_KEY=Your key \
--restart always \
-d chenzhaoyu94/chatgpt-web:latest
Remember to replace Your key with your own OpenAI key.

Now, your own web version of ChatGPT has been deployed.
You can now open ChatGPT by directly accessing your VPS IP at
http://xxx.xx.xx.xx:3002

Leave a Reply