How to get the file name to a file id ? or: How to retrieve the file_name for a file_id?

Hello community,

for some time now I am trying to figure out how to retrieve the file name associated to a file_id ?

Example:

The file to upload is called “data.csv” .

A file is uploaded or added afterwards to an existing Assistant.

Afterwards we. can list the files associated with a specific Assitant by using its assitant_id.

Let assistant_id be “asst_123456789” for example.

The following method can be used for that:

client.beta.assistants.files.list(assistant_id)

In the Object returned there is no information about the original name of the file?

Is there a way of retrieving the File Name that is associated with the fiel_id that can be retrieved ?

Or how would you go about handling this ?

Thanks in advance

Check this out:

https://platform.openai.com/docs/api-reference/files/retrieve

GET https://api.openai.com/v1/files/{file_id}

curl https://api.openai.com/v1/files/file-abc123 \ -H "Authorization: Bearer $OPENAI_API_KEY"

Response: {
  "id": "file-abc123",
  "object": "file",
  "bytes": 120000,
  "created_at": 1677610602,
  "filename": "mydata.jsonl",
  "purpose": "fine-tune",
}