Code interpreter

A code interpreter is a tool that lets an AI model write code, run it in an isolated sandbox and read the results, so it can analyse data, do exact calculations, make charts and convert files.

Language models are unreliable at exact arithmetic and cannot open a spreadsheet just by reading about it. A code interpreter fixes this by dividing the work. The model writes a short program, usually in Python; the tool runs it in an isolated container; and the output, whether numbers, an error message or a new file, goes back to the model. If the code fails, the model can read the error, fix it and run it again.

OpenAI introduced Code Interpreter as a ChatGPT plugin on March 23, 2023. It gave the model a Python interpreter in a sandboxed, firewalled environment with some temporary disk space, a session lasting as long as the chat, no access to the internet and limits on resources. Users could upload files and download the results, and OpenAI suggested uses such as solving maths problems, analysing and charting data and converting files between formats.

Code execution is now a standard built-in tool in model APIs. As of December 2026, OpenAI's Code Interpreter tool runs in containers with memory sizes from 1 GB to 64 GB, and a container that sits unused for 20 minutes expires along with anything held in memory. Anthropic's code execution tool runs Python and Bash in a container with 5 GiB of memory, one CPU and no internet access; containers expire 30 days after creation, and each organisation gets 1,550 free hours a month, then pays $0.05 per container hour.

A typical use: upload a file of 50,000 sales records and ask for monthly totals by region with a chart. The model writes code to load and group the data, runs it, checks the output and returns the chart. The figures come from executed code rather than the model's guesswork, which makes them far more reliable, but only as right as the code. A wrong column or a bad filter produces a wrong answer that looks just as authoritative, so the code is worth reading.

The sandbox matters for security. Model-written code can be buggy, or malicious if the model has been manipulated by prompt injection, so it runs cut off from the network and from other systems. Without internet access the container also cannot install new packages, so only the libraries already installed are available. Uploaded data passes to the provider: Anthropic, for example, keeps container data for up to 30 days, which matters for sensitive files.

Common questions

What is ChatGPT's code interpreter?

It is the feature that lets ChatGPT write and run Python code in a sandbox to analyse uploaded files, do calculations and produce charts or converted files. OpenAI first released it as a plugin in March 2023, and the same capability is available to developers as a built-in API tool.

Can a code interpreter access the internet?

Usually not. OpenAI's original Code Interpreter blocked external internet access, and Anthropic's code execution tool has networking disabled entirely. This stops code from sending data out or downloading software, but it also means only pre-installed libraries can be used.

Is it safe to upload sensitive data to a code interpreter?

The code runs in an isolated sandbox, but the files are still sent to and stored by the provider for a time; Anthropic, for example, retains container data for up to 30 days. Check the provider's data retention terms and your own policies before uploading confidential material.

Why use a code interpreter instead of asking the model to calculate?

Models predict text and can get arithmetic or data handling wrong, especially with large files. Running code produces exact results from the actual data, and the code itself can be inspected to see how an answer was reached.

Finding more

Search for "code interpreter tool", "code execution tool" or "LLM sandbox" with the name of the provider you use. Provider documentation is the authority on limits, pricing, retention and available libraries, all of which change over time. For security questions, look to guidance on sandboxing and prompt injection from security researchers and standards bodies.

  • ChatGPT pluginsOfficialOpenAI's March 2023 post introducing the Code Interpreter plugin and its sandbox design.
  • Code InterpreterOfficialOpenAI's API guide to containers, memory sizes, files and expiry.
  • Code execution toolOfficialAnthropic's documentation of its sandbox, resource limits, networking, retention and pricing.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.