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


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.


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.


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


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

The Top AI Certifications for 2024: A Guide to Advancing Your Tech Career

Explore the best AI certifications for 2024 with our comprehensive guide. Understand the difference between AI certifications and certificates, identify top courses for various career paths, and learn how to choose the right program.
Matt Crabtree's photo

Matt Crabtree

10 min

Announcing the "Become an AI Developer" Code-Along Series

Get started with Generative AI in this brand new code-along series. Free for a limited time.
DataCamp Team's photo

DataCamp Team

4 min

ChatGPT 1 Year

ChatGPT & Generative AI: The Year in Review – Top 17 Moments

Explore the pivotal year for ChatGPT and generative AI with our comprehensive review of 2023's top 17 AI milestones.
Moez Ali's photo

Moez Ali

17 min

Data & AI for Good, with Marga Hoek, Founder & CEO, Business for Good

Marga and Adel explore the fourth industrial revolution, how data and AI enable real-time information sharing, use cases of tech for good initiatives, how collaboration can bridge the gap in investment for sustainable business ventures and a lot more. 
Adel Nehme's photo

Adel Nehme

45 min

How to Make Custom ChatGPT Models: 5 Easy Steps to Personalized GPTs

Check out these five simple steps to unlock the full potential of ChatGPT with your own custom GPTs.
Moez Ali's photo

Moez Ali

9 min

Fine-tuning Stable Diffusion XL with DreamBooth and LoRA

Learn how to successfully fine-tune Stable Diffusion XL on personal photos using Hugging Face AutoTrain Advance, DreamBooth, and LoRA for customized, high-quality image generation.
Abid Ali Awan's photo

Abid Ali Awan

14 min

See MoreSee More