Gemini File Search API - "Upload has already been terminated" error when uploading large CSV files (>5MB)

,

Hi everyone,

I’m experiencing an issue with the File Search API when uploading large CSV files and would appreciate any insights or confirmation if others are seeing the same behavior.

Summary

Large CSV file uploads (5MB) to File Search Stores fail with “Upload has already been terminated” error, while smaller files (up to 1.3MB) upload successfully. The issue appears to be related to file size, occurring somewhere between 1.3MB and 5MB.

Environment

  • Tier: Tier 3 (Paid)
  • SDK: google-genai 1.59.0
  • Python: 3.14.2
  • OS: macOS 15.6.1
  • Model: gemini-2.5-flash

Expected Behavior

File upload completes successfully and the document becomes available in the File Search Store.

Actual Behavior

Upload fails with the following error:

google.genai.errors.ClientError: 400 Bad Request. {'message': 'Upload has already been terminated.', 'status': 'Bad Request'}

Steps to Reproduce

  1. Create a File Search Store
  2. Attempt to upload a CSV file (~5MB)
  3. Error occurs during upload

Minimal Reproducible Code(You can copy & paste to check it)

from google import genai
import time

client = genai.Client(api_key="YOUR_API_KEY")

# Create store
store = client.file_search_stores.create(config={"display_name": "test-store"})
store_name = store.name

# Upload file
# - 1.3MB CSV -> SUCCESS
# - 5.0MB CSV -> FAILS
operation = client.file_search_stores.upload_to_file_search_store(
    file="data.csv",  # ~5MB
    file_search_store_name=store_name,
    config={"display_name": "data.csv"},
)

while not operation.done:
    time.sleep(5)
    operation = client.operations.get(operation)

print(operation.response.document_name)

Full Error Traceback

$ python test.py

Traceback (most recent call last):
  File "/.../gemini_file_search_poc/test.py", line 13, in <module>
    operation = client.file_search_stores.upload_to_file_search_store(
        file="data.csv",  # 5MB
        file_search_store_name=store_name,
        config={"display_name": "data.csv"},
    )
  File "/.../.pyenv/versions/3.14.2/lib/python3.14/site-packages/google/genai/file_search_stores.py", line 764, in upload_to_file_search_store
    upload_response = self._api_client.upload_file(
        fs_path, upload_url, size_bytes, http_options=http_options
    )
  File "/.../.pyenv/versions/3.14.2/lib/python3.14/site-packages/google/genai/_api_client.py", line 1499, in upload_file
    return self._upload_fd(
           ~~~~~~~~~~~~~~~^
        file, upload_url, upload_size, http_options=http_options
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/.../.pyenv/versions/3.14.2/lib/python3.14/site-packages/google/genai/_api_client.py", line 1577, in _upload_fd
    errors.APIError.raise_for_response(response)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/.../.pyenv/versions/3.14.2/lib/python3.14/site-packages/google/genai/errors.py", line 121, in raise_for_response
    cls.raise_error(response.status_code, response_json, response)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.pyenv/versions/3.14.2/lib/python3.14/site-packages/google/genai/errors.py", line 146, in raise_error
    raise ClientError(status_code, response_json, response)
google.genai.errors.ClientError: 400 Bad Request. {'message': 'Upload has already been terminated.', 'status': 'Bad Request'}

What I Have Tried

Action File Size Result
Upgrade google-genai to latest - Still fails
Upload small CSV ~60KB Success
Upload medium CSV ~1.3MB Success
Upload large CSV ~5.0MB Fails
Retry after waiting ~5.0MB Still fails

The failure threshold appears to be somewhere between 1.3MB and 5.0MB.

Related Issue

I found a similar issue reported here:

The post mentions the issue was related to SDK endpoint mismatches after an API update. The original poster reported it started working, but I’m still experiencing this issue with larger files.

Questions

  1. Is anyone else experiencing this issue with larger files?
  2. Are there any workarounds?

Additional Context

  • The documented maximum file size is 100MB, but failures occur at 5MB

Any help or insights would be greatly appreciated. Thanks!