Skip to content

Retrieve container file

containers.files.retrieve(strfile_id, FileRetrieveParams**kwargs) -> FileRetrieveResponse
GET/containers/{container_id}/files/{file_id}

Retrieve Container File

ParametersExpand Collapse
container_id: str
file_id: str
ReturnsExpand Collapse
class FileRetrieveResponse: …
id: str

Unique identifier for the file.

bytes: int

Size of the file in bytes.

container_id: str

The container this file belongs to.

created_at: int

Unix timestamp (in seconds) when the file was created.

object: Literal["container.file"]

The type of this object (container.file).

path: str

Path of the file in the container.

source: str

Source of the file (e.g., user, assistant).

Retrieve container file

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
file = client.containers.files.retrieve(
    file_id="file_id",
    container_id="container_id",
)
print(file.id)
{
  "id": "id",
  "bytes": 0,
  "container_id": "container_id",
  "created_at": 0,
  "object": "container.file",
  "path": "path",
  "source": "source"
}
Returns Examples
{
  "id": "id",
  "bytes": 0,
  "container_id": "container_id",
  "created_at": 0,
  "object": "container.file",
  "path": "path",
  "source": "source"
}