> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/googleapis/python-genai/llms.txt
> Use this file to discover all available pages before exploring further.

# Files

> Upload, retrieve, and delete files using the Gemini API

<Note>
  Files are only supported in the Gemini Developer API, not Vertex AI.
</Note>

The Files API allows you to upload files to use with the Gemini models.

## Upload files

Upload a file from your local filesystem:

```python theme={null}
file1 = client.files.upload(file='2312.11805v3.pdf')
file2 = client.files.upload(file='2403.05530.pdf')

print(file1)
print(file2)
```

The `upload` method automatically detects the file type and uploads it to the Gemini API.

### Upload response

The upload method returns a `File` object with the following properties:

* **name** - The unique identifier for the file
* **uri** - The URI to reference the file in API calls
* **mime\_type** - The detected MIME type
* **size\_bytes** - File size in bytes
* **create\_time** - When the file was uploaded

## Get file metadata

Retrieve information about an uploaded file:

```python theme={null}
file1 = client.files.upload(file='2312.11805v3.pdf')
file_info = client.files.get(name=file1.name)

print(file_info)
```

## Delete files

Remove a file from the Gemini API:

```python theme={null}
file3 = client.files.upload(file='2312.11805v3.pdf')

client.files.delete(name=file3.name)
```

## Using files with models

Once uploaded, you can reference files in your model requests:

```python theme={null}
# Upload a PDF
file = client.files.upload(file='document.pdf')

# Use the file in a generate_content call
response = client.models.generate_content(
    model='gemini-2.5-flash',
    contents=[
        types.Part.from_uri(file.uri, file.mime_type),
        'Summarize this document',
    ],
)

print(response.text)
```

## Supported file types

The Files API supports various file types including:

* PDF documents
* Images (JPEG, PNG, WebP)
* Audio files (MP3, WAV)
* Video files (MP4, MOV)
* Text files

## File storage and lifecycle

* Files are stored temporarily on Google's servers
* Files are automatically deleted after a period of inactivity
* You should delete files you no longer need to manage storage
