Skip to content

Create container file

containers.files.create(container_id, **kwargs) -> FileCreateResponse { id, bytes, container_id, 4 more }
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: String
file: FileInput

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

file_id: String

Name of the file to create.

ReturnsExpand Collapse
class FileCreateResponse { id, bytes, container_id, 4 more }
id: String

Unique identifier for the file.

bytes: Integer

Size of the file in bytes.

container_id: String

The container this file belongs to.

created_at: Integer

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

object: :"container.file"

The type of this object (container.file).

path: String

Path of the file in the container.

source: String

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

Create container file

require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

file = openai.containers.files.create("container_id")

puts(file)
{
  "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"
}