Mlejnsky introduces an Artifacts-style app: a chat interface paired with a preview, where Claude can generate code and run it. The workshop uses Python and E2B’s Linux sandboxes, with plans to demonstrate other runtimes and languages.
How to add secure code interpreting in your AI app
Speaker
Vasek Mlejnsky, E2B co-founder, leads an AI Engineer workshop on adding secure Python code execution to an AI app using E2B sandboxes and the Vercel AI SDK.
The starter app uses Next.js and the Vercel AI SDK to stream messages to and from Anthropic’s Sonnet 3.5. Mlejnsky then adds a `runPython` tool, giving the model a code string and descriptive fields to guide its use.
The tool calls E2B’s Code Interpreter SDK to execute generated Python inside a sandboxed VM. The app searches sandbox metadata for a matching user ID and reconnects to that sandbox, preserving notebook state between requests; otherwise, it creates a new one. Mlejnsky says sandboxes start in roughly 800 to 900 milliseconds.
Execution results include standard output, error output, runtime errors with tracebacks, and cell results such as charts, images, PDFs, and HTML. The app streams tool status to the frontend and renders a returned PNG in a side panel. Mlejnsky notes that interactive charts and richer data views would require additional frontend work.
In the Q&A, Mlejnsky describes Firecracker VMs and the Jailer as the foundation for isolating untrusted code, with a separate VM for each user session. He says sandbox contents are destroyed when a sandbox closes, and custom environments can be built from Ubuntu-based Dockerfiles that E2B converts into VM filesystems.
Takeaways
- Give generated code its own isolated runtime instead of executing it on your app server.
- Use a stable user or session ID to reconnect to a sandbox and retain execution context.
- Return structured logs, errors, and rich cell outputs so the model and frontend can handle them separately.
- Stream execution status alongside model responses to give users feedback while code runs.
- Treat sandbox isolation, data retention, and custom runtime contents as explicit design choices.
Mentioned in this talk
Search inside this talk
What was claimed 11
- uses
E2B uses Firecracker
E2B is Firecracker-based.“As far as Kubernetes, we're Firecracker-based.”
56:09inHow I Learned to Stop Worrying and Love the SandboxYouTube Verified12 sources· Talk, Job posting· archived
- foundedVasek Mlejnsky founded
E2B
Co-founder and CEO“We’ll use E2B, a company I co-founded”
YouTube Verified4 sources· Talk, Web· archived
- built
E2B built
code-interpreter“That's something we built at E2B.”
YouTube Verified3 sources· Talk, GitHub, Web· archived
- launchedofferings in financial services and life sciences
“Anthropic released about two days ago”
YouTube Verified3 sources· Talk
- featureVercel AI SDK: Provides streaming chat and tool calling for the workshop app.
“an easy, nice way to connect to different models and stream them to your frontend and from your backend”
YouTube Unverified1 source· Talk
- feature
code-interpreter: Executes Python, JavaScript, R, and Java code and returns standard output, errors, and rich outputs such as charts and images.“You can send it Python, JavaScript, R, and Java code, and get back standard output and error output. We also get back charts.”
YouTube Unverified1 source· Talk
- uses
“The sandbox is a Jupyter server.”
YouTube Unverified1 source· Talk
- integrates withVercel AI SDK integrates with
Claude
“The model we're using is Anthropic's Sonnet”
YouTube Unverified1 source· Talk












