Retrieve a source file
Updated at:
Return source file metadata for a file ID.
Endpoint
Returns 200 and source file metadata. The response shape differs from the source file list and upload response: it uses bytes, Unix-second timestamps, and an object field.
GET
/agents/file/{file_id}Path parameters
file_idstringRequiredSource file ID
There is no source file content download endpoint.
Request example
curl -sS "$BASE_URL/agents/file/file_xxx" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "OpenAI-Beta: agents=v1"
import os
import requests
resp = requests.get(
f"{os.environ['BASE_URL']}/agents/file/file_xxx",
headers={"Authorization": f"Bearer {os.environ['DASHSCOPE_API_KEY']}"},
)
print(resp.status_code, resp.json())
Response fields
idstringSource file ID
objectstringSource file object type, fixed as file
bytesintegerFile size in bytes
created_atintegerCreation time in Unix seconds
filenamestringFile name
statusstringFile status: uploaded, processed, or error. processed means the file is usable; uploaded means it is uploaded and undergoing content moderation; error means processing failed or content moderation did not pass
Response example
{
"id": "file_xxx",
"object": "file",
"bytes": 18,
"created_at": 1794321796,
"filename": "input.txt",
"status": "uploaded"
}
Error codes
| HTTP status | Error type / code | Solution |
|---|---|---|
401 | authentication_error / invalid_api_key | Send a valid Authorization: Bearer $DASHSCOPE_API_KEY header |
404 | not_found_error / not_found_error | Use a source file ID that exists in the current workspace |
500 | server_error / server_error | Retry later. If it keeps failing, submit a ticket with x-request-id |
Is this page helpful?