Skip to main content
HomeTutorialsArtificial Intelligence (AI)

How to Use ChatGPT Code Interpreter

Everything you need to know about OpenAI’s ChatGPT Code Interpreter
Jul 2023  · 9 min read

OpenAI's ChatGPT has taken the world by storm with its remarkable text-generation abilities. Presently, the chatbot continues to captivate users by generating charts, maps, and transforming images into videos, thanks to a newly introduced feature called Code Interpreter. This feature, exclusive to ChatGPT Plus subscribers, was launched by OpenAI on July 6.

This article gives an overview of how you can use ChatGPT code interpreter functionality with the help of a few example use cases.

ChatGPT Plugins

ChatGPT’s Code Interpreter is a plugin. Yes, it’s a plugin. ChatGPT plugins are enhancements that augment what ChatGPT can do for you. For example, the Kayak and Expedia plugins can answer real-time travel questions. These plugins are found in the ChatGPT plugins store.

ChatGPT Plugin Store (only available to ChatGPT plus users)

ChatGPT Plugin Store (only available to ChatGPT plus users)

In fact Code Interpreter is one of the two plugins officially published by OpenAI itself. Plugins are tools designed specifically to help ChatGPT access up-to-date information, run computations, or use third-party services.

The other plugin that OpenAI published before Code Interpreter is “Web browsing”. Currently, the web browsing plugin is unavailable as OpenAI has recently removed it due to security and privacy issues.

What is ChatGPT Code Interpreter?

ChatGPT is a chatbot that responds to questions using a technology known as a large language model (LLM). This technology works by predicting the next word in a sequence to form coherent responses. However, when the code interpreter feature is activated, ChatGPT's capabilities are significantly enhanced.

With the code interpreter enabled, ChatGPT can write and execute computer code to provide answers. This feature, introduced by OpenAI, allows the chatbot to perform tasks it couldn't do before. For instance, it can carry out complex calculations, generate charts based on user-uploaded data, and more, all through the execution of code.

The introduction of the code interpreter is seen by some as a way to reduce inaccuracies, a common issue associated with LLMs. By executing code to find answers, the chatbot can provide more precise and accurate responses, enhancing the overall user experience.

Technically speaking, the ChatGPT model has access to a Python interpreter in a sandbox environment and it can not only write code but also execute it in a Python environment and return the answers. If the code fails (as it does many times), it can also debug the code reading the callback messages and automatically enters the loop to fix the code and make it work.

The code interpreter feature stays active for the whole chat, but there's a time limit to make sure things don't go on for too long. The cool thing is, you can run multiple pieces of code one after the other, and they can work together.

Plus, you can send files to this chat conversation. So, if your code needs to read data from a file, you can send that file over. And when your code is done, you can get the results back. For example, if your code makes a new file, you can download that file and use it however you want. At the moment the limit on input file size is roughly 500 MB.

Here’s a simple example of Code Interpreter from official OpenAI documentation:

Code interpreter plugin performing logic calculations

Code interpreter plugin performing logic calculations

Getting started with Code Interpreter

Getting started is easy but you do need a ChatGPT plus account to access this functionality. Even if you have ChatGPT plus, the functionality is not available to you by default as it is in beta and must be turned on from the settings.

If you have ChatGPT plus, all you need to do is click on settings on left-hand corner and turn on the toggle button for Code Interpreter:

Enabling Code interpreter from Beta features in ChatGPT settings

Enabling Code interpreter from Beta features in ChatGPT settings

Common use-cases of ChatGPT code interpreter

The most common use-case of ChatGPT’s Code Interpreter that came out so far is Analyzing Data. For example, if you ask ChatGPT to find something interesting in your data, it can examine information like your financial records, health stats, or location details and give you some insights. People working in finance have found it useful for tasks like studying stock prices or planning a budget. Researchers are also using this tool to make unique data visualizations. For example this interactive graph of World Population was created by ChatGPT’s code interpreter.

2022 World Population Map

Credits

Even though data analysis is the most common use-case for now. Theoretically, any task that requires logic and computation should be possible for ChatGPT’s code interpreter to achieve. From the initial user studies, OpenAI has identified these areas where the code interpreter is particularly very useful:

  • Solving mathematical problems, both quantitative and qualitative
  • Doing data analysis and visualization
  • Converting files between formats

Examples of using ChatGPT code interpreter

Example 1 - Data Analysis on Toy Dataset

First, let’s try it out with a very simple dataset. This is what the dataset looks like:

Carat table

I will upload the csv file and ask the ChatGPT’s code interpreter to analyze the data through a simple prompt. Before you do that we have to select Code Interpreter from the dropdown towards the top (If you don’t have ChatGPT plus you won’t even see the dropdowns).

Code interpreter option menu

As soon as you select Code Interpreter you will see a plus sign in the message box using which you can use to upload files.

Prompt

Once you input the prompt, the ChatGPT code interpreter starts processing. I can't display the entire output here since it's pretty big, as it includes the process itself, but here are a few insights extracted.

output visualizations

Having worked on this dataset before I can tell this is relevant insight and it’s impressive how fast it churned that out. Here is the story as well that we asked for:

Bulleted insights

This is pretty impressive. However, the dataset is relatively simple with 6,000 rows and 7 columns—pretty clean and straightforward. Let’s try out this example with a dataset that’s more likely for the real world.

Gain access to 60+ ChatGPT prompts for data science tasks in this ChatGPT Cheat Sheet for Data Science on DataCamp.

Example 2 - Data Insights on a more complex dataset

In this example, the dataset is of Canadian CPI inflation from StatsCan. This is what the dataset looks like—it is raw, has duplicates, missing values, a lot of encoded information, and geographical coding.

Inflation data

Let’s see what kind of insights we can get from this dataset and a simple prompt.

prompt2

1. Developing The Schema

dataset schema

2. Data Cleaning

dataset analysis

3. Data Visualization

4. Extracting Insights

Insight extraction

This is impressive. It has done a decent job in understanding the data, cleaning the data, thinking of the relevant / appropriate visualization, then writing Python code to generate that visualization, and finally writing insights around it. It’s not perfect, but it’s very promising compared to all the automated insight tools we have seen in the past.

Do you want to learn how to use ChatGPT in a real-life end-to-end data science project? Check out this Guide to Using ChatGPT For Data Science Projects on DataCamp now.

Example 3 - Image Animation using ChatGPT

What you can also do is upload an image and make ChatGPT edit the image as well. For example, I will upload an image of an apple and ask it to animate it.

animation prompt

It may ask you some clarifying questions but will eventually write a code to animate the image as per your request.

animation working process

output gif

Animated output (gif file) downloaded from ChatGPT's Code Interpreter

Conclusion

OpenAI's ChatGPT Code Interpreter is a groundbreaking feature that expands the capabilities of the AI-driven chatbot. By enabling the code interpreter, ChatGPT gains the ability to write and execute computer code, allowing it to perform complex tasks such as calculations, data analysis, and generating visualizations.

This feature not only enhances the accuracy and precision of ChatGPT's responses but also provides users with a more interactive and dynamic experience. From analyzing data to solving mathematical problems, the code interpreter opens up a wide range of possibilities for users, making ChatGPT a powerful tool for various applications.

If you want to Level up your workflows and transform your business with ChatGPT! Join an introductory level Introduction to ChatGPT course on DataCamp now and master the power of generative AI. Unlock endless possibilities and revolutionize your work today! Enroll here.

Introduction to ChatGPT Course

Get Started with ChatGPT

Start Now
Topics
Related

tutorial

How to Use ChatGPT for Sales

Discover the essential prompts and tips for getting the most out of ChatGPT for sales
Matt Crabtree's photo

Matt Crabtree

10 min

tutorial

A Beginner's Guide to ChatGPT Prompt Engineering

Discover how to get ChatGPT to give you the outputs you want by giving it the inputs it needs.
Matt Crabtree's photo

Matt Crabtree

6 min

tutorial

How to Use ChatGPT Custom Instructions

Explore ChatGPT Custom Instructions feature. Learn how to fine-tune responses, explore use cases for teachers, entrepreneurs, and content creators.
Moez Ali's photo

Moez Ali

7 min

tutorial

A Beginner's Guide to Using the ChatGPT API

This guide walks you through the basics of the ChatGPT API, demonstrating its potential in natural language processing and AI-driven communication.
Moez Ali's photo

Moez Ali

11 min

tutorial

Introduction to ChatGPT Next Web (NextChat)

Learn everything about a versatile open-source application that uses OpenAI and Google AI APIs to provide you with a better user experience. It's available on desktop and browser and can even be privately deployed.
Abid Ali Awan's photo

Abid Ali Awan

7 min

code-along

Using ChatGPT Code Interpreter for Data Science

In this live training, we use ChatGPT Code Interpreter to perform a data analysis workflow on an Airbnb dataset.
Adel Nehme's photo

Adel Nehme

See MoreSee More