> ## Documentation Index
> Fetch the complete documentation index at: https://openrouter.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Containers

> Containers endpoints

## Overview

Containers endpoints

### Available Operations

* [list\_container\_files](#list_container_files) - List container files
* [get\_container\_file](#get_container_file) - Retrieve a container file
* [download\_container\_file\_content](#download_container_file_content) - Download container file content

## list\_container\_files

Lists the files under a sandbox session prefix, in lexicographic path order. A restarted session is a separate container with its own session id. Paginate with `limit` and `after` (pass the previous page’s `last_id`); `has_more: true` always means the next page is fetchable that way.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.containers.list_container_files(session_id="sess-abc123", limit=100)

    # Handle response
    print(res)

```

### Parameters

| Parameter                  | Type                                                                | Required             | Description                                                                                                                                                 | Example                    |
| -------------------------- | ------------------------------------------------------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| `session_id`               | *str*                                                               | :heavy\_check\_mark: | The sandbox session id, exactly as stored — a restarted session has its own `-r<nonce>`-suffixed id.                                                        | sess-abc123                |
| `http_referer`             | *Optional\[str]*                                                    | :heavy\_minus\_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br />This is used to track API usage per application.<br /> |                            |
| `x_open_router_title`      | *Optional\[str]*                                                    | :heavy\_minus\_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br />                                                          |                            |
| `x_open_router_categories` | *Optional\[str]*                                                    | :heavy\_minus\_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br />                                                 |                            |
| `limit`                    | *Optional\[int]*                                                    | :heavy\_minus\_sign: | Maximum number of files to return (1-1000). Defaults to 100 when absent.                                                                                    | 100                        |
| `after`                    | *Optional\[str]*                                                    | :heavy\_minus\_sign: | Forward cursor: a container file id from a previous page (typically `last_id`); listing resumes strictly after that file.                                   | cfile\_b3V0L3JlcG9ydC5jc3Y |
| `retries`                  | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | :heavy\_minus\_sign: | Configuration to override the default retry behavior of the client.                                                                                         |                            |

### Response

**[components.ContainerFileListResponse](../../components/containerfilelistresponse.mdx)**

### Errors

| Error Type                             | Status Code | Content Type     |
| -------------------------------------- | ----------- | ---------------- |
| errors.BadRequestResponseError         | 400         | application/json |
| errors.UnauthorizedResponseError       | 401         | application/json |
| errors.ForbiddenResponseError          | 403         | application/json |
| errors.TooManyRequestsResponseError    | 429         | application/json |
| errors.InternalServerResponseError     | 500         | application/json |
| errors.ServiceUnavailableResponseError | 503         | application/json |
| errors.OpenRouterDefaultError          | 4XX, 5XX    | \*/\*            |

## get\_container\_file

Returns the metadata of a single file under a sandbox session prefix.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.containers.get_container_file(session_id="sess-abc123", file_id="cfile_b3V0L3JlcG9ydC5jc3Y")

    # Handle response
    print(res)

```

### Parameters

| Parameter                  | Type                                                                | Required             | Description                                                                                                                                                 | Example                    |
| -------------------------- | ------------------------------------------------------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| `session_id`               | *str*                                                               | :heavy\_check\_mark: | The sandbox session id, exactly as stored — a restarted session has its own `-r<nonce>`-suffixed id.                                                        | sess-abc123                |
| `file_id`                  | *str*                                                               | :heavy\_check\_mark: | Container file id (`cfile_` + base64url of the file path).                                                                                                  | cfile\_b3V0L3JlcG9ydC5jc3Y |
| `http_referer`             | *Optional\[str]*                                                    | :heavy\_minus\_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br />This is used to track API usage per application.<br /> |                            |
| `x_open_router_title`      | *Optional\[str]*                                                    | :heavy\_minus\_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br />                                                          |                            |
| `x_open_router_categories` | *Optional\[str]*                                                    | :heavy\_minus\_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br />                                                 |                            |
| `retries`                  | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | :heavy\_minus\_sign: | Configuration to override the default retry behavior of the client.                                                                                         |                            |

### Response

**[components.ContainerFile](../../components/containerfile.mdx)**

### Errors

| Error Type                             | Status Code | Content Type     |
| -------------------------------------- | ----------- | ---------------- |
| errors.BadRequestResponseError         | 400         | application/json |
| errors.UnauthorizedResponseError       | 401         | application/json |
| errors.ForbiddenResponseError          | 403         | application/json |
| errors.NotFoundResponseError           | 404         | application/json |
| errors.TooManyRequestsResponseError    | 429         | application/json |
| errors.InternalServerResponseError     | 500         | application/json |
| errors.ServiceUnavailableResponseError | 503         | application/json |
| errors.OpenRouterDefaultError          | 4XX, 5XX    | \*/\*            |

## download\_container\_file\_content

Streams the raw bytes of a file under a sandbox session prefix.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.containers.download_container_file_content(session_id="sess-abc123", file_id="cfile_b3V0L3JlcG9ydC5jc3Y")

    # Handle response
    print(res)

```

### Parameters

| Parameter                  | Type                                                                | Required             | Description                                                                                                                                                 | Example                    |
| -------------------------- | ------------------------------------------------------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| `session_id`               | *str*                                                               | :heavy\_check\_mark: | The sandbox session id, exactly as stored — a restarted session has its own `-r<nonce>`-suffixed id.                                                        | sess-abc123                |
| `file_id`                  | *str*                                                               | :heavy\_check\_mark: | Container file id (`cfile_` + base64url of the file path).                                                                                                  | cfile\_b3V0L3JlcG9ydC5jc3Y |
| `http_referer`             | *Optional\[str]*                                                    | :heavy\_minus\_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br />This is used to track API usage per application.<br /> |                            |
| `x_open_router_title`      | *Optional\[str]*                                                    | :heavy\_minus\_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br />                                                          |                            |
| `x_open_router_categories` | *Optional\[str]*                                                    | :heavy\_minus\_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.<br />                                                 |                            |
| `retries`                  | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | :heavy\_minus\_sign: | Configuration to override the default retry behavior of the client.                                                                                         |                            |

### Response

**[httpx.Response](../../models/.mdx)**

### Errors

| Error Type                             | Status Code | Content Type     |
| -------------------------------------- | ----------- | ---------------- |
| errors.BadRequestResponseError         | 400         | application/json |
| errors.UnauthorizedResponseError       | 401         | application/json |
| errors.ForbiddenResponseError          | 403         | application/json |
| errors.NotFoundResponseError           | 404         | application/json |
| errors.TooManyRequestsResponseError    | 429         | application/json |
| errors.InternalServerResponseError     | 500         | application/json |
| errors.ServiceUnavailableResponseError | 503         | application/json |
| errors.OpenRouterDefaultError          | 4XX, 5XX    | \*/\*            |
