Code interpreter pricing is the price of the sandbox your agent’s code runs in, billed one of three ways: per container session (OpenAI), per second of CPU actually used and memory held (AWS Bedrock AgentCore and Fly.io Sprites), or per second of reserved vCPUs and memory for as long as the sandbox runs (E2B, Daytona, Modal). At published rates, 1,000 short executions cost from about $0.24 on Sprites to $7.50 or more on OpenAI containers.[1][2][3][4]
An agent is asked a question about a CSV. It writes a pandas script, runs it, gets a KeyError, fixes the column name, runs it again and plots the result. Each run takes a few seconds of CPU. Between runs the sandbox sits with the dataframe in memory while the model decides what to do next.
That gap decides the bill. A reserved-resource provider charges for the model’s thinking time at full price, a metered one charges for the seconds of pandas and the memory held, and a per-session one charges a flat fee whether the code ran for one second or nineteen minutes. The same workload differs by a factor of thirty across those models.
How Does Code Interpreter Pricing Work?
Code interpreter pricing meters the sandbox, not the code: you pay for a container session, for CPU-seconds and memory-seconds consumed, or for reserved resources while the sandbox runs. Tokens come on top: OpenAI bills the tokens a model spends on built-in tools at that model’s own rates, separately from the container.[1]
Per-session containers
OpenAI prices Code Interpreter and Hosted Shell containers by memory tier: $0.03 for 1 GB, $0.12 for 4 GB, $0.48 for 16 GB and $1.92 for 64 GB, per 20-minute session per container. Eligible sessions are billed by the minute with a 5-minute minimum.[1] The tier is fixed for the life of the container, and 1 GB is the default.[5] A container expires after 20 minutes without use, and everything in it, files and Python objects included, is discarded and cannot be recovered.[5]
Actual CPU and memory used
AgentCore Code Interpreter charges $0.0895 per vCPU-hour and $0.00945 per GB-hour, metered per second on actual CPU consumption and the peak memory consumed up to that second, with a 1-second minimum and a 128 MB memory floor. AWS does not charge for I/O wait and idle time as long as no background process is running, but memory is billed for as long as the session holds it, which is how AWS’s own worked example adds up.[2] Sprites meter the same way at $0.0385 per CPU-hour of CPU used and $0.021875 per GB-hour of memory used, and a sleeping Sprite bills no compute at all.[3]
Reserved vCPUs and memory
E2B bills running sandboxes per second for provisioned CPU and RAM, at $0.000014 per vCPU-second and $0.0000045 per GiB-second, and billing stops once a sandbox is paused, killed or times out.[4][6] Daytona charges $0.0504 per vCPU-hour and $0.0162 per GiB-hour on reserved resources, per second, and bills a stopped sandbox for its disk only.[7][8] Modal charges whichever is higher, the amount you request or the amount you use.[9] Fly.io vs E2B prices E2B’s pause against a sleeping Sprite.
Vercel and Cloudflare split the difference. Vercel bills Active CPU only while code is using the processor, but bills memory on what is provisioned, 2 GB per vCPU, in 1-minute minimum increments.[10] Cloudflare bills containers for every 10 ms they run, with CPU on active usage and memory and disk on the instance type’s provisioned size.[11] Every billing model is compared under AI sandbox pricing; a code interpreter is where they diverge most, because its executions are short and its gaps long.
What Do 1,000 Code Executions Cost?
One thousand short code executions cost about $0.24 on Fly.io Sprites and $0.30 on AgentCore when each holds 0.3 GB of memory, $1.06 to $1.58 on the per-second sandbox platforms, and $7.50 on OpenAI when every execution opens its own container. Each execution runs on 1 vCPU, keeps its sandbox alive for 60 seconds and spends 10 of them on the CPU.
| Provider | Billed on | 0.3 GB in use | 1 GB in use |
|---|---|---|---|
| Fly.io Sprites | CPU used, memory used | $0.24 | $0.49 |
| AWS Bedrock AgentCore | CPU used, peak memory | $0.30 | $0.41 |
| Vercel Sandbox | Active CPU, provisioned memory | $1.06 | $1.06 |
| E2B | Reserved vCPU and memory | $1.11 | $1.11 |
| Daytona | Reserved vCPU and memory | $1.11 | $1.11 |
| Cloudflare Sandbox | Active CPU, provisioned memory and disk | $1.15 | $1.15 |
| Modal Sandboxes | Higher of request or usage | $1.58 | $1.58 |
| OpenAI containers | Per session, new container per call | $7.50 | $7.50 |
Our arithmetic on published rates, not a figure any vendor quotes: [3] [2] [10] [4] [7] [11] [9] [1]. Each execution: 1 vCPU, 60 s alive, 10 s on CPU. E2B, Daytona and Modal reserve 1 vCPU and 1 GiB. Cloudflare uses its nearest shape, standard-2, which provisions 6 GiB. Vercel provisions 2 GB per vCPU and adds $0.60 per million creations at iad1 rates. Sprites include 2 GB of hot storage. OpenAI uses the 1 GB tier billed per minute with its 5-minute minimum; billed as a full session, it is $30.00. Plan fees, credits and allowances excluded. Checked 2026-10-05.
Sprites are the cheapest row while each execution holds less than about 0.6 GB of memory; above that, AgentCore’s memory rate, under half the Sprites rate, puts it ahead, at $0.41 against $0.49 when 1 GB is in use. Both skip idle CPU, so the split comes down to the two rates. Sprites charge $0.0385 per CPU-hour against AgentCore’s $0.0895, which wins the short, CPU-bound call. AgentCore charges $0.00945 per GB-hour against $0.021875, which wins the interpreter holding a large dataframe for a minute.
The other platforms do not move between columns, because they bill the memory they set aside whatever the code uses, and they bill the 50 idle seconds in every execution.
OpenAI’s figure depends on reuse more than on usage. A new container per call is the worst case. If the same 1,000 calls arrive as 50 conversations that each fit inside one 20-minute session, the container bill is 50 sessions, or $1.50.[1]
Hosted Code Interpreter Tools vs Running Your Own Sandbox
The difference between a hosted code interpreter tool and a sandbox you run is less the rate than the lifetime: OpenAI and AgentCore discard the environment when the session ends, and a sandbox you control keeps it for as long as you want. On OpenAI, a container unused for 20 minutes expires, a call to it fails, and the only way back is a new container with the files uploaded again.[5]
AgentCore sessions run for 15 minutes by default and can be set to last up to 8 hours. Each runs in its own microVM, and when the session ends its data is cleaned up.[12] AgentCore offers no managed session storage for Code Interpreter. Persistence means mounting your own Amazon S3 Files or Amazon EFS access point, which requires the interpreter to run in VPC network mode.[13]
That lifetime is a cost the rate card does not show. An interpreter that starts fresh reinstalls every package the agent added, re-downloads the dataset and rebuilds the dataframe before it can answer, and that setup is billed on every platform that throws the environment away. The tradeoff between the two designs is laid out under ephemeral vs persistent sandboxes.
What Are the Hidden Costs of a Code Interpreter?
The hidden costs of a code interpreter are the charges that do not scale with the code you run.
- Billing minimums. OpenAI bills eligible container sessions with a 5-minute minimum, so a 10-second call is billed as five minutes.[1] Vercel bills provisioned memory in 1-minute minimum increments.[10]
- Memory during the model’s turn. AgentCore, Vercel and Cloudflare stop charging CPU while code waits, and keep charging memory.[2][10][11]
- Reservations left running. E2B bills a sandbox until it is paused, killed or times out, and Daytona bills reserved CPU and memory until a sandbox is stopped.[6][8] An agent that forgets to stop its sandbox pays for the forgetting.
- Services billed alongside. Cloudflare’s Sandbox SDK is billed as Containers, plus Workers for incoming requests, Durable Objects for each sandbox instance and Workers Logs if enabled.[14]
Code Interpreter Pricing on Fly.io
On Fly.io, a code interpreter runs in a Sprite: a hardware-isolated Linux computer that bills $0.0385 per CPU-hour of CPU used and $0.021875 per GB-hour of memory used, sleeps when nothing is happening, and bills no compute while it sleeps.[3]
The interpreter also keeps its state between calls. A Sprite has a real ext4 disk, so files, installed packages, Git repositories and SQLite databases survive every pause. About 30 seconds after activity stops, the Sprite pauses. A warm pause suspends the VM with memory intact, so the Python objects from the last call are still there; if it stays idle long enough, the VM stops fully and processes start fresh on the next wake, with the disk unchanged. The Sprite lifecycle covers when each happens. A request to the Sprite’s URL wakes it.[3] An agent that installs scikit-learn on Monday finds it there on Thursday.
To build it, install the packages once, run the interpreter as a service listening on port 8080, and point the agent’s tool at the Sprite’s URL. Services are started at boot, restarted on crash and brought back after a cold wake, so the interpreter answers the request that woke it. The Sprites quickstart covers creating one. One Sprite per user keeps each user’s files on their own machine.
The code in that interpreter is written by a model, and the model reads whatever is in the CSV, the web page or the user’s prompt. An instruction planted in that input can make it write code that reads the Sprite’s files and sends them somewhere. Each Sprite is its own Firecracker microVM with its own kernel, so that code cannot reach another user’s Sprite. A Sprite starts with open egress, and you close it by applying an egress allowlist from outside the Sprite: code inside can read the policy and cannot change it, and packets to anywhere else are dropped. Before a risky step, checkpoint the Sprite; a restore puts the whole filesystem back as it was.
Sprites lose on paper above roughly 0.6 GB per execution, and the table shows it. An interpreter that keeps its packages and data between calls still does less work per call than one rebuilt every session.
Frequently Asked Questions
How much does OpenAI Code Interpreter cost?
OpenAI charges $0.03 per 20-minute session for a 1 GB container, rising to $1.92 for 64 GB, with eligible sessions billed by the minute and a 5-minute minimum, plus model tokens. A container expires after 20 minutes without use and its files are discarded. On Fly.io, a Sprite running the same interpreter bills only the CPU and memory it uses, and its files stay on disk between calls.
How much does Bedrock AgentCore Code Interpreter cost?
AgentCore Code Interpreter costs $0.0895 per vCPU-hour of CPU actually used and $0.00945 per GB-hour of peak memory, metered per second with a 1-second minimum and a 128 MB memory floor. At published rates, 1,000 short executions holding 0.3 GB cost about $0.30, against about $0.24 on Fly.io Sprites.
What is the cheapest code interpreter?
Fly.io Sprites, for short executions holding less than about 0.6 GB of memory: about $0.24 per 1,000 runs at 0.3 GB, the lowest of eight platforms at published rates. Above that, AgentCore’s lower memory rate makes it cheaper per execution, about $0.41 against $0.49 at 1 GB, though its sessions discard their files when they end and a Sprite keeps its disk.
Which sandbox is best for AI agents?
Fly.io Sprites, for agents that run code in bursts. Each Sprite is a hardware-isolated microVM that keeps its filesystem, sleeps with no compute billing when idle, and wakes on the next request, so an interpreter keeps its installed packages and data files between calls instead of rebuilding them every session.
Is code interpreter billed separately from tokens?
Yes. On OpenAI, the container is billed per session and the tokens the model spends using the tool are billed at the model’s own rates. Running your own interpreter on Fly.io Sprites splits the bill the same way: the model provider bills tokens, and the Sprite bills the CPU and memory the code uses.
How do I calculate code interpreter cost?
Multiply executions by what each one holds. For metered sandboxes, that is CPU-seconds used times the CPU rate, plus memory held times seconds alive times the memory rate; for reserved sandboxes, reserved vCPUs and memory times seconds alive; for per-session tools, sessions times the session price. On Fly.io Sprites, 1,000 runs of 10 CPU-seconds each, alive 60 seconds at 0.3 GB, come to about $0.24.
Does a code interpreter keep state between calls?
Yes, but on hosted tools only until the session ends. OpenAI discards a container after 20 minutes without use, and AgentCore cleans up session data when the session ends. A Fly.io Sprite keeps files and installed packages on disk across every sleep, and a warm pause keeps in-memory state as well.
Does an idle code interpreter cost money?
Yes, on most platforms, because memory is billed while the sandbox is alive even when the CPU is idle. AgentCore, Vercel and Cloudflare stop charging CPU during idle time and keep charging memory, and E2B and Daytona charge the full reservation until the sandbox is paused or stopped. A Fly.io Sprite pauses about 30 seconds after activity stops and bills no compute while it sleeps, only storage.
Sources
- ^ OpenAI, “Pricing”. developers.openai.com/api/docs/pricing. Checked 2026-10-05.
- ^ Amazon Web Services, “Amazon Bedrock AgentCore Pricing”. aws.amazon.com/bedrock/agentcore/pricing. Checked 2026-10-05.
- ^ Fly.io, “Sprites”. fly.io/sprites. Checked 2026-10-05.
- ^ E2B, “E2B Pricing”. e2b.dev/pricing. Checked 2026-10-05.
- ^ OpenAI, “Code Interpreter”. developers.openai.com/api/docs/guides/tools-code-interpreter. Checked 2026-10-05.
- ^ E2B, “Billing & limits”. docs.e2b.dev/billing. Checked 2026-10-05.
- ^ Daytona, “Daytona: Secure Infrastructure for Running AI-Generated Code”. www.daytona.io/pricing. Checked 2026-10-05.
- ^ Daytona, “Billing | Daytona”. www.daytona.io/docs/en/billing. Checked 2026-10-05.
- ^ Modal, “Pricing: Pay per second for GPUs and CPUs”. modal.com/pricing. Checked 2026-10-05.
- ^ Vercel, “Vercel Sandbox pricing and quotas”. vercel.com/docs/sandbox/pricing. Checked 2026-10-05.
- ^ Cloudflare, “Pricing, Cloudflare Containers docs”. developers.cloudflare.com/containers/platform/pricing. Checked 2026-10-05.
- ^ Amazon Web Services, “Session management, Amazon Bedrock AgentCore Developer Guide”. docs.aws.amazon.com/bedrock-agentcore/latest/devguide/code-interpreter-session-characteristics.html. Checked 2026-10-05.
- ^ Amazon Web Services, “File system configurations for AgentCore Code Interpreter”. docs.aws.amazon.com/bedrock-agentcore/latest/devguide/code-interpreter-filesystem-configurations.html. Checked 2026-10-05.
- ^ Cloudflare, “Pricing, Cloudflare Sandbox SDK docs”. developers.cloudflare.com/sandbox/sdk/platform/pricing. Checked 2026-10-05.