Skip to content

Create container file

containers.files.create(strcontainer_id, FileCreateParams**kwargs) -> FileCreateResponse
POST/containers/{container_id}/files

Create a Container File

You can send either a multipart/form-data request with the raw file content, or a JSON request with a file ID.

ParametersExpand Collapse
container_id: str
file: Optional[FileTypes]

The File object (not file name) to be uploaded.

file_id: Optional[str]

Name of the file to create.

ReturnsExpand Collapse
class FileCreateResponse: …
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).

Create 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.create(
    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"
}