I’m using the Gemini API to upload and list files. The following code works as expected:
from google.genai import Client
client = Client(api_key=os.getenv('GEMINI_API_KEY'))
file = client.files.upload(file=image_path) # Uploads successfully
files = client.files.list() # Lists uploaded files correctly
print(files)
However, when I specify api_version=‘v1’ in HttpOptions, the file uploads successfully, but client.files.list() fails:
from gemini import Client, HttpOptions
import os
client = Client(api_key=os.getenv('GEMINI_API_KEY'), http_options=HttpOptions(api_version='v1'))
file = client.files.upload(file=image_path) # Still uploads successfully
files = client.files.list() # This fails
print(files)
What I’ve tried:
- Removing api_version=‘v1’ makes client.files.list() work again.
- Ensuring the file upload succeeds (it does for both).
Why does specifying api_version=‘v1’ cause client.files.list() to fail? Is this a known limitation or am I missing something? How can I list uploaded files while setting a specific api_version.