Skip to content

Create container file

FileCreateResponse containers().files().create(FileCreateParamsparams = FileCreateParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
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
FileCreateParams params
Optional<String> containerId
Optional<InputStream> file

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

Optional<String> fileId

Name of the file to create.

ReturnsExpand Collapse
class FileCreateResponse:
String id

Unique identifier for the file.

long bytes

Size of the file in bytes.

String containerId

The container this file belongs to.

long createdAt

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

JsonValue; object_ "container.file"constant"container.file"constant

The type of this object (container.file).

String path

Path of the file in the container.

String source

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

Create container file

package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.containers.files.FileCreateParams;
import com.openai.models.containers.files.FileCreateResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        FileCreateResponse file = client.containers().files().create("container_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"
}