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_idstringRequired

Source 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

idstring

Source file ID

objectstring

Source file object type, fixed as file

bytesinteger

File size in bytes

created_atinteger

Creation time in Unix seconds

filenamestring

File name

statusstring

File 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 statusError type / codeSolution
401authentication_error / invalid_api_keySend a valid Authorization: Bearer $DASHSCOPE_API_KEY header
404not_found_error / not_found_errorUse a source file ID that exists in the current workspace
500server_error / server_errorRetry later. If it keeps failing, submit a ticket with x-request-id