code_execution (Anthropic)
Tool : A precise action the AI can call · requires anthropic-api
Runs Python and bash in an Anthropic sandbox, with a file editor.
Ideal for data analysis; code execution means it should be treated as a risk even in a sandbox.
Security reflects where data goes, requested permissions and incidents on record at the verification date. It is not a guarantee of zero risk: check the deployment mode and the connections you enable.
What it does, concretely
Many analysis or calculation tasks go beyond what a language model can reliably handle through reasoning alone: statistics on large files, visualizations, simulations, structured data processing. Anthropic's code_execution tool addresses this need by allowing Claude to run code directly during a conversation, without you having to manage the execution environment yourself.
In practice, the tool is added to an API request and gives Claude access to two sub-tools: Bash command execution and a file editor. Claude writes Python or shell commands, runs them in an isolated server-side container, retrieves the results, and incorporates them into its response. You can send your own files via the Files API (CSV, Excel, JSON, images, text) and retrieve files produced by Claude, such as charts or reports.
This tool is aimed at developers and technical teams building applications via the Anthropic API who need to automate data analysis, complex calculations, or file generation. It also suits those who want to delegate file processing tasks to Claude without exposing their own infrastructure.
However, it is not suited to users looking for a ready-to-use graphical interface: access is through the API only. It is also not appropriate for cases requiring internet access from the container, as it is network-isolated and cannot download additional packages at runtime.
What it offers
- ·Bash command execution in a secure server-side container, without any action required on your part.
- ·Built-in file editor allowing Claude to create, read, and modify files, including source code.
- ·Support for files uploaded via the Files API: CSV, Excel, JSON, XML, images, text files.
- ·Retrieval of generated files (charts, reports, etc.) via the Files API after execution.
- ·Container reuse across multiple requests by passing the container ID, with Python state persistence between calls (versions code_execution_20260120 and later).
- ·Free execution when the tool is used alongside the web_search or web_fetch tools (beyond standard token costs).
- ·Automatic C2PA signing of image, video, and audio files produced in the sandbox, enabling origin verification.
- ·Dynamic filtering of web search results directly within the execution environment, at no additional code execution cost.
In practice
- Price
- Freemium
- Commercial use
- Commercial use: yes
- Available on
- api
- Host
- anthropic-api
- FR interface
- No
Security and data
- Rating
- Security: one caveat, see the card
- Capabilities
- readswritesexecutesnetwork
- Your data
- Data with the vendor
- Maintenance
- Active
Links and repository checked on 25 October 2026 · added on 1 May 2025
How to install code_execution (Anthropic)
tools=[{"type":"code_execution_20260120","name":"code_execution"}]