code_execution.py
code_execution_20250825 is generally available and does not need a beta header. It gives Claude Bash, file operations, and Python through the sandbox. During streaming, tool input can arrive incrementally, but each execution-result block arrives as a complete block.
Anthropic offers code execution on the Claude API, Claude Platform on AWS,
and Hosted-on-Anthropic Microsoft Foundry deployments. It is unavailable on
Amazon Bedrock and Google Cloud.
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Set your API key
4
Save and run
Save the example as
code_execution.py, then run: