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:
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
Related Resources
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.
For additional information on related topics, take a look at the following resources:
- Leverage OpenAI's API in Your Python Projects (Course)
- Use ChatGPT to Learn Python Programming (Tutorial)
- Python for Data Analysis: A Practical Guide (Tutorial)
- Generate Images With DALL·E and the OpenAI API (Tutorial)
- Write Unit Tests for Your Python Code With ChatGPT (Tutorial)
- Document Your Python Code and Projects With ChatGPT (Tutorial)
- How to Integrate ChatGPT's API With Python Projects (Quiz)
- Using Python for Data Analysis (Quiz)
- Generate Images With DALL·E and the OpenAI API (Quiz)
By Martin Breuss • Updated Aug. 28, 2026