Skip to content

OpenAI Code Interpreter

OpenAI Code Interpreter is a built-in tool that lets OpenAI models write and run Python in a sandboxed container to analyze data, solve math problems, and work with uploaded files.

The model drives the sandbox itself. It writes code, reads the output, and rewrites the code when a run fails, so you get a finished answer instead of a snippet to run yourself. It accepts more than thirty file formats, from CSV and JSON to PDFs and images, and it can return generated files, including charts. Step through a session below to see that loop in action:

Interactive diagram — enable JavaScript to view.

In ChatGPT, Code Interpreter powers file uploads and data analysis, a feature also known as Advanced Data Analysis. Through the API, you add a code_interpreter tool to a Responses request, and the OpenAI Agents SDK for Python wraps the same tool as CodeInterpreterTool for agents you build yourself.

Containers default to 1 GB of memory and expire after twenty minutes of inactivity. A session costs $0.03 at that tier, and the price scales with memory up to $1.92 at the 64 GB tier.

Competing model providers ship equivalent hosted sandboxes: Anthropic’s code execution tool runs Python and Bash in a container for Claude, and the Gemini API exposes the same capability as code execution.

Official website: developers.openai.com

How to Integrate ChatGPT's API With Python Projects

Tutorial

How to Integrate ChatGPT's API With Python Projects

Learn how to use the ChatGPT Python API with the openai library to build AI-powered features in your Python applications.

intermediate ai api

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated Aug. 28, 2026