ModelRefs / Code Interpreter — AI Glossary

Code Interpreter — AI Glossary

A sandboxed execution environment that lets an LLM write and run code, capturing stdout/stderr and returning results. Sandboxing is critical for security.

Overview

Code interpreters enable data analysis, math verification, file manipulation, and chart generation by running LLM-generated Python (or other languages). OpenAI's Advanced Data Analysis, Anthropic's tool use, and E2B are common implementations. Sandboxing is critical for security.

Reference details

Topicagents
Last reviewed2026-06-24

Example: Why it beats the model doing the sum

Asked to compute a median over 4,000 rows, a model estimates and is confidently wrong. Given execution, it writes three lines of pandas, runs them, and reports the actual value. The model's job changes from computing the answer to writing code that computes it — which it is far better at.

Commonly confused with

The sandbox is the feature, not an implementation detail. Code interpretation means running model-generated code, so isolation, resource limits and network policy are the product. An unsandboxed interpreter is remote code execution with extra steps.

When to use it

Reach for it when:

  • Data analysis, transformation or verifiable computation
  • Charts and file manipulation where the artifact is the output
  • Checking a model's arithmetic rather than trusting it

Reach for something else when:

  • The sandbox has network access it does not need
  • Untrusted user input reaches the generated code unfiltered
  • A fixed query or script would do the job deterministically

Referenced by

This term is used by the following ModelRefs references:

Continue your research

Use these connected ModelRefs sections to compare alternatives, inspect implementation paths, and review the evidence and governance boundaries relevant to Code Interpreter — AI Glossary.

Frequently asked questions

What is Code Interpreter?

A sandboxed execution environment that lets an LLM write and run code, capturing stdout/stderr and returning results.

What concepts are related to Code Interpreter?

Closely related concepts include tool use, agent, function calling.