Skip to main content
Anthropic’s code interpreter runs Python in a sandboxed environment. State persists across turns, and generated files are automatically downloaded.

Enable Code Interpreter

Multi-Turn Execution

State persists across conversation turns:

Generated Files

Files created during code execution are attached as DataPart instances:
Anthropic’s code interpreter supports common Python libraries including matplotlib for plotting, pandas for data manipulation, and reportlab for PDF generation.

Streaming Code Events

Code execution events stream through metadata['code_interpreter']:

Example