Choosing a sandbox for code interpreters and data analysis
A code interpreter runs short, frequent bursts of Python for many users, so prioritize fast startup, stateful kernels (variables persist across calls), file upload and download, and no network by default. If you are already on one cloud or model provider, its managed tool (Azure, AWS, Google, OpenAI) is the least work. For model-agnostic apps, a hosted platform with a code-interpreter SDK such as E2B gives you more control.
What code interpreters need from a sandbox
A code interpreter lets a model run Python to analyse data, do maths, draw charts and convert files. Sessions are short and frequent, so the needs are:
- Fast startup — users wait while the sandbox boots.
- Stateful execution (Jupyter-style kernels) so variables persist across calls in a conversation.
- File upload/download and rich outputs such as charts.
- Strong isolation because every user’s code is untrusted, and ideally no network by default.
Sandboxes that fit, by kind
10 sandboxes document what this workload needs. They are grouped by kind and listed alphabetically; the order is not a ranking. Shortlist two or three, then pilot them with your own workload.
Hosted sandbox platforms
SDK-driven sandboxes you create, run code in and destroy through an API.
E2B
Open-source cloud sandboxes for AI agents, each a Firecracker microVM, with pause/resume, snapshots and forking.
- Firecracker microVM
- Open source
- Self-hostable
- BYOC
- Pause/resume
Why it fits: A dedicated Code Interpreter SDK with stateful Jupyter-style execution and chart output, on Firecracker microVMs, with pre-built templates and generous free credit.
Compute platforms with sandboxes
General serverless or app platforms that also offer sandboxes, often with GPUs.
Modal Sandboxes
Sandboxes on Modal’s serverless compute platform for running untrusted code at very high scale, with GPUs, snapshots and tunnels.
- gVisor or VM
- GPU
- Pause/resume
Why it fits: Fast-starting gVisor sandboxes with GPUs for heavier analysis or ML inside the interpreter.
Cloud provider code execution
Managed code-execution tools from AWS, Azure, Google Cloud and OpenAI.
AWS Bedrock AgentCore
AWS’s managed agent platform: a Code Interpreter tool for running agent-generated code and a Runtime that hosts each agent session in its own microVM.
- MicroVM (Runtime)
Why it fits: Managed Code Interpreter with sessions up to 8 hours, IAM/VPC integration and CPU billing that skips I/O wait.
Azure Container Apps dynamic sessions
Azure service that hands out Hyper-V-isolated sessions from prewarmed pools, either as a built-in code interpreter or running your own container image.
- Hyper-V VM
Why it fits: Hyper-V-isolated Python and Node interpreters from prewarmed pools with egress disabled by default and first-party LangChain, LlamaIndex and Semantic Kernel tools. 220-second execution cap.
Claude code execution tool
Server-side tool in the Claude API that runs Bash commands, Python and file edits inside an Anthropic-hosted container with no internet access.
- Hosted Linux container
Why it fits: A hosted container for Python and shell inside a Claude API conversation: data analysis, file generation and multi-step scripting with no sandbox to run.
Full profile →Claude code execution tool alternativesWebsite ↗
Gemini API code execution
Built-in Gemini API tool that lets the model write and run Python in a Google-hosted environment at no charge beyond tokens.
- Hosted Python runtime
Why it fits: The Gemini API tool that runs Python for calculation, analysis and charts inside the model call; the isolation technology is not documented.
Full profile →Gemini API code execution alternativesWebsite ↗
Google Agent Platform Code Execution
Google-managed sandbox API (formerly part of Vertex AI Agent Engine) that lets agents deployed anywhere run Python in stateful, network-isolated environments.
- gVisor
Why it fits: gVisor-isolated, no-network Python with state retained up to 14 days; fixed library set.
OpenAI Code Interpreter & Hosted Shell
Hosted containers in the OpenAI Responses API that the model uses to run Python (Code Interpreter) or shell commands (Hosted Shell).
- VM (unspecified)
Why it fits: Zero extra infrastructure if you are already on the OpenAI Responses API; tied to OpenAI models.
Code execution APIs
Submit code, get output: online judges, compiler APIs and Jupyter kernels as a service.
Datalayer Runtimes
Remote Jupyter kernels as a service for AI agents: stateful CPU or GPU runtimes created on demand from Python or TypeScript, with snapshots of installed packages, files and variables, and a hosted Jupyter MCP Server.
- Not documented
- GPU
- Snapshots
Why it fits: Stateful, snapshot-able Jupyter kernels (CPU or GPU) as a service, for agents that need a kernel rather than a one-shot run.
Judge0
Open-source online code execution system (GPL-3.0) that runs each submission in an isolate sandbox, offered as Judge0 Cloud via RapidAPI or directly and as a self-hosted Docker Compose stack.
- isolate (namespaces/cgroups)
- Open source
- Self-hostable
Why it fits: Open-source submit-and-run API in 60 to 90+ languages with per-submission CPU, wall-clock and memory limits; hosted or self-hosted.
Side by side
| Sandbox | Isolation | Open source | Self-host / BYOC | Cold start (vendor) | Max session | Snapshots / pause | GPU | SDKs |
|---|---|---|---|---|---|---|---|---|
| AWS Bedrock AgentCore | MicroVM (Runtime) | No | No / No | Not documented | Up to 8 h | Not documented / Not documented | No | Python (AgentCore SDK), AWS SDKs, AWS CLI |
| Azure Container Apps dynamic sessions | Hyper-V VM | No | No / No | Sub-second (pooled) | 220 s / exec | No / No | No | REST API, Azure CLI, LangChain, LlamaIndex, Semantic Kernel |
| Claude code execution tool | Hosted Linux container | No | No / No | Not documented | 30 days (container) | No / Not documented | No | Python, JavaScript/TypeScript, Go, Java, C#, PHP, Ruby, REST API, CLI |
| Datalayer Runtimes | Not documented | No | No / No | Not documented | Minutes (set per runtime) | Yes / Not documented | Yes | Python, JavaScript/TypeScript, CLI, MCP server, REST API |
| E2B | Firecracker microVM | Yes | Yes / Yes | Not documented | 1 h / 24 h (Pro) | Yes / Yes | No | Python, JavaScript/TypeScript |
| Gemini API code execution | Hosted Python runtime | No | No / No | Not documented | 30 s per execution | No / No | No | Python, JavaScript/TypeScript, Go, Java, REST API |
| Google Agent Platform Code Execution | gVisor | No | No / No | <1 s (warm) | 14-day state | No / Not documented | No | Python (Agent Platform SDK), REST API |
| Judge0 | isolate (namespaces/cgroups) | Yes | Yes / No | Not documented | 5 s wall (max 20 s) | No / No | No | REST API, Python, JavaScript/TypeScript |
| Modal Sandboxes | gVisor or VM | No | No / Not documented | <1 s | Up to 24 h | Yes / Yes | Yes | Python, JavaScript/TypeScript, Go |
| OpenAI Code Interpreter & Hosted Shell | VM (unspecified) | No | No / No | Not documented | 20 min idle | No / No | No | OpenAI Responses API, Containers API, OpenAI SDKs |
Frequently asked questions
What is the easiest way to add a code interpreter to my AI app?
Cite this page
Agent Sandboxes. (2026). Choosing a sandbox for code interpreters and data analysis. agentsandboxes.org. Last reviewed November 9, 2026. https://agentsandboxes.org/use-cases/code-interpreter/
Found an error or a missing sandbox? Submit a correction — every entry links to the sources it relies on.