AI

How to Use ChatGPT on Linux

ChatGPT is an AI chatbot developed by OpenAI that allows you to search for any queries related to facts and information, creative text format, decent conversation, and much more. It was developed to help people get adequate knowledge about a specific source. However, it can only access information that it has been trained on. This means that if you ask ChatGPT a question about something that it has not been trained on, it may not be able to answer it correctly.

You can easily use ChatGPT on your browser by just login to the OpenAI account with your email and password. However, if you want to use it locally on your Linux terminal, it might not be straightforward.

Read this post to learn the usage of ChatGPT on Linux.

How to Use ChatGPT on Linux

Follow the below-given steps to learn how to use ChatGPT on Linux:

Step 1: Open the Firefox browser on your Linux system and visit the ChatGPT website. Choose the Login button if you have already created an account on ChatGPT or use Sign Up if you are a new user.

Step 2: Login to ChatGPT using your email account.

Step 3: Provide a password, then select the Continue button.

Step 4: Now choose the API option.

Step 5: On the left side of the browser window, choose the View API keys option.

Step 6: Select the Create new secret key option.

Step 7: Choose the name for your secret key and then select the Create secret key button.

After this step, your secret key will be generated and you can copy it and save it somewhere else.

Step 8: You must create an environment variable by utilizing the export command:

export OPENAI_API_KEY=<OpenAI_API_key_key>

You must type in your API key in place of <OpenAI_API_key_key> and then execute the command in the terminal.

Step 9: To verify whether the environment variable has been set correctly or not, run the provided command:

env

Step 10: Now open the bash configuration file on your Linux terminal from the following command:

nano .bashrc

Step 11: Add in the following line inside the bash configuration file, as shown below:

export OPENAI_API_KEY=<OpenAI_API_key_key>

Step 12: Save the file using Ctrl+X, add Y and press enter.

Step 13: Now reload the added changes to the file by executing the below-given command:

source .bashrc

Step 14: You can then verify your changes by running the following command:

env

Once you are done with the changes, it’s now time to install a command-line tool for ChatGPT called Shell GPT that you should install on your Linux system to interact with the ChatGPT.

How to Install Shell GPT on Linux

You can install Shell GPT tool on your Linux system easily from the following pip command:

pip3 install shell-gpt

After completing the Shell GPT installation, you can start searching for queries directly from your terminal using the following syntax:

sgpt "queries"

That’s all! We have described the usage of ChatGPT on Linux.

Conclusion

ChatGPT is an AI chatbot developed by OpenAI that enables users to search for any queries related to facts and information, creative text format, decent conversation, and much more. Linux users can also use ChatGPT for generating content. For that purpose, first, they need to create an API key. Then, with the help of the key they can use ChtaGPT on the terminal. This post demonstrated the ChatGPT usage on Linux.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.