上傳檔案到百鍊平台,支援多檔案上傳,上傳後可在多個任務中複用。
使用限制
當您使用本服務時,會有如下限制存在
- 單個檔案大小限制因 purpose 而異:file-extract 最大 150MB,batch 最大 500MB,fine-tune 最大 300MB。
- 有效檔案(未刪除)總使用空間配額為100GB。
- 有效檔案(未刪除)總數量配額為10000個。
OpenAI 相容方式調用請參考:相關文檔。
說明通過 fine-tune purpose 上傳的調優檔案,在百鍊控制台模型調優頁面與 API 呼叫中均可見可用。
上傳檔案
POST https://dashscope-intl.aliyuncs.com/api/v1/files
Content-type: multipart/form-data
請求樣本
curl --request POST "https://dashscope-intl.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"'
請求參數
欄位 | 類型 | 傳參方式 | 必選 | 描述 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
files | 檔案流 | multipart/form-data | 是 | 調優檔案,支援多檔案上傳 | ||||||||
purpose | 字串 | multipart/form-data | 否 |
不傳 purpose 時檔案仍可上傳成功,建議明確指定 purpose 以便後續按用途管理檔案。 | ||||||||
descriptions | 檔案流 | multipart/form-data | 否 | 檔案描述 |
返回樣本
{
"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."
}
]
}
}
返回參數
欄位 | 類型 | 描述 |
|---|---|---|
data.failed_uploads | Array | 上傳失敗的檔案資訊 |
data.uploaded_files | Array | 上傳成功的檔案資訊 |
data.uploaded_files.$.file_id | String | 檔案ID,可用於查詢檔案詳情和刪除檔案介面 |
data.uploaded_files.$.name | String | 檔案名稱 |
request_id | String | 本次請求的系統唯一碼 |
請求異常
返回樣本
當返回的HTTP狀態代碼不為200時,表示請求失敗,此時樣本返回如下。
{
"request_id": "8f25f57c-5cc0-9881-9c83-62bc173dc9ad",
"code": "InvalidParameter",
"message": "File not found."
}
返回參數
欄位 | 類型 | 描述 |
|---|---|---|
code | String | 錯誤碼。 |
request_id | String | 本次請求的系統唯一碼。 |
message | String | 錯誤資訊。 |