We earn commission when you buy through affiliate links.

This does not influence our reviews or recommendations.Learn more.

ChatGPT is a large language model developed by OpenAI.

Screenshot of Google Colab notebook

Integrating ChatGPT with Google Colab will help you reap all the above benefits in the Google Colab environment.

This post describes how to get started with ChatGPT with Google Colab.

It is free to use, at least at the time of writing.

Screenshot showing ChatGPT button

You debug, refactor, and generate code faster.

It can explain code written in a notebook if theres something you do not understand.

It is available for most popular browsers.

Screenshoot showing the ChatGPT prompt interface inside Google Colab

I use Google Chrome, so that I will install it from theChrome web store.

you might also install it from theMozilla Web Store.

The extension is free and open-source.

Screenshot showing the Refactor task select and the associated prompt that is generated

The code is available onGitHub.

When you press the button, this interface will open up at the bottom of the cell.

Using this interface, you’re able to select a task you want ChatGPT to perform.

Screenshow showing the output of sending the request to chatgpt

Tasks you’ve got the option to select include Refactoring Code, Explaining Code, and Summarising Code.

Selecting a task will generate a prompt to tell ChatGPT what to do.

you’re free to edit the prompt if you want to or bang out a new one altogether.

When your prompt is ready, press the Submit button to send it to ChatGPT.

Next to the Submit button, there is a checkbox for including the code.

When this checkbox is checked, the code in the cell will be sent along with the prompt.

ChatGPT now works natively withinGoogle Colabwithout moving between different tabs.

It even explained what it did.

That is, it isnt always right.

It makes mistakes, hallucinates, or produces erroneous code using functions that dont exist.

Generating test cases Writing tests is boring, yet they are so essential.

Getting explanations for code At times, another developer will write cryptic code that you cant understand.

ChatGPT will help explain what the code does.

you could even ask questions about frameworks and libraries, saving you a trip to Google and Stack Overflow.

You may also want to read abouthow to use ChatGPT with Siri.