Code interpreter

Assistants can solve more complex problems in domains like data analysis, coding and maths.

They use a tool called ‘code interpreter’ - you’ll see a Python code indicator when this is in use. Click the down arrow to expand and see the code used to interpret your instructions.

 

Tips, tricks and troubleshooting

  • If code interpreter stops working for you in your current thread, try creating a new thread.
  • Models usually understand prompts that refer to the code interpreter tool, but the most explicit way to invoke this tool is to ask for "the python tool" in your prompts. For example "analyse the data in the attached table using the python tool and chart the price over time."
  • The AI model is writing code for you to do these operations. It may write incorrect code so double check the outputs.

Things you can do with the code interpreter:

Data Analysis & Visualisation

  • Work with spreadsheets or CSVs — read, clean, filter, and transform data.

  • Run statistics — means, medians, correlations, regressions, etc.

  • Generate charts — line graphs, bar charts, scatter plots, histograms.

  • Summarise small to medium datasets — find patterns, outliers, trends.

Note: large files with many thousands of rows may not be suitable for analysis.

 

Maths, Science, and Engineering

  • Do calculations — from basic arithmetic to advanced algebra/calculus.

  • Solve equations — symbolically or numerically.

  • Run simulations — Monte Carlo, random sampling, modelling.

  • Unit conversions — currencies, measurements, scientific constants.

Text & Document Processing

  • Parse text — extract keywords, detect sentiment, count word frequencies.

  • Convert between formats — CSV ↔ Excel, Markdown ↔ PDF, JSON ↔ XML, etc.

  • Generate files — DOCX, PDF, XLSX, RTF, TXT, Markdown.

  • Summarise or transform documents — reformat, extract sections, split/merge.

Image & Media Handling

  • Analyse images — get dimensions, detect dominant colours, OCR text (if provided as data, this can also be done via the normal AI image handling).

  • Transform images — resize, crop, rotate, convert formats.

  • Generate plots from image data — e.g. histograms of pixel intensity.

Automation & Scripting

  • Batch processing — repeat a process for multiple files or datasets.

  • Web data extraction (from an uploaded HTML file) — extract tables or content from uploaded HTML.

  • API interaction (with provided API output) — parse and process JSON/XML from external systems - if uploaded as a file.

Note: The Code Interpreter cannot access the internet.

Advanced Use Cases

  • Financial modelling — profit/loss forecasts, investment simulations.

  • Scientific data processing — Fourier transforms, statistical testing.

  • Custom algorithms — anything from pathfinding to text classification.

  • Code debugging — test small code snippets and logic.