Skip to main content
You want an assistant that takes a user’s spreadsheet or log file, writes analysis code for it, runs that code, and returns tables or files, without that code ever running on your servers. Pieces. The python template has Python 3.12 with numpy, pandas, requests and httpx in /opt/venv, which is on the PATH. Files moves data in and out.
1

Upload, run, read back

analyze_csv.py
If the code fails, commands.run raises with the exit code and stderr. Hand that back to the model and let it try again in the same sandbox: the file is still there.
2

Get files back

Read text with files.read, and binary output such as a chart image with files.read(path, format="bytes"). Extra packages install with pip install in the sandbox on a plan with public egress, or ship in your own template.
3

Keep state between questions

For a chat that asks follow-up questions about the same data, keep the sandbox and its loaded files between turns, and pause it when idle. For a stateful Python kernel (variables kept between calls), the code-interpreter template runs E2B’s code-interpreter server.
Untrusted output. The analysis code is your model’s, so treat it like any code an agent wrote: a short timeout, and egress off unless it needs it. Runnable example: examples/python/analyze_csv.py in the public SDK repository. It prints what happens at each step.