FilesResource class

Resource for file operations.

Files are used to upload documents that can be used with the Assistants API, Fine-tuning, and Batch API.

Access this resource through OpenAIClient.files.

Example

// Upload a file
final file = await client.files.upload(
  bytes: fileBytes,
  filename: 'training.jsonl',
  purpose: FilePurpose.fineTune,
);

// List files
final files = await client.files.list();
Inheritance

Constructors

FilesResource({required OpenAIConfig config, required Client httpClient, required InterceptorChain interceptorChain, required RequestBuilder requestBuilder, void ensureNotClosed()?})
Creates a FilesResource.

Properties

config OpenAIConfig
Client configuration.
finalinherited
ensureNotClosed → void Function()?
Callback to check if the client has been closed.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
httpClient → Client
HTTP client for making requests.
finalinherited
interceptorChain InterceptorChain
Interceptor chain for request/response processing.
finalinherited
requestBuilder → RequestBuilder
Request builder for constructing HTTP requests.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
streamClientFactory → Client Function()?
Factory for creating dedicated HTTP clients for streaming requests.
finalinherited

Methods

delete(String fileId) Future<DeleteFileResponse>
Deletes a file.
list({FilePurpose? purpose, int? limit, String? order, String? after}) Future<FileList>
Lists all files that belong to the user's organization.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
retrieve(String fileId) Future<FileObject>
Retrieves information about a specific file.
retrieveContent(String fileId) Future<String>
Retrieves the content of a file.
toString() String
A string representation of this object.
inherited
upload({required List<int> bytes, required String filename, required FilePurpose purpose}) Future<FileObject>
Uploads a file to OpenAI.

Operators

operator ==(Object other) bool
The equality operator.
inherited