Files - Delete

Deletes the file with the given file-id. Deletion is also allowed if a file was used, e.g., as training file in a fine-tune job.

DELETE {endpoint}/openai/files/{file-id}?api-version=2024-10-21

URI Parameters

Name In Required Type Description
endpoint
path True

string (url)

Supported Cognitive Services endpoints (protocol and hostname, for example: https://aoairesource.openai.azure.com. Replace "aoairesource" with your Azure OpenAI account name).

file-id
path True

string

The identifier of the file.

api-version
query True

string

The requested API version.

Request Header

Name Required Type Description
api-key True

string

Provide your Cognitive Services Azure OpenAI account key here.

Responses

Name Type Description
200 OK

FileDelete

The file was successfully deleted.

Other Status Codes

ErrorResponse

An error occurred.

Security

api-key

Provide your Cognitive Services Azure OpenAI account key here.

Type: apiKey
In: header

Examples

Deleting a file.

Sample request

DELETE https://aoairesource.openai.azure.com/openai/files/file-181a1cbdcdcf4677ada87f63a0928099?api-version=2024-10-21

Sample response

{
  "object": "file",
  "deleted": true,
  "id": "file-181a1cbdcdcf4677ada87f63a0928099"
}

Definitions

Name Description
Error

Error

ErrorCode

ErrorCode

ErrorResponse

ErrorResponse

FileDelete

FileDelete

InnerError

InnerError

InnerErrorCode

InnerErrorCode

TypeDiscriminator

TypeDiscriminator

Error

Error

Name Type Description
code

ErrorCode

ErrorCode
Error codes as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).

details

Error[]

The error details if available.

innererror

InnerError

InnerError
Inner error as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).

message

string

minLength: 1

The message of this error.

target

string

The location where the error happened if available.

ErrorCode

ErrorCode

Value Description
conflict

The requested operation conflicts with the current resource state.

contentFilter

Image generation failed as a result of our safety system.

fileImportFailed

Import of file failed.

forbidden

The operation is forbidden for the current user/api key.

internalFailure

Internal error. Please retry.

invalidPayload

The request data is invalid for this operation.

itemDoesAlreadyExist

The item does already exist.

jsonlValidationFailed

Validation of jsonl data failed.

notFound

The resource is not found.

quotaExceeded

Quota exceeded.

serviceUnavailable

The service is currently not available.

tooManyRequests

Too many requests. Please retry later.

unauthorized

The current user/api key is not authorized for the operation.

unexpectedEntityState

The operation cannot be executed in the current resource's state.

ErrorResponse

ErrorResponse

Name Type Description
error

Error

Error
Error content as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).

FileDelete

FileDelete

Name Type Description
deleted

boolean

A value indicating whether gets if the file was deleted.

id

string

minLength: 1

The file-id that was deleted.

object

TypeDiscriminator

TypeDiscriminator
Defines the type of an object.

InnerError

InnerError

Name Type Description
code

InnerErrorCode

InnerErrorCode
Inner error codes as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).

innererror

InnerError

InnerError
Inner error as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).

InnerErrorCode

InnerErrorCode

Value Description
invalidPayload

The request data is invalid for this operation.

TypeDiscriminator

TypeDiscriminator

Value Description
batch

This object represents a batch.

file

This object represents a file.

fine_tuning.job

This object represents a fine tune job.

fine_tuning.job.checkpoint

This object represents a checkpoint of a fine tuning job.

fine_tuning.job.event

This object represents an event of a fine tuning job.

list

This object represents a list of other objects.

model

This object represents a model (can be a base model or fine tune job result).

upload

This object represents a file upload.

upload.part

This object represents part of a file upload.