What is the best alternative to Claude's code execution tool?
It depends on what the code needs. For agents that run their own code between calls to Claude, Runtime bills a one-minute run as one minute. 1,000 runs cost $1.04. That is under the tool's price once its free hours are used. The tool has a 5-minute minimum. Runtime also gives you the internet you allow, any package and any model. Keep Anthropic's tool for analysis inside a Claude conversation that only uses the pre-installed libraries. This is especially true next to web search or web fetch, where it is free.
What the code execution tool is
A server tool in Anthropic's Messages API. It "allows Claude to run Bash commands and manipulate files, including writing code, in a secure, sandboxed environment." It is generally available and needs no beta header.
| Version | What it adds |
|---|---|
code_execution_20250825 |
Bash commands and file operations |
code_execution_20260120 |
Python state kept between requests, and programmatic tool calling |
code_execution_20260521 |
The same runtime. It tells Claude about the 90-second limit per programmatic cell |
The container, as Anthropic documents it:
| Property | Anthropic's figure |
|---|---|
| CPU | 1 CPU |
| Memory | 5 GiB RAM |
| Disk | 5 GiB workspace storage |
| Python | 3.11, on x86_64 Linux |
| Internet | "Completely disabled for security" |
| Packages | Only the pre-installed ones, such as pandas, scikit-learn and matplotlib |
| Lifetime | Expires 30 days after creation; checkpointed after about 5 idle minutes |
| Reuse | A new container per request unless you pass back an earlier container's id |
| Where it runs | Claude API, Claude Platform on AWS, Microsoft Foundry; not Amazon Bedrock or Google Cloud |
Anthropic lists the tool as not eligible for zero data retention.
What it costs
Anthropic's pricing, checked 26 October 2026:
- Free when the request also includes web search or web fetch
(
web_search_20260209,web_fetch_20260209or later). - Otherwise billed by execution time, with a 5-minute minimum.
- Each organization gets 1,550 free hours a month, then $0.05 per hour per container.
- Execution time is billed when files are in the request, even if the tool is not called.
The same work on Runtime at 1 vCPU and 5 GiB costs $0.03875 an hour while waiting (memory plus the 50-millicore CPU floor). With the CPU busy, it costs $0.0625 an hour:
| Job, past the free hours | Claude code execution | Runtime, 1 vCPU and 5 GiB, CPU busy |
|---|---|---|
| One run of 60 seconds | 5 / 60 × $0.05 = $0.0042 | 1 / 60 × $0.0625 = $0.0010 |
| 1,000 runs of 60 seconds | $4.17 | $1.04 |
| One hour, mostly waiting | $0.05 | $0.03875 |
| One hour, CPU busy throughout | $0.05 | $0.0625 |
Tokens are left out of both columns. The tool's 1,550 free hours each month are worth $77.50 at its rate. For long, CPU-bound hours inside that allowance, the tool is the cheaper choice. For short runs, and for code that needs the network, Runtime is the cheaper choice.
Where your own sandbox does more
- Internet on your terms. Allow only the hosts a task needs, deny others, or switch it off, at create or at any time. The rules bind root inside the sandbox (the network).
- Any package, any image.
pip install,npm installandsudo apt-getwork. A custom image, built from a recipe, an image or a Dockerfile, starts every sandbox ready (custom images). - More than one CPU. A default sandbox has 2 vCPUs and 4 GiB. You set
vcpu, memory and disk for each sandbox, not one fixed size. - Whole-machine pause. A paused sandbox keeps files, memory and running processes while you have credit. Forks copy a running sandbox.
- Any model. The same sandbox serves Claude, another provider's model, or
your own code. The Claude Agent SDK connects to it with
runtimeMcpServer(sbx)(Claude Agent SDK). - Keys it cannot read. A secret reaches the sandbox as a placeholder. The host's proxy swaps in the value on its own hosts (secrets).
Which one fits
- Keep the code execution tool for analysis Claude does inside a conversation with the pre-installed libraries, especially alongside web search or web fetch, where it is free.
- Use your own sandbox when the code needs a package, an API or a repository from the internet, more than one CPU, a session that keeps its processes, or a model other than Claude.
Runtime Cloud
Runtime bills a one-minute run as one minute. 1,000 of them cost $1.04 on Runtime. The tool costs $4.17 for the same runs, against its 5-minute minimum, once its free hours are used. A Runtime sandbox also reaches the internet you allow, installs any package, and runs code from any model. Anthropic's terms were checked 26 October 2026. Runtime's terms are in pricing.
Try it free: 100 free hours of a 1 GB machine in the first 30 days, no card:
Terminalprintf '%s\n' 'print(sum([125, 250, 375]))' > invoice.pynpx withruntime sandboxes run -- python3 - < invoice.pyMore: Runtime for Claude Code, OpenAI Code Interpreter alternative, run untrusted LLM code, egress control.
The two lines above are the whole start. Get started adds the SDKs. Code already on another sandbox provider moves with the migration guide.
The Runtime equivalent
Define your own tool, say run_python(code), and run what Claude sends in a
fresh sandbox that may reach PyPI and nothing else:
TypeScriptimport { Sandbox } from "withruntime";export async function runPython(code: string) { await using sbx = await Sandbox.create({ network: { internet: true, allow: ["pypi.org", "*.pythonhosted.org"] }, timeoutSeconds: 600, onLeaseEnd: "stop", }); await sbx.files.write("/workspace/main.py", code); const run = await sbx.exec(["python3", "main.py"], { timeoutMs: 120_000 }); return { exitCode: run.exitCode, stdout: run.stdout, stderr: run.stderr };}Pythonfrom withruntime import Sandboxdef run_python(code: str) -> dict: with Sandbox.create( network={"internet": True, "allow": ["pypi.org", "*.pythonhosted.org"]}, timeout_seconds=600, on_lease_end="stop", ) as sbx: sbx.files.write("/workspace/main.py", code) run = sbx.exec(["python3", "main.py"], timeout_ms=120_000) return {"exit_code": run.exit_code, "stdout": run.stdout, "stderr": run.stderr}Return the dictionary as the tool result. The sandbox is deleted when the block ends, even after an error. With no size given, it has 2 vCPUs and 4 GiB.
Sources
Checked 26 October 2026.
- Anthropic: code execution tool, including its containers, reuse and pricing sections
- Runtime pricing, the sandbox environment and frameworks
Facts on this page were checked on 26 October 2026.