Guide 01 · template: code-interpreter
Build an AI code interpreter for data analysis
Give your LLM a Python runtime it can actually execute in: upload a CSV, let the model write pandas, run it safely, and pull the chart back out. This is the classic "code interpreter API" loop behind ChatGPT-style data analysis.
1
Create the sandbox
The code-interpreter template ships Python 3.11 with pandas, numpy, and matplotlib preinstalled.
from pilldrops import Sandbox sb = Sandbox.create(template="code-interpreter", timeout=1800)
2
Upload the user's data
sb.upload("./sales.csv", "/data/sales.csv")
3
Run the code your model wrote
Pass the LLM's generated script straight to run. Whatever happens, it happens inside the microVM — not on your servers.
code = llm("write pandas code that plots monthly revenue from /data/sales.csv to /out/chart.png") sb.run(f"python -c '{code}'", timeout=120)
4
Bring the artifacts home, then clean up
sb.download("/out", "./results") # chart.png, tables, … sb.kill()