Sample - OpenAI API
GET/files

List files

Lists uploaded files available to the authenticated user. Use purpose, order, and the cursor in after to filter, sort, and paginate the results.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

4 parameters
purposestringoptional
Filters the list to files with the specified purpose.
limitintegeroptional
Maximum number of files to return, from 1 to 10,000. Defaults to 10,000 when omitted.
Default:10000
orderstringoptional
Sort order by creation time: `asc` or `desc`. Defaults to `desc` when omitted.
Allowed:ascdescDefault:desc
afterstringoptional
Cursor identifying the last file from the previous page; omit it to start from the beginning.

1 status code
200Returns a paginated list containing file objects, the first and last file identifiers, and a flag indicating whether more files are available.
objectstringrequired
dataarray<OpenAIFile>required
first_idstringrequired
last_idstringrequired
has_morebooleanrequired

Error handling

limit must be between 1 and 10,000 and defaults to 10,000 when omitted. order must be asc or desc, and after must identify a position in the file list when supplied.