Claude code-execution tool
Plug Podflare into Claude's native `code_execution` tool. One helper call turns every tool_use block into a sandboxed run.
from anthropic import Anthropic
from podflare import Sandbox
from podflare.integrations.anthropic import handle_code_execution_tool_use
client = Anthropic()
with Sandbox() as sbx:
messages = [
{"role": "user",
"content": "Download this CSV and summarize: https://ex.com/sales.csv"}
]
while True:
resp = client.messages.create(
model="claude-opus-4-7",
max_tokens=2048,
tools=[{"type": "code_execution_20250825",
"name": "code_execution"}],
messages=messages,
)
messages.append({"role": "assistant", "content": resp.content})
if resp.stop_reason != "tool_use":
break
# run every code_execution call in our sandbox
results = [
handle_code_execution_tool_use(b, sbx)
for b in resp.content
if b.type == "tool_use" and b.name == "code_execution"
]
messages.append({"role": "user", "content": results})
print(resp.content[0].text)