Skip to content

Files

List files
client.Files.List(ctx, query) (*CursorPage[FileObject], error)
GET/files
Upload file
client.Files.New(ctx, body) (*FileObject, error)
POST/files
Delete file
client.Files.Delete(ctx, fileID) (*FileDeleted, error)
DELETE/files/{file_id}
Retrieve file
client.Files.Get(ctx, fileID) (*FileObject, error)
GET/files/{file_id}
Retrieve file content
client.Files.Content(ctx, fileID) (*Response, error)
GET/files/{file_id}/content
ModelsExpand Collapse
type FileContent string
type FileDeleted struct{…}
ID string
Deleted bool
Object File
type FileObject struct{…}

The File object represents a document that has been uploaded to OpenAI.

ID string

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

Bytes int64

The size of the file, in bytes.

CreatedAt int64

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

Filename string

The name of the file.

Object File

The object type, which is always file.

Purpose FileObjectPurpose

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

Accepts one of the following:
const FileObjectPurposeAssistants FileObjectPurpose = "assistants"
const FileObjectPurposeAssistantsOutput FileObjectPurpose = "assistants_output"
const FileObjectPurposeBatch FileObjectPurpose = "batch"
const FileObjectPurposeBatchOutput FileObjectPurpose = "batch_output"
const FileObjectPurposeFineTune FileObjectPurpose = "fine-tune"
const FileObjectPurposeFineTuneResults FileObjectPurpose = "fine-tune-results"
const FileObjectPurposeVision FileObjectPurpose = "vision"
const FileObjectPurposeUserData FileObjectPurpose = "user_data"
DeprecatedStatus FileObjectStatus

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

Accepts one of the following:
const FileObjectStatusUploaded FileObjectStatus = "uploaded"
const FileObjectStatusProcessed FileObjectStatus = "processed"
const FileObjectStatusError FileObjectStatus = "error"
ExpiresAt int64optional

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

DeprecatedStatusDetails stringoptional

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

type FilePurpose 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
Accepts one of the following:
const FilePurposeAssistants FilePurpose = "assistants"
const FilePurposeBatch FilePurpose = "batch"
const FilePurposeFineTune FilePurpose = "fine-tune"
const FilePurposeVision FilePurpose = "vision"
const FilePurposeUserData FilePurpose = "user_data"
const FilePurposeEvals FilePurpose = "evals"