IOpenAIClient.UploadFileAsync

IOpenAIClient.UploadFileAsync method

Uploads a file asynchronously to the OpenAI server.

public Task<FileResponse> UploadFileAsync(string purpose, string fileName, byte[] fileBytes, 
    CancellationToken? cancellationToken = default)
ParameterTypeDescription
purposeStringThe purpose of the file upload, typically describing how the file will be used.
fileNameStringThe name of the file to upload.
fileBytesByte[]The byte array containing the file data.
cancellationTokenNullable`1A token to cancel the operation.

Return Value

A task that represents the asynchronous operation. The task result contains the response from the file upload.

Exceptions

exceptioncondition
AIClientExceptionThrown when the file purpose is null or empty.
AIClientExceptionThrown when the file name is null or empty.

See Also