Retrieve file details

Updated at:

Retrieves the details of a file by its file ID.

ImportantThis interface is primarily for compatibility with historical scenarios. It is recommended to prioritize the OpenAI-compatible File interface.

Get file information

GET https://dashscope.aliyuncs.com/api/v1/files/{file_id}
Accept: application/json

Request example

curl --location --request GET "https://dashscope.aliyuncs.com/api/v1/files/123" \
--header "Authorization: Bearer ${DASHSCOPE_API_KEY}"

Request parameters

Parameter

Type

Parameter location

Required

Description

file_id

String

path

Yes

The file ID. You can obtain it from the upload file or list files operations.

Response example

{
    "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"
    }
}

Response parameters

Parameter

Type

Description

data.file_id

String

The file ID.

data.url

String

The file download link.

data.name

String

The file name.

data.size

Number

The file size.

data.md5

String

The MD5 of the file.

data.description

String

The file description.

data.gmt_create

Date

The time when the file was uploaded.

data.id

String

The internal ID of the file.

data.region

String

The region where the file is stored.

data.user_id

String

The user ID.

data.api_key_id

String

The API Key ID.

request_id

String

The unique ID for the request. It can be used for troubleshooting.

List all files

GET https://dashscope.aliyuncs.com/api/v1/files
Accept: application/json

Request example

curl --location --request GET "https://dashscope.aliyuncs.com/api/v1/files?page_no=1&page_size=20" \
--header "Authorization: Bearer ${DASHSCOPE_API_KEY}"

Request parameters

Parameter

Type

Parameter location

Required

Description

page_no

Number

Query

Yes

The current page number. The minimum value is 1, and the default value is 1.

page_size

Number

Query

Yes

The page size. The minimum value is 1, the maximum value is 100, and the default value is 10.

Response example

{
    "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"
            }
        ]
    }
}

Response parameters

Parameter

Type

Description

data.total

Number

The total number of records.

data.page_size

Number

The page size.

data.page_no

Number

The current page number.

data.files

Array

The file list. Each element is a file object. For its attributes, see the File object section.

request_id

String

The unique ID for the request. It can be used for troubleshooting.

Delete a file

DELETE https://dashscope.aliyuncs.com/api/v1/files/{file_id}
Accept: application/json

Request example

curl --location --request DELETE "https://dashscope.aliyuncs.com/api/v1/files/123" \
--header "Authorization: Bearer ${DASHSCOPE_API_KEY}"

Request parameters

Parameter

Type

Parameter location

Required

Description

file_id

String

path

Yes

The file ID. You can obtain it from the upload file or list files operations.

Response example

{
    "request_id": "038e9953-6f0e-4691-afcc-1f0fe07b32c2"
}

Response parameters

Parameter

Type

Description

code

String

The error code. Returned only when this request fails.

message

String

The error message. Returned only when this request fails.

request_id

String

The unique ID for the request. It can be used for troubleshooting.

File object

A file object represents a file uploaded to the Model Studio platform and its attributes. It is created through the upload file interface and can be obtained through the list files and file details query interfaces.

In addition to the DashScope native interface, you can also manage files through the OpenAI-compatible File interface (/compatible-mode/v1/files).

The file management API is currently available only in the China (Beijing) region. If you use another region, manage your files in the Model Studio console of that region.

Parameter

Type

Description

file_id

String

The file ID.

name

String

The file name.

description

String

The file description.

size

Number

The file size.

md5

String

The MD5 of the file.

url

String

The file download link.

gmt_create

Date

The time when the file was uploaded.

id

String

The internal ID of the file.

region

String

The region where the file is stored.

user_id

String

The user ID.

api_key_id

String

The API Key ID.

purpose

String

The purpose of the file.