Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Compute statistics with Claude’s server-side code execution tool via a beta flag.
""" Anthropic Code Execution ======================== Cookbook example for `anthropic/code_execution.py`. """ from agno.agent import Agent from agno.models.anthropic import Claude # --------------------------------------------------------------------------- # Create Agent # --------------------------------------------------------------------------- agent = Agent( model=Claude( id="claude-sonnet-4-20250514", betas=["code-execution-2025-05-22"], ), tools=[ { "type": "code_execution_20250522", "name": "code_execution", } ], markdown=True, ) agent.print_response( "Calculate the mean and standard deviation of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", stream=True, ) # --------------------------------------------------------------------------- # Run Agent # --------------------------------------------------------------------------- if __name__ == "__main__": pass
Set up your virtual environment
uv venv --python 3.12 source .venv/bin/activate
uv venv --python 3.12 .venv\Scripts\activate
Install dependencies
uv pip install -U agno anthropic
Export your Anthropic API key
export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
$Env:ANTHROPIC_API_KEY="your_anthropic_api_key_here"
Run the example
code_execution.py
python code_execution.py
Was this page helpful?