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. The simplest way to give Claude a scratch computer for analysis and file work, provided you can live without network access and custom environments.
Overview
The code execution tool is a server-side tool in the Claude API: add {"type": "code_execution_20250825", "name": "code_execution"} to a Messages request and Claude can run Bash commands, write and edit files and execute Python in a container that Anthropic hosts. The container is a Linux x86_64 environment with Python 3.11, 1 CPU, 5 GiB of RAM and 5 GiB of workspace storage, with a fixed set of pre-installed libraries (pandas, numpy, scipy, scikit-learn, matplotlib, seaborn, openpyxl, pypdf and others) and command-line tools such as ripgrep, sqlite and 7zip. Internet access is completely disabled. Files are passed in and out through the Files API using container_upload blocks and $OUTPUT_DIR.
Each request gets a fresh container unless you pass back the container.id from an earlier response, in which case files (and, with code_execution_20260120 or later, Python REPL state) persist. Containers are checkpointed after about five minutes of inactivity and expire 30 days after creation. Three tool versions are current: code_execution_20250825 (Bash and file operations), code_execution_20260120 (adds REPL state persistence and programmatic tool calling) and code_execution_20260521 (same runtime, with the 90-second per-cell limit described to the model); the legacy Python-only code_execution_20250522 is documented for migration. The feature is marked stable and no beta header is required. Pricing is by execution time: 1,550 free container-hours per organisation per month, then $0.05 per container-hour with a five-minute minimum, and no charge when the request also uses the web search or web fetch tools. This record covers the hosted API tool only; Claude Code's local sandbox is a separate product.
Notable
- Marked stable in the Claude API docs; the three current tool versions are dated 2025-08-25, 2026-01-20 and 2026-05-21, and none requires a beta header
- Each organisation receives 1,550 free container-hours per month; usage beyond that is $0.05 per container-hour
- Images, video and audio that Claude produces in the container carry C2PA Content Credentials when downloaded through the Files API
Claude code execution tool specifications
| Attribute | Details |
|---|---|
| Isolation | Anthropic-hosted Linux container per request ("secure, sandboxed container"); the docs state full isolation from the host and other containers but do not name the container runtime or hypervisor |
| Deployment | Cloud or model provider service |
| Open source | No |
| SDKs and interfaces | Python, JavaScript/TypeScript, Go, Java, C#, PHP, Ruby, REST API, CLI |
| Cold start (vendor claim) | Not documented |
| Max session length | Containers expire 30 days after creation; after about 5 minutes of inactivity a container is checkpointed and restored when its ID is sent again; each tool call has a maximum execution time and each REPL cell in programmatic tool calling has a 90-second wall-clock limit |
| Persistence | Files written to the container persist across requests when you pass the container ID back; with code_execution_20260120 or later the Python REPL state (variable bindings) also persists; generated files are returned through the Files API |
| GPU | No — each container has 1 CPU, 5 GiB RAM and 5 GiB of workspace storage |
| Networking | Internet access is completely disabled and no outbound connections are allowed; packages cannot be installed at runtime, only the pre-installed libraries are available |
| Pricing | Billed by execution time, separate from tokens: 1,550 free container-hours per organisation per month, then $0.05 per hour per container, with a 5-minute minimum per execution; free of additional charge in requests that also use the web search or web fetch tools (web_search_20260209 / web_fetch_20260209 or later) |
| Free tier | 1,550 free container-hours per organisation per month |
| Compliance | Not eligible for zero data retention (container data retained up to 30 days) |
| Regions | Available on the Claude API, the Claude Platform on AWS, Claude Models on Google Cloud (Anthropic managed) and Microsoft Foundry (hosted on Anthropic); no region selection documented |
Facts from Claude code execution tool’s public documentation, verified November 9, 2026. Performance numbers are vendor claims.
Strengths and trade-offs
Strengths
- You want Claude to analyse uploaded files or produce charts and documents without operating a sandbox yourself
- You need the execution environment to be fully offline for data-handling reasons
- You are already on the Claude API (or its AWS, Google Cloud or Microsoft Foundry distributions) and want a one-line opt-in
- You want REPL state and files to survive across turns by reusing a container ID
Trade-offs
- No internet access at all, so no package installation, git clones or API calls from inside the container
- Fixed resources: 1 CPU, 5 GiB RAM, 5 GiB disk, no GPU and no custom images
- Only usable through Claude; the container is not addressable as a general-purpose sandbox from your own code
- Container data is retained for up to 30 days, so the tool is not eligible for zero data retention
Good fit for: Data analysis, file generation and multi-step scripting inside a Claude API conversation without running your own sandbox.
Use cases Claude code execution tool fits
- Code interpreters: 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.
How Claude code execution tool compares
| Sandbox | Isolation | Open source | Self-host / BYOC | Cold start (vendor) | Max session | Snapshots / pause | GPU | SDKs |
|---|---|---|---|---|---|---|---|---|
| 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 |
| 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 |
| 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 |
| Mistral code interpreter | Isolated container | No | No / No | Not documented | Not documented | Not documented / Not documented | Not documented | Python, JavaScript/TypeScript, REST API |
| 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 |
Frequently asked questions
What is Claude code execution tool?
How does Claude code execution tool isolate code?
Is Claude code execution tool open source?
How much does Claude code execution tool cost?
What are the alternatives to Claude code execution tool?
Sources
Cite this page
Agent Sandboxes. (2026). Claude code execution tool. agentsandboxes.org. Last reviewed November 9, 2026. https://agentsandboxes.org/sandboxes/anthropic-code-execution/
Found an error or a missing sandbox? Submit a correction — every entry links to the sources it relies on.