Upload a file
Upload files to the Model Studio platform. You can upload multiple files at once and reuse them across different jobs.
ImportantThis interface is primarily for compatibility with historical scenarios. It is recommended to prioritize the OpenAI-compatible File interface.
Usage limits
The following usage limits apply when you use this service:
- The maximum size of a single file varies by purpose: 150 MB for file-extract, 500 MB for batch, and 300 MB for fine-tune.
- The total storage quota for active (not deleted) files is 100 GB.
- The total number of active (not deleted) files is limited to 10,000.
For OpenAI-compatible calls, see the relevant documentation.
NoteFine-tuning files uploaded by using the fine-tune purpose are visible and available in both the Model Studio console model fine-tuning page and API calls.
Upload a file
POST https://dashscope.aliyuncs.com/api/v1/files
Content-type: multipart/form-data
Request example
curl --request POST "https://dashscope.aliyuncs.com/api/v1/files" \
--header "Authorization: Bearer ${DASHSCOPE_API_KEY}" \
--form 'files=@"/path/to/your/file1.jsonl"' \
--form 'purpose="fine-tune"'\
--form 'descriptions="a sample fine-tune data file for qwen"' \
--form 'files=@"/path/to/your/file2.jsonl"' \
--form 'purpose="fine-tune"'\
--form 'descriptions="a sample fine-tune data file for qwen"'
Request parameters
Parameter | Type | In | Required | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
files | file stream | multipart/form-data | Yes | The file to upload. You can upload multiple files in one request. | ||||||||
purpose | string | multipart/form-data | No |
If you do not specify purpose, the file can still be uploaded successfully. We recommend that you explicitly specify purpose to manage files by usage later. | ||||||||
descriptions | file stream | multipart/form-data | No | A description of the file. |
Response example
{
"request_id": "xxx",
"data": {
"uploaded_files": [
{
"file_id": "9G2EaQtq7p1fw7oRhYXdHTtDFYAMVQSh95432B38CAB211EDB8F952C2E8001733",
"name": "test.txt"
}
],
"failed_uploads": [
{
"name": "test1.jpg",
"code": "BadRequest.TooLarge",
"message": "Out of space, <839> B of <1024> B storage space has been used."
},
{
"name": "test2.jpg",
"code": "BadRequest.TooMany",
"message": "Out of number, <10> of <10> files has been uploaded."
}
]
}
}
Response parameters
Parameter | Type | Description |
|---|---|---|
data.failed_uploads | array | Information about files that failed to upload. |
data.uploaded_files | array | Information about successfully uploaded files. |
data.uploaded_files.$.file_id | string | The file ID, which can be used in the Retrieve file details and Delete file APIs. |
data.uploaded_files.$.name | string | The file name. |
request_id | string | The unique ID of the request. |
Error responses
Response example
A non-200 HTTP status code indicates that the request failed. The following is an example of an error response.
{
"request_id": "8f25f57c-5cc0-9881-9c83-62bc173dc9ad",
"code": "InvalidParameter",
"message": "File not found."
}
Response parameters
Parameter | Type | Description |
|---|---|---|
code | string | The error code. |
request_id | string | The unique ID of the request. |
message | string | The error message. |