How to use ChatGPT 3.5 from your terminal without API Keys using tgpt

David Rutland
David Rutland CLI

AI chatbots are a wonder of the modern age and can assist with everything from coding to poetry. But accessing ChatGPT usually means signing up for an account. tgpt is a terminal interface that doesn't require an account or API key, and allows you to use ChatGPT 3.5 without leaving your terminal.

Why use tgpt?

When you sign up to use ChatGPT all of your queries, conversations, idle musings, and boundary-pushing questions are tied to your account.

Aside from the obvious privacy risks associated with using ChatGPT, a transcript of all your interactions could prove to be embarrassing - especially if you use the chatbot for writing difficult emails, cut your medical insurance premiums by using ChatGPT as a therapist, or use AI to prognosticate the future.

Using ChatGPT through the web interface is a far from ideal experience, and while there are already CLI tools that let you use ChatGPT from the Linux terminal, these require you to use an API key - a process that both complicates setting up the tool, and ensures that OpenAI can associate your queries with you - even if you use a VPN to hide your IP address.

By installiing tgpt, you get the convenience of using ChatGPT in your terminal, and you don't need to provide an API key or account details. You can use tgpt wherever you are, and even access it from behind a VPN.

How to install tgpt on Linux

terminal output for installing tgpt with go

The easiest way to install tgpt on Linux is with Go, so make sure you have Go installed before you begin.

Now you can use Go to install tgpt:

go install github.com/aandrew-me/tgpt@latest

Go will install tgpt to ~/go/bin/tgpt

If you want to easily use tgpt from any terminal location, you should create a symbolic link:

sudo ln -s ~/go/bin/tgpt /usr/bin/tgpt

You can start tgpt by typing:

tgpt

...wherever you are in the terminal.

Unfortunately, this won't work on Windows, and is yet another addition to why Linux is better than Windows.

Use tgpt to get ChatGPT in your terminal

tgpt in interactive mode showing a haiku about dogs and one about cats

Using tgpt couldn't be easier. If you have a one of query or request for ChatGPT, and, for instance, want the chatbot to write a haiku about dogs, you'd enter:

tgpt 'Write a haiku about dogs'

Remember to surround your query with quote marks or tgpt will return a response for the first word only. Without quote marks in the above example, tgpt will respond as if you queried:

tgpt write

Not so useful.

tgpt is most useful in interactive mode. To start tgpt in interactive mode, use the i flag:

tgpt -i

This allows you to conduct a complete conversation with ChatGPT, and its responses will be flavoured by your previous replies.

As with the web interface, your conversations can be long, meandering, and cover many topics.

You can can force tgpt to forget the chat ID with:

tgpt -f

Other useful flags include:

-s Generate and Execute shell commands. (Experimental)
-c Generate Code. (Experimental)
-q Gives response back without loading animation
-w Gives response back as a whole text
-v Print version
-h Print help message
-m Start multi-line interactive mode
-u Update program

Unlike with the ChatGPT web interface, you can use tgpt even when your hiding behind a VPN. This doesn't mean you can get away with naughty queries, though. Ask tgpt an inappropriate query and it'll respond that it's unable to assist you

Is tgpt too good to be true?

In a word, yes.

tgpt is an awesome and fun way to access ChatGPT from your terminal, but it isn't truly a way to do it without API keys.

Instead of using your API key, tgpt uses the programme author's ChatGPT API key. Looking through the Github repository, you can see that the API key changes regularly. Presumably, this is because providing tgpt is a breach of ChatGPT terms of service.

If tgpt stops working for some reason, updating it with:

tgpt -u

...should get it going again.

Having said that, it's unlikely that tgpt will continue working forever.

In the meantime, enjoy it while it lasts.