Code librariesReviewed · OpenRouter

OpenRouter Python SDK: Containers module

This OpenRouter Python SDK reference page is for Python developers who need to list, inspect, download or preserve files in existing sandbox containers, such as files that an AI model's bash or shell tool created. It documents four calls on open_router.containers: list_container_files, get_container_file, download_container_file_content and promote_container_file. Every example passes an OpenRouter API key to the client. The main catch is that the page does not explain how containers are created, how long they last or what the calls cost.

Researched 15 Nov 2026

In short.

This OpenRouter Python SDK reference page is for Python developers who need to list, inspect, download or preserve files in existing sandbox containers. Its main catch is that it covers only four file operations. It does not explain how containers are created, how long they last or what the calls cost. It does document some limits. Each listing request returns no more files than the limit parameter allows. That parameter accepts 1 to 1000 and defaults to 100, and a page can hold fewer files or none at all. A listing page can also stop at a scan bound on hidden bookkeeping objects, and promoted copies count against the workspace's storage quota. Quota sizes, rate-limit values and container lifetime are unknown. The four operations are list_container_files (paged listing in lexicographic path order), get_container_file (metadata for one file), download_container_file_content (raw bytes returned as an httpx.Response) and promote_container_file (a copy into the workspace's durable document storage, counted against the storage quota). Each operation has a parameter table, a response type and a list of HTTP error classes. Nothing was executed. This report describes the documentation only, and no behaviour was tested.

Researched and written by an AI model and checked by a second AI model. How it works

The selected scope is the complete OpenRouter Python SDK Containers documentation page at [https://openrouter.ai/docs/client-sdks/python/sdks/containers/README.md]. The page carries no licence, copyright or terms notice. Linked pages were excluded, including the response model pages (ContainerFileListResponse, ContainerFile, FileResponse), the RetryConfig page and the documentation index at [https://openrouter.ai/docs/llms.txt]. No SDK source code, licence file, package metadata, pricing page or changelog was reviewed. Nothing was executed, so all behaviour described is what the page claims, not something observed. Cost, licence, container lifetime, quota sizes, rate-limit values, SDK version and supported Python versions are unknown from this evidence.

The overview

What this resource is

This is the reference page for the containers module of the OpenRouter Python SDK. The page is titled Containers, with the subtitle Containers endpoints, and sits under the client-sdks/python/sdks/containers path of the OpenRouter documentation. It describes four methods on the containers attribute of the OpenRouter client: list_container_files, get_container_file, download_container_file_content and promote_container_file.

The resource is the documentation page, not the SDK source code. The SDK is imported with from openrouter import OpenRouter. The page gives no package name for installation, no version number and no repository link, so those details are unknown from this evidence.

Overall assessment

For its narrow purpose the page is specific and usable. Every operation has a runnable-looking example, a parameter table with required and optional markers, a named response type and an error table listing status codes. The notes on identifiers and pagination are unusually detailed. They explain how the cursor and the container id behave in edge cases, including restarted sessions.

The page is deliberately narrow. It assumes a container already exists and that the reader has a container id from a bash or shell tool result. It does not explain how to start such a tool run, how long containers or their files persist, or what any call costs. Treat it as a reference for retrieving and keeping files, not as an introduction to OpenRouter's tool execution. No behaviour was checked by running code, so everything here reflects what the documentation claims.

Who it is for

The audience is Python developers who already use OpenRouter and whose model runs include a bash or shell tool that writes files, such as a generated report, a CSV or build output. The page says the container id is the canonical id returned in bash/shell tool results, so this module is the documented way to collect what those tool runs produced.

It is a poor fit for people who do not use Python (the page covers only the Python SDK), people who do not use OpenRouter, and beginners looking for a first-steps tutorial. A beginner can follow the examples but first needs an existing container id and an OpenRouter API key, which every example passes to the client. The page does not explain how to obtain either. Any account-provisioning requirements are unknown from this page.

What it can do

list_container_files lists the files in a container in lexicographic path order. It takes limit (1 to 1000, default 100) and after, a forward cursor. The page says has_more: true always means the next page can be fetched by passing the previous page's last_id as after. It also warns that last_id is usually the last listed file's id. When a page stops at the per-request scan bound on hidden bookkeeping objects, last_id names the scan position instead. In that case it may not appear in data, and data can be empty. Such a cursor may name a directory-marker path ending in a slash that was never listed as a file, and the page says such cursors are accepted.

get_container_file returns the metadata of one file, given the container id and a file id. download_container_file_content streams the raw bytes of a file and is documented to return an httpx.Response.

promote_container_file copies a file from the container's sandbox prefix into the workspace's durable document storage, so the file outlives the container. It returns the new document in the Files API shape, with a durable file id in the documents namespace. The page notes that, unlike a direct upload, promoted files are downloadable. The page documents no way to upload, edit, delete or create files in a container through this module.

Using it

What you need

Every example passes an OpenRouter API key to the client as api_key and reads it from the OPENROUTER_API_KEY environment variable with os.getenv("OPENROUTER_API_KEY", ""). That environment variable is simply how the examples load the key. The page does not say it is required or that other ways of supplying the key are unsupported. You also need Python, with the SDK installed so that the openrouter module and its OpenRouter class can be imported. The page does not state the supported Python versions or the install command.

You also need a container id exactly as returned in a bash or shell tool result. The page warns that a restarted session is a separate container with its own id, carrying a -r<nonce> suffix. A session-derived id is always sess_ plus the sanitized session key, which is not necessarily the raw session id you sent. File ids take the form cfile_ followed by the base64url encoding of the file path. You can get them from a listing, or build them yourself from a known path. Decoding the page's example id by hand gives out/report.csv.

Account tier, credit balance, workspace setup and any permission needed for promotion are not stated. The 403 error class suggests some requests can be forbidden, but the page does not say why.

How it works

The module is a Python SDK interface to OpenRouter's container endpoints. Its implementation architecture is unknown from this page. The page does not give the HTTP methods or URLs, so how each method maps to the web API is also unknown. The client is used as a context manager (with OpenRouter(...) as open_router), and the operations are synchronous calls on open_router.containers. This page shows no asynchronous variants, and it does not establish whether any exist.

Returned objects are typed: components.ContainerFileListResponse for listing, components.ContainerFile for metadata, components.FileResponse for a promoted document, and httpx.Response for downloads. Errors are raised as named classes. All four operations list 400, 401, 403, 429, 500 and 503. Get, download and promote add 404, and promote also adds 413 (payload too large) and 499 (client closed request). A catch-all errors.OpenRouterDefaultError covers other 4XX and 5XX codes.

Every method also accepts an optional retries argument (utils.RetryConfig) to override the client's default retry behaviour. The page links to the RetryConfig reference but does not state the default retry policy.

Setup

The page contains no installation section. Based on the examples, setup involves three steps. First, make the SDK available so that from openrouter import OpenRouter works. Second, give the client an OpenRouter API key; the examples read it from the OPENROUTER_API_KEY environment variable, but the page does not say this is the only way. Third, obtain a container id from a bash or shell tool result.

Three optional client arguments appear in every example: http_referer, x_open_router_title and x_open_router_categories. According to the page, http_referer should be the app's URL and serves as the primary identifier for rankings and per-app usage tracking. x_open_router_title sets the app's display name in OpenRouter's dashboard. x_open_router_categories is a comma-separated list such as cli-agent,cloud-agent, used for marketplace rankings. The examples fill all three with the placeholder <value>. The parameter tables mark them as optional, so replace the placeholders with real values or leave them out. Be aware that these values identify your application to OpenRouter.

Worked example

Here is a simplified version of the page's listing example that keeps the optional limit=100 argument: with OpenRouter(api_key=os.getenv("OPENROUTER_API_KEY", "")) as open_router: res = open_router.containers.list_container_files(container_id="sess_abc123", limit=100). The page then prints res. Replace sess_abc123 with the actual container id from your bash or shell tool result. The page's full example also passes http_referer, x_open_router_title and x_open_router_categories, all set to the placeholder <value>. These are marked optional, so replace them with real values for your application or omit them.

Here is a plausible workflow, assembled from the documented pieces and not run. List the files in a container and take a file id from the listing (the page's example id is cfile_b3V0L3JlcG9ydC5jc3Y). Call get_container_file to check its metadata, call download_container_file_content to retrieve the bytes, and call promote_container_file if the file must survive after the container is gone. To page through a long listing, pass the response's last_id as after in the next call and keep going while has_more is true. A page that ended at the scan bound can have empty data, so the loop should rely on has_more and last_id, not on whether data has entries.

Assessment & evidence

Limitations and unknowns

The page does not say how a container is created, how long a container and its files persist, how large files may be, or what limit triggers the 413 error on promotion. It gives no rate limits behind the 429 error. It also does not say how to switch on the bash or shell tool in a model request.

The page names the response models ContainerFile, ContainerFileListResponse and FileResponse and links to their references, but it does not supply their field schemas. Likewise, it links to RetryConfig without giving the default retry policy. It does not demonstrate how to consume the httpx.Response from a download, for example by streaming to disk; every example only prints the result. No asynchronous usage, error-handling example or retry configuration example is shown.

The documented pagination edge cases show that listing can be subtle. A page can be empty yet still have more results, and the resume cursor may name a position that never appears in data. Code that assumes otherwise could stop early. Nothing here was run, so the real behaviour of these calls has not been checked.

Reasoning behind this assessment

The assessment rests on what the page states. The operations, parameters, response types and error classes are repeated consistently across sections, and the container id rules, file id format and promotion behaviour agree between the descriptions and the parameter tables. That consistency makes the page a dependable guide to what the documentation says the SDK exposes.

The assessment is limited to retrieving and preserving files because that is all the page documents. The page says promoted files outlive the container and, unlike direct uploads, are downloadable. That suggests the intended pattern is to promote anything you need to keep, but this is an inference from the description, not a tested result.

Alternatives

The page does not compare itself with other options, so no alternative is assessed. Its path suggests it is the Python-specific section of OpenRouter's SDK documentation. Whether OpenRouter documents the same endpoints for other languages or as a raw HTTP API was not checked, and this page gives no HTTP details.

Anyone not using OpenRouter's container tooling would need some other way to handle file output from model tool runs. The evidence does not describe any such way, so none is recommended here.

Evidence base

This report is based on the OpenRouter Python SDK Containers reference page at [https://openrouter.ai/docs/client-sdks/python/sdks/containers/README.md]. That page documents the four container file operations, with their example calls, parameter tables, response types and error tables, plus notes on container ids, file ids, pagination and promotion. The descriptions of documented behaviour in this report are taken from those contents.

Some parts of this report are interpretation or suggestion rather than statements from the page. These are the overall assessment, the assembled workflow in the worked example, the suggested next steps and the hand-decoding of the example file id into out/report.csv. None of the documented behaviour has been observed in practice, because no code was run. No SDK source, package metadata, changelog, licence file, benchmark, test result or runtime output was reviewed.

Access & freshness

Costs

The page states no price for any container operation and gives no free tier, rate-limit figure or credit requirement. Whether these calls are billed separately, included with other usage or free is unknown from this evidence.

The one cost-related statement is that a promoted copy counts against the workspace's storage quota. The quota size is not stated, and what happens when the quota is exhausted is unknown. Separately, promote_container_file lists a PayloadTooLargeResponseError (413) among its errors, but the page does not explain what size or condition triggers it. Whether files held in a sandbox container incur any storage cost is also unknown.

Rights and licence

The page contains no licence, copyright notice or terms of use for the SDK or for the documentation. The SDK's licence, and whether the documentation text may be redistributed, are therefore unknown from this evidence.

Promotion copies files into workspace document storage; ownership, privacy and governing terms are not established here. The page also does not say how long container contents are retained.

Freshness

The page was captured on 15 November 2026 (2026-11-15T13:31:37.994Z). It shows no publication date, last-updated date, SDK version or changelog, so the evidence cannot show how current it is relative to the released SDK. The page begins with a pointer to OpenRouter's documentation index at [https://openrouter.ai/docs/llms.txt], which suggests the documentation is maintained as a set. That index was not reviewed.

The page does not state a beta status, deprecation status or any stability level. Check the live page before relying on these details.

Suggested next steps

Before building on this module, confirm the SDK's install name, version and licence from its package or repository, since the page gives none. Also check OpenRouter's pricing and quota documentation for container operations and document storage. Then look for the page that explains how to create a container-backed bash or shell tool run and how long its files persist.

When writing code, take the container id from the tool result rather than constructing it, because restarted sessions get a suffixed id. Page with has_more and last_id, not with whether data is empty. Promote any file you need after the container ends, and handle the documented error classes, especially 404, 413 and 429. Try everything on a small non-sensitive container first, since this report did not run any of it.

Evidence for this report

selected-page.txtselected · checked 2026-11-15