Skip to main content
Lists all files that have been uploaded to the Gemini File API. Returns a paginated list of files.

Method Signature

Parameters

ListFilesConfig
Optional configuration for the list request.Available options:
  • page_size: Number of files per page (default varies)
  • page_token: Token for fetching a specific page
  • http_options: Custom HTTP request options

Returns

Pager[File]
A Pager object that automatically handles pagination.When you iterate over the pager, it automatically fetches additional pages as needed.Each File in the pager contains:
  • name: Resource name
  • uri: URI for API calls
  • display_name: Human-readable name
  • mime_type: File type
  • size_bytes: File size
  • create_time: Upload time
  • expiration_time: When the file expires
  • state: Processing state

Examples

List All Files

List with Page Size

Count Total Files

Filter Active Files

List by File Type

Calculate Total Storage

List Files Expiring Soon

Async List

Export File List to JSON

Find Specific File

List and Delete Old Files

Display File Summary

Manual Pagination

Pagination

The list() method returns a Pager that automatically handles pagination. You can iterate over it directly without worrying about page tokens.The pager fetches additional pages automatically as you iterate through the results.

Error Handling

API Availability

This method is only available in the Gemini API (not Vertex AI).