Python scripting?

Let’s have ChatGPT in Python!

Not Davinci, we need ChatGPT itself.

Danyal Jamil
2 min readJan 9


So, I had to work recently to integrate ChatGPT into a Python app, and to not re-invent the wheel, as any developer would do, I started searching about it on Medium, and other websites. So, after spending a lot of time, all I could really find was implementations of The Davinci 003 and none of them were of ChatGPT itself. So, as this was a requirement, I knew I had to get this done one way or another.

Photo by Peter Forster on Unsplash

Later on, I came across this great module which was written in Python with ChatGPT’s integration. Although the GitHub repository is not really well written but the code is working and that is enough for our project. It took me a lot of time to figure out how exactly the code work and how I wanted to integrate it into my script.

Now, the code is not perfect and it has to run a nightly background window with it to simulate some kind of online post/get request mechanism. The best feeling?

Uploaded by the Publisher

And from here, the integration went smooth.

Let me walk you through the code:

The module name is chatgpt_wrapper. You can install it by running:

pip install git+

Next thing is to install a helper background windows, such as firefox, to do this, run:

playwright install firefox

And lastly, run:

chatgpt install

This should open up a browser window, where you have to provide login credentials. Once done, access it in the cmd by running:


Now, you can use it in Python by using the following code:

from chatgpt_wrapper import ChatGPT

BOT = ChatGPT()

response = BOT.ask("Hi!")
print("Bot's response: {}".format(response))

And there you have it.

Let me know what applications you have in mind to create using this? I might write the follow up blog on one application automation I made.



Danyal Jamil

Machine Learning Enthusiast | Student