查詢、列舉和刪除檔案,並瞭解檔案對象的屬性資訊。
擷取指定檔案資訊
GET https://dashscope-intl.aliyuncs.com/api/v1/files/{file_id}
Accept: application/json
請求樣本
curl --location --request GET "https://dashscope-intl.aliyuncs.com/api/v1/files/123" \
--header "Authorization: Bearer ${DASHSCOPE_API_KEY}"
請求參數
欄位 | 類型 | 傳參方式 | 必選 | 描述 |
|---|---|---|---|---|
file_id | String | path | 是 | 檔案ID,可通過上傳檔案或列舉檔案介面擷取 |
返回樣本
{
"request_id": "bddee90e-d320-4bf9-b32b-ac3359192d1e",
"data": {
"file_id": "mbSwIGR9yA6i1EtwIpndFErIoDKFyQ6W5601487ECAB111EDA20422ECF4959B5E",
"name": "dogs.jpg",
"description": "1",
"size": 129862,
"md5": "1d5ee55c2453009b14db98e74c453abb",
"gmt_create": "2023-03-25 10:04:11",
"url": "http://xxxxx.oss-cn-hangzhou.aliyuncs.com/oss%3A//dashscope-pre/api-fs/1253/236/dogs.jpg?Expires=1679797621&OSSAccessKeyId=YOUR_ACCESS_KEY_ID&Signature=YOUR_SIGNATURE"
}
}
返回參數
欄位 | 類型 | 描述 |
|---|---|---|
data.file_id | String | 檔案ID |
data.url | String | 檔案下載連結 |
data.name | String | 檔案名稱 |
data.size | Number | 檔案大小 |
data.md5 | String | 檔案的md5 |
data.description | String | 檔案的描述 |
data.gmt_create | Date | 檔案上傳時間 |
data.id | String | 檔案的內部ID |
data.region | String | 檔案所在地區 |
data.user_id | String | 使用者ID |
data.api_key_id | String | API Key ID |
request_id | String | 本次請求的系統唯一碼 |
列舉當前所有的檔案
GET https://dashscope-intl.aliyuncs.com/api/v1/files
Accept: application/json
請求樣本
curl --location --request GET "https://dashscope-intl.aliyuncs.com/api/v1/files?page_no=1&page_size=20" \
--header "Authorization: Bearer ${DASHSCOPE_API_KEY}"
請求參數
欄位 | 類型 | 傳參方式 | 必選 | 描述 |
|---|---|---|---|---|
page_no | Number | Query | 是 | 當前頁,最小值為1,預設值為1 |
page_size | Number | Query | 是 | 分頁大小。最小值為1,最大值為100,預設值為10 |
返回樣本
{
"request_id": "123456",
"data": {
"total": 2,
"page_size": 20,
"page_no": 1,
"files": [
{
"id": 1001,
"file_id": "9G2EaQtq7p1fw7oRhYXdHTtDFYAMVQSh95432B38CAB211EDB8F952C2E8001733",
"name": "test.txt",
"description": "1",
"size": 0,
"md5": "d41d8cd98f00b204e9800998ecf8427e",
"gmt_create": "2023-03-25 10:13:07",
"url": "http://xxx.oss-cn-hangzhou.aliyuncs.com/oss%3A//dashscope-dev/api-fs/123456/123456/test.txt",
"region": "cn-hangzhou",
"user_id": "123456",
"api_key_id": "sk-xxxx",
"purpose": "fine-tune"
},
{
"id": 1002,
"file_id": "wmIDj6zemqjIb8L2o8NHIlMRk3QinjGP00E987C7CA3711ED83E0000EC63B0D1C",
"name": "sdsdsd.mp4",
"description": "1",
"size": 780635,
"md5": "8382b3d3137bce6eaf1beef9c8920ef6",
"gmt_create": "2023-03-24 19:28:30",
"url": "http://xxxx.oss-cn-hangzhou.aliyuncs.com/oss%3A//dashscope-dev/api-fs/123456/123456/sdsdsd.mp4",
"region": "cn-hangzhou",
"user_id": "123456",
"api_key_id": "sk-xxxx",
"purpose": "file-extract"
}
]
}
}
返回參數
欄位 | 類型 | 描述 |
|---|---|---|
data.total | Number | 總記錄數 |
data.page_size | Number | 分頁大小 |
data.page_no | Number | 當前頁 |
data.files | Array | 檔案清單,元素為檔案對象,屬性詳見檔案對象小節 |
request_id | String | 本次請求的系統唯一碼 |
刪除檔案
DELETE https://dashscope-intl.aliyuncs.com/api/v1/files/{file_id}
Accept: application/json
請求樣本
curl --location --request DELETE "https://dashscope-intl.aliyuncs.com/api/v1/files/123" \
--header "Authorization: Bearer ${DASHSCOPE_API_KEY}"
請求參數
欄位 | 類型 | 傳參方式 | 必選 | 描述 |
|---|---|---|---|---|
file_id | String | path | 是 | 檔案ID,可通過上傳檔案或列舉檔案介面擷取 |
返回樣本
{
"request_id": "038e9953-6f0e-4691-afcc-1f0fe07b32c2"
}
返回參數
欄位 | 類型 | 描述 |
|---|---|---|
code | String | 錯誤碼,僅當本次請求出錯時返回 |
message | String | 錯誤資訊,僅當本次請求出錯時返回 |
request_id | String | 本次請求的系統唯一碼 |
檔案對象
檔案對象表示已上傳到百鍊平台的檔案及其屬性資訊。通過上傳檔案介面建立,可通過列舉檔案和查詢檔案詳情介面擷取。
除 DashScope 原生介面外,您也可以通過 OpenAI 相容-File 介面(/compatible-mode/v1/files)管理檔案。
當前檔案管理 API 僅在新加坡 Region 開放。如您使用其他 Region,請通過該 Region 的百鍊控制台完成檔案管理操作。
欄位 | 類型 | 描述 |
|---|---|---|
file_id | String | 檔案ID |
name | String | 檔案名稱 |
description | String | 檔案的描述 |
size | Number | 檔案大小 |
md5 | String | 檔案的md5 |
url | String | 檔案下載連結 |
gmt_create | Date | 檔案上傳時間 |
id | String | 檔案的內部ID |
region | String | 檔案所在地區 |
user_id | String | 使用者ID |
api_key_id | String | API Key ID |
purpose | String | 檔案用途 |