Getting Started with ChatGPT Code Interpreter

In this guide, we'll discuss ChatGPT's latest plugin: Code Interpreter. The plugin combines the power of LLMs with the ability to write and execute Python.

9 months ago   •   5 min read

By MLQ

The moment all ChatGPT users have been waiting for (and data analysts have been fearing) has arrived: Code Interpreter has been rolled out to all Plus users.

In all seriousness, this plugin is a major upgrade to ChatGPT and may very well change Python development (and soon other coding languages) in a big way.

As OpenAI continues to bring AI and machine learning to the masses, Code Interpreter is a perfect example of how they're bringing ML models into practical tools for everyday use.

As we'll discuss below, Code Interpreter lets users write and execute Python code all with natural language from within ChatGPT.

What is Code Interpreter?

Code Interpreter is one of two ChatGPT Plugins that OpenAI has decided to build in-house—the other being Browsing. This means they know how critical it is to the ChatGPT ecosystem and want to get it right.

In what many are calling "GPT 4.5", Code Interpreter is:

...an experimental ChatGPT model that can use Python, handle uploads and downloads.

As OpenAI writes:

We provide our models with a working Python interpreter in a sandboxed, firewalled execution environment, along with some ephemeral disk space. Code run by our interpreter plugin is evaluated in a persistent session that is alive for the duration of a chat conversation (with an upper-bound timeout) and subsequent calls can build on top of each other.

In other words, Code Interpreter isn't just running pre-set Python scripts, it's fully interactive and allows users to write, debug, and execute code all with natural language.

The plugin's code execution is also stateful, meaning variables and functions defined in one message can be referenced and reused in subsequent messages. This feature allows you to incrementally build complex code structures, much like you would in an actual Python coding session.

While it doesn't have internet access to maintain security, it does come loaded with several pre-installed Python libraries like NumPy, Pandas, Matplotlib, and sci-kit learn, providing a suite of tools that enable you perform data analysis, visualization, and many other tasks.

How to install Code Interpreter

At the time of writing Code Interpreter is only available for ChatGPT Plus users, but having an always on-demand data analyst for $20/month seems worth it to me.

To enable Code Interpreter, simply follow these steps:

  • Step 1: Click the "..." next to your profile and click "Settings"
  • Step 2: Within settings click on "Beta features" and enable Code Interpreter
  • Step 3: Change from the default GPT-3.5 model to GPT-4 and enable Code Interpreter.

Now that we've got it enabled, let's look a few practical applications that others have posted posted on Twitter, and then we'll walk through a more detailed example of performing data analysis of AI startups using Code Interpreter.

Applications of Code Interpeter

While only being out for 10 days at the time of writing, there have already been a number of examples shared by others. Here are a few of the most interesting applications so far:

Rewriting code

As Santiago writes after rewriting 1000+ lines of code...

It's the best model I've seen by a long shot.

Turning images into video

Here's the prompt Chase Lean used to turn a panoramic image into video:

"This image is a panoramic shot. Help me turn it into a video with aspect ratio 3:2, with the image filling the entire video (so the sides are cut off).  The video should be centered in the middle of the image.

Then, pan the video smoothly (with no sudden jumps) as follows:

Start: Center --> Right --> Center --> Left --> Center: End

Use the imageio library to help you. Save the frames directly to a video file instead of into a list. Use a frame step of 8 pixels. If necessary, crop the edges of the image so that the size of the image is divisible by the frame step." draggable="true"."

Data analysis

In this example, Ethan Mollic creates a dataset with an r-squared of 0.2, and as he writes it "relentlessly try to solve a problem and overcome obstacles".

Data visualization

In another example form Ethan Mollic, he created an interactive 3D visisaulization that highlights "the Song of the SUmmer' based on the Billboard Hot 100...wow.

These are just a few examples, although I imagine these example will only pick up speed as more people start experimenting with it.

Summary: Code Interpreter

Code Interpreter is another example of how OpenAI's has been pushing the boundaries of practical ML. By combining the capabilities of an IDE with one of the most powerful language models, Code Interpreter will likely become an invaluable resource for programmers and non-programmers alike.

Spread the word

Keep reading