SpyBara
Go Premium

java/resources/containers/subresources/files/index.md 2026-07-10 23:02 UTC to 2026-07-12 06:58 UTC

7 added, 5 removed.

2026
Wed 15 02:58 Tue 14 06:58 Mon 13 15:59 Sun 12 06:58 Fri 10 23:02 Thu 9 20:58 Tue 7 08:02

Files

List container files

FileListPage containers().files().list(FileListParamsparams = FileListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())

get /containers/{container_id}/files

List Container files

Parameters

  • FileListParams params

    • Optional<String> containerId

    • Optional<String> after

      A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

    • Optional<Long> limit

      A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

    • Optional<Order> order

      Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

      • ASC("asc")

      • DESC("desc")

Returns

  • class FileListResponse:

    • 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

      The type of this object (container.file).

      • CONTAINER_FILE("container.file")
    • String path

      Path of the file in the container.

    • String source

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

Example

package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.containers.files.FileListPage;
import com.openai.models.containers.files.FileListParams;

public final class Main {
    private Main() {}

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

        FileListPage page = client.containers().files().list("container_id");
    }
}

Response

{
  "data": [
    {
      "id": "id",
      "bytes": 0,
      "container_id": "container_id",
      "created_at": 0,
      "object": "container.file",
      "path": "path",
      "source": "source"
    }
  ],
  "first_id": "first_id",
  "has_more": true,
  "last_id": "last_id",
  "object": "list"
}

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.

Parameters

  • FileCreateParams params

    • Optional<String> containerId

    • Optional<String> file

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

    • Optional<String> fileId

      Name of the file to create.

Returns

  • 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

      The type of this object (container.file).

      • CONTAINER_FILE("container.file")
    • String path

      Path of the file in the container.

    • String source

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

Example

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");
    }
}

Response

{
  "id": "id",
  "bytes": 0,
  "container_id": "container_id",
  "created_at": 0,
  "object": "container.file",
  "path": "path",
  "source": "source"
}

Retrieve container file

FileRetrieveResponse containers().files().retrieve(FileRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())

get /containers/{container_id}/files/{file_id}

Retrieve Container File

Parameters

  • FileRetrieveParams params

    • String containerId

    • Optional<String> fileId

Returns

  • class FileRetrieveResponse:

    • 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

      The type of this object (container.file).

      • CONTAINER_FILE("container.file")
    • String path

      Path of the file in the container.

    • String source

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

Example

package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.containers.files.FileRetrieveParams;
import com.openai.models.containers.files.FileRetrieveResponse;

public final class Main {
    private Main() {}

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

        FileRetrieveParams params = FileRetrieveParams.builder()
            .containerId("container_id")
            .fileId("file_id")
            .build();
        FileRetrieveResponse file = client.containers().files().retrieve(params);
    }
}

Response

{
  "id": "id",
  "bytes": 0,
  "container_id": "container_id",
  "created_at": 0,
  "object": "container.file",
  "path": "path",
  "source": "source"
}

Delete a container file

containers().files().delete(FileDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())

delete /containers/{container_id}/files/{file_id}

Delete Container File

Parameters

  • FileDeleteParams params

    • String containerId

    • Optional<String> fileId

Example

package com.openai.example;

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

public final class Main {
    private Main() {}

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

        FileDeleteParams params = FileDeleteParams.builder()
            .containerId("container_id")
            .fileId("file_id")
            .build();
        client.containers().files().delete(params);
    }
}

Content

Retrieve container file content

HttpResponse containers().files().content().retrieve(ContentRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())

get /containers/{container_id}/files/{file_id}/content

Retrieve Container File Content

Parameters

  • ContentRetrieveParams params

    • String containerId

    • Optional<String> fileId

Example

package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.core.http.HttpResponse;
import com.openai.models.containers.files.content.ContentRetrieveParams;

public final class Main {
    private Main() {}

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

        ContentRetrieveParams params = ContentRetrieveParams.builder()
            .containerId("container_id")
            .fileId("file_id")
            .build();
        HttpResponse content = client.containers().files().content().retrieve(params);
    }
}