Skip to main content

Method Signature

Parameters

str
A cursor for use in pagination. after is an object ID that defines your place in the list.For instance, if you make a list request and receive 100 objects ending with obj_foo, your subsequent call can include after=obj_foo to fetch the next page of the list.
int
default:"10000"
A limit on the number of objects to be returned.
  • Range: 1 to 10,000
  • Default: 10,000
Literal['asc', 'desc']
default:"desc"
Sort order by the created_at timestamp of the objects.
  • asc - Ascending order (oldest first)
  • desc - Descending order (newest first)
str
Only return files with the given purpose.Valid purposes:
  • assistants
  • batch
  • fine-tune
  • vision
  • user_data
  • evals

Response

Returns a paginated list of FileObject instances.

Examples

List All Files

List Fine-tuning Files Only

Paginate Through Files

List Files in Ascending Order

Auto-pagination

Filter and Process Files

Async Usage

Pagination Details

The list() method returns a SyncCursorPage object that supports:
  • Iteration: Automatically fetches pages as you iterate
  • Manual pagination: Use after parameter with the last object ID
  • Page size control: Use limit to control how many objects per page

Notes

  • Default limit is 10,000 files per request
  • Files are sorted by created_at timestamp
  • Use pagination for large file lists to avoid memory issues
  • The response includes all file metadata except the actual file contents
  • Use the retrieve content endpoint to download file contents