Back to blog
ChatGPT12 min read

Prompting the Code Interpreter (Python Inside ChatGPT)

ChatGPT code interpreter prompts only work once you know the sandbox: no internet access, a 20-minute idle limit, and file rules most guides skip.

NH
Nafiul Hasan
Founder, Prompt Architects

TL;DR: OpenAI no longer calls this feature Code Interpreter inside ChatGPT itself. It's "Data Analysis" now, though the API tool and the model still answer to the older name. The sandbox has no internet access, containers expire after 20 minutes idle, and file limits are specific published numbers. Ask for "the python tool" by name when you need code to actually run.

Is It Still Called the Code Interpreter?

Not inside the product you are typing into. It has a different name there now, even though the old one still shows up elsewhere on the same domain.

OpenAI's Capabilities Overview page, the closest thing it publishes to a feature index for ChatGPT, lists this capability under a section header reading simply "Data Analysis", saying "ChatGPT can run code in a secure environment to analyze and visualize data from spreadsheets, CSVs, and other structured formats" (OpenAI, ChatGPT Capabilities Overview, read September 3, 2026). The dedicated help page carries the matching modern name, "Data analysis with ChatGPT". Neither page uses the phrase "Code Interpreter" once.

Go one level down, though, and the old name is still very much alive. OpenAI's own File Uploads FAQ, last updated within weeks of this writing, states plainly that "Files uploaded to Advanced Data Analysis are deleted within a duration that varies based on your plan" (OpenAI, File Uploads FAQ, read September 3, 2026), using a name OpenAI is widely reported to have retired back in 2023. And if you are building against the API rather than typing into ChatGPT directly, the tool is still, literally, named Code Interpreter: "The Code Interpreter tool allows models to write and run Python code in a sandboxed environment to solve complex problems in domains like data analysis, coding, and math" (OpenAI, Code Interpreter guide, read September 3, 2026).

So three names for the same underlying capability sit live on OpenAI's own domain at once: Code Interpreter (the API tool's actual name), Advanced Data Analysis (the internal label that survives in the file-retention copy), and Data Analysis (what the ChatGPT product calls it today). None of this is a documentation error worth reporting to anyone. It is just what a feature looks like after two renames, when old copy never gets fully swept.

There is a genuinely useful detail buried in the API docs that answers the question most people actually have: what to type. OpenAI states it directly: 'While we call this tool Code Interpreter, the model knows it as the "python tool". Models usually understand prompts that refer to the code interpreter tool, however, the most explicit way to invoke this tool is to ask for "the python tool" in your prompts' (OpenAI, Code Interpreter guide, read September 3, 2026). If you want to remove any ambiguity about whether the model is reasoning about code versus actually executing it, asking it to use the python tool is the phrasing that carries that meaning, more reliably than asking it to use Code Interpreter.

What Can the Sandbox Actually Reach?

Nothing outside itself. No internet, no live APIs, no fresh data. Only whatever you hand it directly.

OpenAI states the constraint in one sentence, in the current Data Analysis help article: "The Python environment used for data analysis cannot make external web requests or API calls" (OpenAI, Data analysis with ChatGPT, read September 3, 2026). That single line rules out an entire category of prompt people keep trying: pull today's exchange rate and convert this column, check the latest release version, scrape this URL and summarize it. None of that reaches the sandbox. If the analysis depends on something outside the conversation, you upload it, paste it, or you do not get it.

What the sandbox does have is a real, persistent compute environment for the length of the session. OpenAI describes it as a "stateful Jupyter notebook environment" whose "environment can use files made available to the session and can display pandas DataFrames as interactive tables when that format is useful" (OpenAI, Data analysis with ChatGPT, read September 3, 2026). Stateful matters here: a variable or a cleaned dataframe you create in one exchange is still sitting there in the next, inside the same conversation, right up until the session resets or expires.

How Long Does a Session Actually Last?

On the API side, OpenAI publishes an exact number: 20 minutes of inactivity. On the ChatGPT product side, there is no equivalent published figure, and treating whatever still appears to be working as your only signal is the honest position.

The API's container object, the sandboxed VM the Code Interpreter tool actually runs in, has a documented expiry: "A container expires if it is not used for 20 minutes. When this happens, using the container in v1/responses will fail. You'll still be able to see a snapshot of the container's metadata at its expiry, but all data associated with the container will be discarded from our systems and not recoverable. You should download any files you may need from the container while it is active" (OpenAI, Code Interpreter guide, read September 3, 2026). OpenAI's own advice is blunt about what that means in practice: "We highly recommend you treat containers as ephemeral and store all data related to the use of this tool on your own systems" (same page). Anything the code generated, a cleaned CSV, a chart, a fitted model, that you have not downloaded is gone the moment that clock runs out.

Containers also come in memory tiers, fixed for the container's entire life: "You can choose from 1g (default), 4g, 16g, or 64g" and "The selected memory_limit applies for the entire life of that container, whether it was created automatically or via the containers API" (OpenAI, Code Interpreter guide, read September 3, 2026). Higher tiers cost more, billed at Code Interpreter's own built-in-tool rates. If you are working through the API and a large file keeps failing partway through, the default 1 GB tier, not your prompt, is very often the real ceiling.

None of this is published with the same precision for chat.openai.com itself. OpenAI's consumer help pages describe the Data Analysis feature's behavior without giving a specific idle-timeout number for a ChatGPT conversation. Treat that as genuinely unverified rather than assuming the API's 20 minutes carries over automatically: a chat session and an API container are documented as separate objects, and only one of them comes with a number attached. The practical habit holds either way. Download anything the sandbox produced before you close the tab, and do not assume a chart or a generated file will still be there when you come back.

Which Files Can You Actually Hand It?

Spreadsheets, PDFs, and a handful of plain text and data formats inside ChatGPT itself. A much longer list of code and archive formats if you are working through the API. Every one of those comes with a real size number, not a vague ceiling.

The ChatGPT product's own file support is intentionally narrow. OpenAI's help center lists what it supports for data analysis: "Spreadsheets, such as .xls, .xlsx, and .csv files", "PDFs", and "Text and data files, such as .json, .xml, .yaml, .txt, and .md files" (OpenAI, Data analysis with ChatGPT, read September 3, 2026), adding the caveat that "Available file types can vary by model, plan, workspace settings, and account capabilities."

The API's Code Interpreter tool documents a longer, more code-shaped list, because it also has to run whatever source code you hand it directly:

FormatMIME type
.pytext/x-python
.csvtext/csv
.jsonapplication/json
.xlsxapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.pdfapplication/pdf
.docxapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
.png / .jpgimage/png / image/jpeg
.zip / .tarapplication/zip / application/x-tar

(Full list: OpenAI, Code Interpreter guide, read September 3, 2026.)

Sizes are the part most people skip past. OpenAI's File Uploads FAQ gives specific numbers rather than vague guidance: "All files uploaded to a GPT or a ChatGPT conversation have a hard limit of 512MB per file", and "All text and document files uploaded to a GPT or to a ChatGPT conversation are capped at 2M tokens per file. This limitation does not apply to spreadsheets" (OpenAI, File Uploads FAQ, read September 3, 2026). Spreadsheets get their own ceiling instead: "For CSV files or spreadsheets, the file size cannot exceed approximately 50MB, depending on the size of each row", while images are capped separately, "For images, there's a limit of 20MB per image" (same page).

There are usage caps layered on top of the per-file limits, and they bite hardest on the free tier: "Free users are limited to 3 file uploads per day", while paid accounts share a rolling allowance of "up to 80 files every 3 hours" (same page). If an upload silently refuses, or a large CSV analysis quietly stalls, check the cap before assuming the prompt itself is wrong.

When Does Running Code Actually Beat Just Asking It to Reason?

Whenever the answer depends on an exact number, a real transformation of real data, or output the model would otherwise have to fake from pattern-matching alone.

The clearest case is arithmetic and dates, and we have already covered exactly why the model gets those wrong on its own in a separate piece on tokenization and missing clocks. The short version: numbers arrive pre-chopped into small chunks and there is no calendar built in, so anything with real financial or scheduling consequences should go through code, not prose.

The same logic applies anywhere the model would otherwise have to hold an entire dataset in its head, with no code checking the work. Merging two files on a shared identifier, deduplicating rows, computing a rolling average across a year of daily values: these are places where a model reasoning in prose produces a plausible-sounding paragraph that quietly drops rows or approximates. Actual code either runs on the actual data or throws a visible error. It cannot bluff the same way a sentence can.

A prompt that forces the tool, rather than hoping the model reaches for it on its own:

Use the python tool for every calculation in this task. Do not
compute or estimate anything yourself. Show the code you ran and
its raw output before you write any interpretation.

And one that forces the result into a shape you can actually paste somewhere, which pairs with prompting for tables and structured data:

Run this with the python tool. Return the result as a markdown
table with these exact columns: metric, value, formula_used. Do
not add commentary below the table.

Why Did My Chart Come Out as a Flat Image Instead of Something I Can Click?

Because only four chart types are documented as interactive, and everything else is a static image by default.

OpenAI states this plainly: "Interactive charts are supported for bar, line, pie, and scatter charts. Other chart types may be returned as static images" (OpenAI, Data analysis with ChatGPT, read September 3, 2026). If you ask for a histogram, a box plot, or a heat map and get back a PNG-style image with no way to hover or filter, that is not a bug. It is the documented default outside those four types. Say explicitly which of the four interactive types you want if that matters, and do not be surprised when a more exotic chart type comes back flat.

Can It Actually Read a Scanned PDF or a Screenshot of a Spreadsheet?

Not reliably, and OpenAI says so itself rather than leaving you to find out the hard way.

The FAQ on OpenAI's own Data Analysis help page answers this directly: "ChatGPT may not reliably extract exact values from image-based tables, scanned files, or files with complex visual layouts. When exact values matter, upload a spreadsheet or text-based file instead" (OpenAI, Data analysis with ChatGPT, read September 3, 2026). A screenshot of a spreadsheet is an image to this pipeline, not a table, no matter how clean it looks to you. If a number needs to be right, the source needs to be a real spreadsheet or a text file, not a photo of one.

Turning a One-Off Answer Into a Repeatable Workflow

Everything above is about the tool itself: what it can reach, how long it lasts, and what breaks it. None of it tells you how to run an actual analysis end to end, from a real question to an answer you would defend to your own boss. That is a different set of habits, and we cover it separately in how to prompt ChatGPT for data analysis. This piece has been about the sandbox; that one is about the job you use it for.

If you are coming at this from a development angle instead, our developer prompt collection and advanced prompting past the basics cover the surrounding habits that make any of this reliable in the first place.

Prompt Architects does not run Python for you. It is a prompt generator and library, not a sandbox. What it saves is retyping the same tool-forcing, show-your-work instructions from memory every time you open a new chat.

Free Chrome Extension

Stop rewriting prompts. Start shipping.

Works with ChatGPT, Claude, Gemini, Grok, Midjourney, Ideogram, Veo3 & Kling. 4.8★ on the Chrome Web Store.

Create An Account

Frequently asked questions

Free Chrome Extension

Stop rewriting prompts. Start shipping.

Works with ChatGPT, Claude, Gemini, Grok, Midjourney, Ideogram, Veo3 & Kling. 4.8★ on the Chrome Web Store.

Create An Account