Files - Upload
Creates a new file entity by uploading data from a local machine. Uploaded files can, for example, be used for training or evaluating fine-tuned models.
POST {endpoint}/openai/files?api-version=2023-05-15
URI Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
|
file
|
formData | True |
file |
Gets or sets the file to upload into Azure OpenAI. |
|
purpose
|
formData | True |
The intended purpose of the uploaded documents. Use "fine-tune" for fine-tuning. This allows us to validate the format of the uploaded file. |
|
|
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). |
|
api-version
|
query | True |
string |
The requested API version. |
Request Header
Media Types: "multipart/form-data"
| Name | Required | Type | Description |
|---|---|---|---|
| api-key | True |
string |
Provide your Cognitive Services Azure OpenAI account key here. |
Responses
| Name | Type | Description |
|---|---|---|
| 201 Created |
The file has been successfully created. Headers Location: string |
|
| Other Status Codes |
An error occurred. |
Security
api-key
Provide your Cognitive Services Azure OpenAI account key here.
Type:
apiKey
In:
header
Examples
Upload a file.
Sample request
POST https://aoairesource.openai.azure.com/openai/files?api-version=2023-05-15
Sample response
location: https://aoairesource.openai.azure.com/openai/files/file-181a1cbdcdcf4677ada87f63a0928099
{
"purpose": "fine-tune",
"filename": "puppy.jsonl",
"id": "file-181a1cbdcdcf4677ada87f63a0928099",
"status": "notRunning",
"created_at": 1646126127,
"updated_at": 1646127311,
"object": "file"
}
Definitions
| Name | Description |
|---|---|
| Error |
Error |
|
Error |
ErrorCode |
|
Error |
ErrorResponse |
| File |
File |
|
File |
FileStatistics |
|
Inner |
InnerError |
|
Inner |
InnerErrorCode |
| Purpose |
Purpose |
| State |
State |
|
Type |
TypeDiscriminator |
Error
Error
| Name | Type | Description |
|---|---|---|
| code |
ErrorCode |
|
| details |
Error[] |
The error details if available. |
| innererror |
InnerError |
|
| 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. |
| invalidPayload |
The request data is invalid for this operation. |
| forbidden |
The operation is forbidden for the current user/api key. |
| notFound |
The resource is not found. |
| unexpectedEntityState |
The operation cannot be executed in the current resource's state. |
| itemDoesAlreadyExist |
The item does already exist. |
| serviceUnavailable |
The service is currently not available. |
| internalFailure |
Internal error. Please retry. |
| quotaExceeded |
Quota exceeded. |
| jsonlValidationFailed |
Validation of jsonl data failed. |
| fileImportFailed |
Import of file failed. |
ErrorResponse
ErrorResponse
| Name | Type | Description |
|---|---|---|
| error |
Error |
File
File
| Name | Type | Description |
|---|---|---|
| bytes |
integer (int64) |
The size of this file when available (can be null). File sizes larger than 2^53-1 are not supported to ensure compatibility with JavaScript integers. |
| created_at |
integer (unixtime) |
A timestamp when this job or item was created (in unix epochs). |
| error |
Error |
|
| filename |
string minLength: 1 |
The name of the file. |
| id |
string |
The identity of this item. |
| object |
TypeDiscriminator |
|
| purpose |
Purpose |
|
| statistics |
FileStatistics |
|
| status |
State |
|
| updated_at |
integer (unixtime) |
A timestamp when this job or item was modified last (in unix epochs). |
FileStatistics
FileStatistics
| Name | Type | Description |
|---|---|---|
| examples |
integer (int32) |
The number of contained training examples in files of kind "fine-tune" once validation of file content is complete. |
| tokens |
integer (int32) |
The number of tokens used in prompts and completions for files of kind "fine-tune" once validation of file content is complete. |
InnerError
InnerError
| Name | Type | Description |
|---|---|---|
| code |
InnerErrorCode |
|
| innererror |
InnerError |
InnerErrorCode
InnerErrorCode
| Value | Description |
|---|---|
| invalidPayload |
The request data is invalid for this operation. |
Purpose
Purpose
| Value | Description |
|---|---|
| fine-tune |
This file contains training data for a fine tune job. |
| fine-tune-results |
This file contains the results of a fine tune job. |
State
State
| Value | Description |
|---|---|
| notRunning |
The operation was created and is not queued to be processed in the future. |
| running |
The operation has started to be processed. |
| succeeded |
The operation has successfully be processed and is ready for consumption. |
| canceled |
The operation has been canceled and is incomplete. |
| failed |
The operation has completed processing with a failure and cannot be further consumed. |
| deleted |
The entity has been deleted but may still be referenced by other entities predating the deletion. |
TypeDiscriminator
TypeDiscriminator
| Value | Description |
|---|---|
| list |
This object represents a list of other objects. |
| fine-tune |
This object represents a fine tune job. |
| file |
This object represents a file. |
| fine-tune-event |
This object represents an event of a fine tune job. |
| model |
This object represents a model (can be a base models or fine tune job result). |