Skip to content
Primary navigation

Files

Files are used to upload documents that can be used with features like Assistants and Fine-tuning.

resource openai_file

required Expand Collapse
file: String

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

purpose: String

The intended purpose of the uploaded file. One of:

  • assistants: Used in the Assistants API
  • batch: Used in the Batch API
  • fine-tune: Used for fine-tuning
  • vision: Images used for vision fine-tuning
  • user_data: Flexible file type for any purpose
  • evals: Used for eval data sets
optional Expand Collapse
expires_after?: Attributes

The expiration policy for a file. By default, files with purpose=batch expire after 30 days and all other files are persisted until they are manually deleted.

anchor: String

Anchor timestamp after which the expiration policy applies. Supported anchors: created_at.

seconds: Int64

The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).

computed Expand Collapse
id: String

The file identifier, which can be referenced in the API endpoints.

bytes: Int64

The size of the file, in bytes.

created_at: Int64

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

expires_at: Int64

The Unix timestamp (in seconds) for when the file will expire.

filename: String

The name of the file.

object: String

The object type, which is always file.

Deprecatedstatus: String

Deprecated. The current status of the file, which can be either uploaded, processed, or error.

Deprecatedstatus_details: String

Deprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job.

openai_file

resource "openai_file" "example_file" {
  file = "Example data"
  purpose = "assistants"
  expires_after = {
    anchor = "created_at"
    seconds = 3600
  }
}

data openai_file

optional Expand Collapse
file_id?: String
find_one_by?: Attributes
order?: String

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

purpose?: String

Only return files with the given purpose.

computed Expand Collapse
id: String
bytes: Int64

The size of the file, in bytes.

created_at: Int64

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

expires_at: Int64

The Unix timestamp (in seconds) for when the file will expire.

filename: String

The name of the file.

object: String

The object type, which is always file.

purpose: String

The intended purpose of the file. Supported values are assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results, vision, and user_data.

Deprecatedstatus: String

Deprecated. The current status of the file, which can be either uploaded, processed, or error.

Deprecatedstatus_details: String

Deprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job.

openai_file

data "openai_file" "example_file" {
  file_id = "file_id"
}

data openai_files

optional Expand Collapse
purpose?: String

Only return files with the given purpose.

order?: String

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

max_items?: Int64

Max items to fetch, default: 1000

computed Expand Collapse
items: List[Attributes]

The items returned by the data source

id: String

The file identifier, which can be referenced in the API endpoints.

bytes: Int64

The size of the file, in bytes.

created_at: Int64

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

filename: String

The name of the file.

object: String

The object type, which is always file.

purpose: String

The intended purpose of the file. Supported values are assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results, vision, and user_data.

Deprecatedstatus: String

Deprecated. The current status of the file, which can be either uploaded, processed, or error.

expires_at: Int64

The Unix timestamp (in seconds) for when the file will expire.

Deprecatedstatus_details: String

Deprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job.

openai_files

data "openai_files" "example_files" {
  purpose = "purpose"
}