The code execution tool is a server-side tool: instead of your application implementing a tool and returning results, Claude writes code and Anthropic runs it in a managed sandbox, feeding the output back into the conversation automatically. It turns "summarize this CSV" into "actually compute statistics on this CSV" — the model can calculate, transform data, and generate files rather than estimating. On Claude Platform on AWS, the Anthropic-operated deployment behind AWS IAM and Marketplace billing, code execution is available with the platform's typical same-day parity with the first-party API. It is not available on Amazon Bedrock or Google Vertex AI, and is beta on Microsoft Foundry — so among the AWS-side options, Claude Platform on AWS is where this tool lives.
Where the sandbox actually runs
This is the point enterprises most often get wrong: the sandbox is Anthropic's managed environment, not compute inside your AWS account. Code executed by the tool does not run in your VPC, cannot assume your IAM roles, and has no path to your databases, S3 buckets, or internal services. That is a safety property — model-written code cannot touch your infrastructure — and a design constraint: anything Claude's code should process must be provided through the request itself or through files you upload. Remember too that on this platform Anthropic is the data processor for inference inputs and outputs, and data may not reside in AWS; if your requirements demand that AWS be the sole data processor, the official guidance points to Amazon Bedrock instead (which does not offer this tool). For exact sandbox capabilities — available libraries, resource ceilings, network behavior — check the official documentation rather than assuming.
Files in, files out
Code execution pairs naturally with the Files API, which is also available on Claude Platform on AWS. You can upload input data as files and reference them by ID; when Claude's code produces artifacts — a cleaned dataset, a chart, a generated report — the response includes file references you download afterward. On the IAM side that means the calling principal typically needs the Files actions alongside inference: CreateFile to supply inputs, GetFile to download outputs (it covers both metadata and content). Enumerate those actions explicitly — the tempting *File wildcard famously over-matches onto the user-profile actions and misses ListFiles.
What it costs
The billing model has a friendly headline and a few edges worth knowing:
| Scenario | Cost |
|---|---|
Used together with web_search_20260209+ or web_fetch_20260209+ | Free (tokens still billed) |
| Standalone, within free allowance | 1,550 free hours per organization per month |
| Standalone, beyond free allowance | $0.05 per hour per container, 5-minute minimum per execution |
One subtlety: preloading files into the execution environment triggers execution-time billing even if Claude never actually invokes the tool in that request. Standard token costs always apply on top. For most teams the 1,550 free hours comfortably cover exploratory and moderate production use; heavy pipelines should model the per-container hours.
Data retention posture
Code execution is inherently stateful: container data is retained for up to 30 days. Like the Files API and the Batch API, it is not eligible under a zero-data-retention (ZDR) arrangement — using it is an explicit choice to step outside ZDR for that data. Claude Platform on AWS otherwise follows the same retention policy as the first-party Claude API, with ZDR available on request through an Anthropic account representative. If certain workspaces must never use stateful features, the documented lockdown pattern is an IAM deny on the relevant create actions for those workspace ARNs.
Where to go next
See the code execution tool in detail for request anatomy, the Files API on Claude Platform on AWS for the input/output file lifecycle, and web tools on Claude Platform on AWS for the companions that make execution free.