Files - Import

Creates a new file entity by importing data from a provided url. Uploaded files can, for example, be used for training or evaluating fine-tuned models.

POST {endpoint}/openai/files/import?api-version=2022-12-01

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).

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.

Request Body

Name Required Type Description
content_url True
  • string

The url to download the document from (can be SAS url of a blob or any other external url accessible with a GET request).

filename True
  • string

The name of the JSON Lines file to be uploaded. If the purpose is set to "fine-tune", each line is a JSON record with "prompt" and "completion" fields representing your training examples.

purpose True

Purpose
The intended purpose of the uploaded documents. Use "fine-tune" for fine-tuning. This allows us to validate the format of the uploaded file.

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

Importing a file with a blob url as source.

Sample Request

POST https://aoairesource.openai.azure.com/openai/files/import?api-version=2022-12-01


{
  "purpose": "fine-tune",
  "filename": "puppy.jsonl",
  "content_url": "https://www.contoso.com/trainingdata/puppy.jsonl"
}

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

Error

Error

ErrorCode

ErrorCode

ErrorResponse

ErrorResponse

File

File

FileImport

FileImport

FileStatistics

FileStatistics

InnerError

InnerError

InnerErrorCode

InnerErrorCode

Purpose

Purpose

State

State

TypeDiscriminator

TypeDiscriminator

Error

Error

Name Type Description
code

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

The error details if available.

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

The message of this error.

target
  • string

The location where the error happened if available.

ErrorCode

ErrorCode

Name Type Description
conflict
  • string

The requested operation conflicts with the current resource state.

fileImportFailed
  • string

Import of file failed.

forbidden
  • string

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

internalFailure
  • string

Internal error. Please retry.

invalidPayload
  • string

The request data is invalid for this operation.

itemDoesAlreadyExist
  • string

The item does already exist.

jsonlValidationFailed
  • string

Validation of jsonl data failed.

notFound
  • string

The resource is not found.

quotaExceeded
  • string

Quota exceeded.

serviceUnavailable
  • string

The service is currently not available.

unexpectedEntityState
  • string

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

ErrorResponse

ErrorResponse

Name Type Description
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).

File

File

Name Type Description
bytes
  • integer

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

A timestamp when this job or item was created (in unix epochs).

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).

filename
  • string

The name of the file.

id
  • string

The identity of this item.

object

TypeDiscriminator
Defines the type of an object.

purpose

Purpose
The intended purpose of the uploaded documents. Use "fine-tune" for fine-tuning. This allows us to validate the format of the uploaded file.

statistics

FileStatistics
A file is a document usable for training and validation. It can also be a service generated document with result details.

status

State
The state of a job or item.

updated_at
  • integer

A timestamp when this job or item was modified last (in unix epochs).

FileImport

FileImport

Name Type Description
content_url
  • string

The url to download the document from (can be SAS url of a blob or any other external url accessible with a GET request).

filename
  • string

The name of the JSON Lines file to be uploaded. If the purpose is set to "fine-tune", each line is a JSON record with "prompt" and "completion" fields representing your training examples.

purpose

Purpose
The intended purpose of the uploaded documents. Use "fine-tune" for fine-tuning. This allows us to validate the format of the uploaded file.

FileStatistics

FileStatistics

Name Type Description
examples
  • integer

The number of contained training examples in files of kind "fine-tune" once validation of file content is complete.

tokens
  • integer

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
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
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

Name Type Description
invalidPayload
  • string

The request data is invalid for this operation.

Purpose

Purpose

Name Type Description
fine-tune
  • string

This file contains training data for a fine tune job.

fine-tune-results
  • string

This file contains the results of a fine tune job.

State

State

Name Type Description
canceled
  • string

The operation has been canceled and is incomplete.

deleted
  • string

The entity has been deleted but may still be referenced by other entities predating the deletion.

failed
  • string

The operation has completed processing with a failure and cannot be further consumed.

notRunning
  • string

The operation was created and is not queued to be processed in the future.

running
  • string

The operation has started to be processed.

succeeded
  • string

The operation has successfully be processed and is ready for consumption.

TypeDiscriminator

TypeDiscriminator

Name Type Description
deployment
  • string

This object represents a deployment.

file
  • string

This object represents a file.

fine-tune
  • string

This object represents a fine tune job.

fine-tune-event
  • string

This object represents an event of a fine tune job.

list
  • string

This object represents a list of other objects.

model
  • string

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