Check before you reconcile

  • ✓Confirm the line is a container session. It covers Code Interpreter and Hosted Shell. Model tokens still bill at the chosen model.
  • ✓The row quotes a 20-minute session. The footnote bills eligible sessions by the minute, with a 5-minute floor. Do not add the two units.
  • ✓The memory tier is fixed for the container's life. Omitting it keeps 1 GB. Higher tiers use the built-in tool rates on the pricing page.
  • ✓Twenty idle minutes expire it, and an expired container cannot be revived. A retrieve, upload, or delete refreshes last_active_at. Download files first.
  • ✓Auto mode reuses a container that is still active in context. A new session, with no prior call in context, can meet the 5-minute floor again.

1. One page states two units

The OpenAI pricing page gives containers their own row. The row covers Hosted Shell and Code Interpreter. Four memory tiers sit side by side: 1 GB, 4 GB, 16 GB, and 64 GB, priced per 20-minute session per container. The note on that page says eligible container sessions are billed by the minute, with a 5-minute minimum per session. GB there means a binary gigabyte, 2^30 bytes. Tokens used by built-in tools bill at the chosen model's per-token rates. The Responses, Chat Completions, Realtime, Batch, and Assistants APIs are not priced as a separate interface fee. Their tokens bill at the model's input and output rates. The container is the column beside those tokens.

The reconciliation error is to add the two sentences. The row says a 20-minute session. The footnote says by the minute, with a 5-minute floor. A script that ran for a few dozen seconds already meets that floor. Adding another 20 minutes treats the row and the footnote as two charges. Recording those seconds as zero drops the floor. The page does not define "eligible" in that paragraph. The session duration on the bill is what shows which sentence this container landed on. Unit prices stay on the pricing page. This note keeps the units: tier, minute, floor.

This column stands apart from two other overseas meters. Vector-store storage bills by the day once the combined stores pass the free gigabyte, and tool calls bill again. A function schema bills as input even when the model never calls it. The container bills how long the sandbox lived, and which memory tier it was born with. One request can carry all three: the schema in the input, retrieved text in the input, and a container session beside them. Dividing the visible answer by a token price leaves all three unexplained.

2. The memory tier stays, and auto mode can reuse the box

The Code Interpreter guide describes the container as a fully sandboxed virtual machine where the model runs Python. The choices are 1g, 4g, 16g, and 64g. Leaving out memory_limit keeps the default 1 GB tier. The selected tier applies for the entire life of that container, whether it was created automatically or through the containers API. Higher tiers bill at the built-in tool rates for Code Interpreter. Changing the tier means a new container. The old one finishes on the tier it was created with.

Auto mode passes container.type = auto when you create a Response. It creates a container, or it reuses an active container that a previous code_interpreter_call in the model's context already used. That output item carries the container_id that was generated or reused. Explicit mode creates the container at v1/containers and passes the returned id in the tool configuration. Containers created in auto mode are also visible at /v1/containers. The model knows the tool as the python tool. Asking for the python tool in the prompt is the explicit way to invoke it.

A new HTTP request is therefore not, by itself, a new container. If the previous call is still in context and the container is still active, auto mode continues the same one. The same memory tier continues, and so does the same clock. If the context was trimmed and the previous call is gone, auto mode opens another. The new one can meet the 5-minute floor again. Estimating every turn as a fresh session overstates short work that was reused. Estimating the whole day as one container misses the floor that appears after the context dropped the prior call.

3. Expiry is 20 minutes, and a retrieve resets that clock

A container expires if it is not used for 20 minutes. After that, using it in v1/responses fails. A snapshot of the metadata remains. The data inside is discarded and is not recoverable. An expired container cannot be moved back to active. The documented path is a new container and a fresh upload. Python objects that lived in the old container's memory are gone. The guide asks you to treat containers as ephemeral, keep the data on your own systems, and download any files you need while the container is still active.

Any container operation refreshes last_active_at. The guide names retrieving the container, and adding or deleting files. That clock decides whether another 20 idle minutes will expire the box. The pricing page describes the billed session in a different place. A retrieve can keep the container off the expiry. The page does not add a sentence that prices the idle gap between two retrieves by the minute, and it does not say each GET is a new 5-minute floor. A health check whose only job is to keep the box alive also postpones expiry. Reconcile from the session duration on the bill, set against the 5-minute floor, rather than from a count of HTTP calls times that floor.

Files the model creates show up as container_file_citation annotations on the next message, with container_id, file_id, and a filename. Download them through the container file content method. Files in the model input are uploaded to the container automatically. You do not upload them a second time for the same container. After expiry the citation can still sit in the message, while the bytes are gone. Download first, then let it sit. That order is the expiry rule.

4. A retry adds tokens. A new floor needs a new container

The guide includes a model that writes code, watches it fail, and keeps rewriting and running it until it succeeds. Those retries, while they stay inside the same active container, keep the memory tier and keep the Python objects already built there. What grows is the tokens spent rewriting. Built-in tool tokens bill at the chosen model's rates. The container fee follows the session. The number of syntax errors is not the container's billing unit.

Once that container expires, or the next request's context no longer contains the previous code_interpreter_call, auto mode opens another. The new one takes a memory tier from scratch and faces the session floor again. Passing the old id explicitly fails once the container has expired. It cannot be revived. tool_choice set to required means this call must use the tool. It changes whether the tool runs. It does not change the sentence that bills the session by the minute, with a 5-minute minimum.

File size and the memory tier are different rulers. The tier name is RAM, and the GB on the pricing page is 2^30 bytes. A decimal file size that does not match the tier name is the expected result. Vector-store storage bills parsed chunks and embeddings by the day. It is unrelated to this sandbox's RAM tier. Using the upload's megabytes to decide between 4 GB and 16 GB applies both units to the wrong column.

5. A top-up does not shrink the five minutes

Reconcile in five columns. First, the product: container session, model tokens, and vector-store storage, kept apart. Second, the container id, and whether this call reused it or opened another. Third, session duration against the 5-minute floor, reading the 20-minute row and the footnote as one price, not two charges. Fourth, the memory tier, fixed at creation. Fifth, the expiry clock: whether a retrieve or a file change moved last_active_at, and whether the files were downloaded before expiry.

Funding the account happens before those columns settle. Swapping stablecoins on-chain into assets that can be paid in does not turn a few dozen seconds into zero, and it does not move a 4 GB container back to 1 GB. When that swap is the step you need, AllSwap does it without an account, and it is non-custodial. A completed swap only means the asset changed hands. The floor, the memory tier, and the model tokens still follow the container that was actually open.