View Source OpenAi.Files (OpenAI REST API Client v1.0.1)

Provides API endpoints related to files

Summary

Functions

Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB.

Returns the contents of the specified file.

Returns a list of files.

Returns information about a specific file.

Functions

Link to this function

create_file(body, opts \\ [])

View Source
@spec create_file(body :: OpenAi.File.CreateRequest.t(), opts :: keyword()) ::
  {:ok, OpenAi.File.t()} | {:error, OpenAi.Error.error()}

Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB.

The Assistants API supports files up to 2 million tokens and of specific file types. See the Assistants Tools guide for details.

The Fine-tuning API only supports .jsonl files. The input also has certain required formats for fine-tuning chat or completions models.

The Batch API only supports .jsonl files up to 200 MB in size. The input also has a specific required format.

Please contact us if you need to increase these storage limits.

Link to this function

delete_file(file_id, opts \\ [])

View Source
@spec delete_file(file_id :: String.t(), opts :: keyword()) ::
  {:ok, OpenAi.File.DeleteResponse.t()} | {:error, OpenAi.Error.error()}

Delete a file.

Link to this function

download_file(file_id, opts \\ [])

View Source
@spec download_file(file_id :: String.t(), opts :: keyword()) ::
  {:ok, String.t()} | {:error, OpenAi.Error.error()}

Returns the contents of the specified file.

@spec list_files(opts :: keyword()) ::
  {:ok, OpenAi.File.ListResponse.t()} | {:error, OpenAi.Error.error()}

Returns a list of files.

Options

  • purpose: Only return files with the given purpose.

  • limit: A limit on the number of objects to be returned. Limit can range between 1 and 10,000, and the default is 10,000.

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

  • 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.

Link to this function

retrieve_file(file_id, opts \\ [])

View Source
@spec retrieve_file(file_id :: String.t(), opts :: keyword()) ::
  {:ok, OpenAi.File.t()} | {:error, OpenAi.Error.error()}

Returns information about a specific file.