Azure OpenAI Files

API Version: v1

Server: {endpoint}/openai/v1 — Azure AI Foundry Models APIs

Server Variables:

Variable Default Description
endpoint A supported Azure AI Foundry Models APIs endpoint, including protocol and hostname.
For example:
https://westus.api.cognitive.microsoft.com).

Authentication

ApiKeyAuth (API Key)

Pass your API key in the api-key header.

ApiKeyAuth_ (API Key)

Pass your API key in the authorization header.

OAuth2Auth (OAuth 2.0)

Flow: implicit

Authorization URL: https://login.microsoftonline.com/common/oauth2/v2.0/authorize

Scopes:

  • https://cognitiveservices.azure.com/.default

Security Requirements

Endpoints accept any one of the following authentication methods:

  1. ApiKeyAuth
  2. ApiKeyAuth_
  3. OAuth2Auth (scopes: https://cognitiveservices.azure.com/.default)

Create file

POST {endpoint}/openai/v1/files

URI Parameters

Name In Required Type Description
endpoint server Yes string A supported Azure AI Foundry Models APIs endpoint, including protocol and hostname.
For example:
https://westus.api.cognitive.microsoft.com).
api-version query No string
Possible values: v1, preview
The explicit Azure AI Foundry Models API version to use for this request.
v1 if not otherwise specified.

Request Body

Content-Type: multipart/form-data

Name Type Description Required Default
expires_after object Yes
└─ anchor AzureFileExpiryAnchor Yes
└─ seconds integer (int32) Yes
file The File object (not file name) to be uploaded. Yes
purpose enum 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 - evals: Used for eval data sets
Possible values: assistants, batch, fine-tune, evals
Yes

Responses

Status Code: 200

Description: The request has succeeded.

Content-Type Type Description
application/json object
Name Type Description Required Default
bytes integer The size of the file, in bytes. Yes
created_at integer (unixtime) The Unix timestamp (in seconds) for when the file was created. Yes
expires_at integer (unixtime) The Unix timestamp (in seconds) for when the file will expire. No
filename string The name of the file. Yes
id string The file identifier, which can be referenced in the API endpoints. Yes
object enum The object type, which is always file.
Possible values: file
Yes
purpose enum The intended purpose of the file. Supported values are assistants, assistants_output, batch, batch_output, fine-tune and fine-tune-results.
Possible values: assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results, evals
Yes
status enum
Possible values: uploaded, pending, running, processed, error, deleting, deleted
Yes
status_details string (deprecated) Deprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job. No

Response Headers:

Header Type Description
apim-request-id string A request ID used for troubleshooting purposes.

Status Code: default

Description: An unexpected error response.

Content-Type Type Description
application/json object
Name Type Description Required Default
code string or null Yes
inner_error No
message string Yes
param string or null Yes
type string Yes

Response Headers:

Header Type Description
apim-request-id string A request ID used for troubleshooting purposes.

Examples

Example

POST {endpoint}/openai/v1/files?api-version=v1

List files

GET {endpoint}/openai/v1/files

URI Parameters

Name In Required Type Description
endpoint server Yes string A supported Azure AI Foundry Models APIs endpoint, including protocol and hostname.
For example:
https://westus.api.cognitive.microsoft.com).
api-version query No string
Possible values: v1, preview
The explicit Azure AI Foundry Models API version to use for this request.
v1 if not otherwise specified.
purpose query No string
Serialization: explode: false
limit query No integer
Serialization: explode: false
order query No string
Possible values: asc, desc

Serialization: explode: false
after query No string
Serialization: explode: false

Responses

Status Code: 200

Description: The request has succeeded.

Content-Type Type Description
application/json OpenAI.ListFilesResponse

Response Headers:

Header Type Description
apim-request-id string A request ID used for troubleshooting purposes.

Status Code: default

Description: An unexpected error response.

Content-Type Type Description
application/json object
Name Type Description Required Default
code string or null Yes
inner_error No
message string Yes
param string or null Yes
type string Yes

Response Headers:

Header Type Description
apim-request-id string A request ID used for troubleshooting purposes.

Retrieve file

GET {endpoint}/openai/v1/files/{file_id}

URI Parameters

Name In Required Type Description
endpoint server Yes string A supported Azure AI Foundry Models APIs endpoint, including protocol and hostname.
For example:
https://westus.api.cognitive.microsoft.com).
api-version query No string
Possible values: v1, preview
The explicit Azure AI Foundry Models API version to use for this request.
v1 if not otherwise specified.
file_id path Yes string The ID of the file to use for this request.

Responses

Status Code: 200

Description: The request has succeeded.

Content-Type Type Description
application/json object
Name Type Description Required Default
bytes integer The size of the file, in bytes. Yes
created_at integer (unixtime) The Unix timestamp (in seconds) for when the file was created. Yes
expires_at integer (unixtime) The Unix timestamp (in seconds) for when the file will expire. No
filename string The name of the file. Yes
id string The file identifier, which can be referenced in the API endpoints. Yes
object enum The object type, which is always file.
Possible values: file
Yes
purpose enum The intended purpose of the file. Supported values are assistants, assistants_output, batch, batch_output, fine-tune and fine-tune-results.
Possible values: assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results, evals
Yes
status enum
Possible values: uploaded, pending, running, processed, error, deleting, deleted
Yes
status_details string (deprecated) Deprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job. No

Response Headers:

Header Type Description
apim-request-id string A request ID used for troubleshooting purposes.

Status Code: default

Description: An unexpected error response.

Content-Type Type Description
application/json object
Name Type Description Required Default
code string or null Yes
inner_error No
message string Yes
param string or null Yes
type string Yes

Response Headers:

Header Type Description
apim-request-id string A request ID used for troubleshooting purposes.

Delete file

DELETE {endpoint}/openai/v1/files/{file_id}

URI Parameters

Name In Required Type Description
endpoint server Yes string A supported Azure AI Foundry Models APIs endpoint, including protocol and hostname.
For example:
https://westus.api.cognitive.microsoft.com).
api-version query No string
Possible values: v1, preview
The explicit Azure AI Foundry Models API version to use for this request.
v1 if not otherwise specified.
file_id path Yes string The ID of the file to use for this request.

Responses

Status Code: 200

Description: The request has succeeded.

Content-Type Type Description
application/json OpenAI.DeleteFileResponse

Response Headers:

Header Type Description
apim-request-id string A request ID used for troubleshooting purposes.

Status Code: default

Description: An unexpected error response.

Content-Type Type Description
application/json object
Name Type Description Required Default
code string or null Yes
inner_error No
message string Yes
param string or null Yes
type string Yes

Response Headers:

Header Type Description
apim-request-id string A request ID used for troubleshooting purposes.

Download file

GET {endpoint}/openai/v1/files/{file_id}/content

URI Parameters

Name In Required Type Description
endpoint server Yes string A supported Azure AI Foundry Models APIs endpoint, including protocol and hostname.
For example:
https://westus.api.cognitive.microsoft.com).
api-version query No string
Possible values: v1, preview
The explicit Azure AI Foundry Models API version to use for this request.
v1 if not otherwise specified.
file_id path Yes string The ID of the file to use for this request.

Responses

Status Code: 200

Description: The request has succeeded.

Content-Type Type Description
application/octet-stream object

Response Headers:

Header Type Description
apim-request-id string A request ID used for troubleshooting purposes.

Status Code: default

Description: An unexpected error response.

Content-Type Type Description
application/json object
Name Type Description Required Default
code string or null Yes
inner_error No
message string Yes
param string or null Yes
type string Yes

Response Headers:

Header Type Description
apim-request-id string A request ID used for troubleshooting purposes.

Components

AzureAIFoundryModelsApiVersion

Property Value
Type string
Values v1
preview

AzureFileExpiryAnchor

Property Value
Type string
Values created_at

OpenAI.CreateFileRequest

Name Type Description Required Default
expires_after object Yes
└─ anchor AzureFileExpiryAnchor Yes
└─ seconds integer (int32) Yes
file The File object (not file name) to be uploaded. Yes
purpose enum 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 - evals: Used for eval data sets
Possible values: assistants, batch, fine-tune, evals
Yes

OpenAI.DeleteFileResponse

Name Type Description Required Default
deleted boolean Yes
id string Yes
object enum
Possible values: file
Yes

OpenAI.ListFilesResponse

Name Type Description Required Default
data array of OpenAI.OpenAIFile Yes
first_id string Yes
has_more boolean Yes
last_id string Yes
object string Yes

OpenAI.OpenAIFile

OpenAIFile

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

Name Type Description Required Default
bytes integer The size of the file, in bytes. Yes
created_at integer (unixtime) The Unix timestamp (in seconds) for when the file was created. Yes
expires_at integer (unixtime) The Unix timestamp (in seconds) for when the file will expire. No
filename string The name of the file. Yes
id string The file identifier, which can be referenced in the API endpoints. Yes
object enum The object type, which is always file.
Possible values: file
Yes
purpose enum The intended purpose of the file. Supported values are assistants, assistants_output, batch, batch_output, fine-tune and fine-tune-results.
Possible values: assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results, evals
Yes
status enum
Possible values: uploaded, pending, running, processed, error, deleting, deleted
Yes
status_details string (deprecated) Deprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job. No