How to Use ChatGPT Code Interpreter for Free

Recently, OpenAI releasedCode Interpreter in ChatGPTfor all paying users. However, it costs $20 per month, which is not affordable for everyone. So if you want to use ChatGPT Code Interpreter for free, this tutorial is for you. A developer who goes by the name ofShroominichas developed an open-source implementation of ChatGPT’s Code Interpreter. It allows you to perform dataset analysis and visualize data similar to ChatGPT. On that note, let’s go ahead and learn how to use Code Interpreter for free.

Things to Keep in Mind Before You Proceed Further

  1. We are using the free and open-sourceCode Interpreter API projecton GitHub (visit). It uses CodeBoxes, OpenAI’s API, LangChain Agents, and multiple Python packages to behave like ChatGPT’s Code Interpreter.

  2. For asmall dataset, it works pretty well and without any charge. However, when you throw a large dataset for analysis, OpenAI’s rate limit for free users prevents the operation. So if you plan to use it for large amounts of data, consider adding a payment method to your OpenAI account.

  3. If you have access to the GPT-4 API, the project works well. However, I have customized the code to make it compatible with the GPT-3.5-turbo model as well.

Step 1: Set Up Code Interpreter API

Step 1: Set Up Code Interpreter API

  1. First, you need toinstall Python and Pipon your computer, for which you can follow our linked tutorial. Make sure to add python.exe to PATH during installation.

  2. Once you have installed Python along with Pip, open the Terminal and run the below commands to check if they areset up properly. The commands should return output with their version numbers.

  3. Now, run the below command toinstall the Code Interpreter API.

  4. After that, go ahead andget an API keyfrom OpenAI’swebsite. Click on “Create new secret key” and copy the key.

Step 2: Run ChatGPT Code Interpreter for Free

Step 2: Run ChatGPT Code Interpreter for Free

  1. Once you do that, it’s time to run the Code Interpreter API for free.

  2. Open acode editor like Sublime TextorNotepad++(Download).

  3. Now, copy the below code andpaste itinto the code editor. The code is from theGitHubpage of the Code Interpreter API, but I have made some changes to avoid some errors.

  4. I have highlighted the code in red where some changes are needed. First,paste the OpenAI API keyin the second line.

  5. After that, if you have access to the GPT-4 API, you can define the “gpt-4” model in the ninth line. Finally, in the 14th line, you can enter your query and define what you want to create.

  6. Now, save the file as “chart.py” to theDesktop. Make sure to add.pyextension at the end.

  7. Now, go ahead and open Terminal and run the below commands one by one. The first command will move to the Desktop location and the second one will execute the “chart.py” file using Python.

  8. Give it a few seconds and Code Interpreter API willgenerate the chartfor you.

  9. It uses a number of services in the background to achieve this result, including LangChain Agents, Yahoo Finance data from the internet, Matplotlib to plot the graph, and more. You can add the below line to the code tosee everything happeningin the background.

  10. Now onwards, you can simplychange the queryin the code and execute the “chart.py” file again to generate new charts.

Step 3: Perform Data Analysis Using Code Interpreter API

  1. You can also use your local data to perform data analysis for free. For that,create a folder named “analysis”on the Desktop.

  2. Now, move your dataset to the “analysis” folder. The dataset can be in CSV, XSL, or XSLX format. For example, we are going to use a “globaltemperature.csv” file inside the “analysis” folder.

  3. Next, open the code editor andpaste the below code.

  4. Here, you first need topaste the OpenAI API key.

  5. Now, change “globaltemperature.csv” with your own dataset name. By the way, you can also change the model and user query depending on what you want from the data.

  6. Save it as “data.py”inside the “analysis” folderon your Desktop.

  7. Launch theTerminaland run the file in a similar fashion.

  8. You will nowget the chart based on your local dataset. And this is how you can use the Code Interpreter API for dataset analysis without paying any fee.

Arjun Sha

Passionate about Windows, ChromeOS, Android, security and privacy issues. Have a penchant to solve everyday computing problems.

Add new comment

Name

Email ID

Δ

01

02

03

04

05