Gemini-1.5-flash is no longer processing audio files (500 Exception) - retry does not help

Since two days ago gemini-1.5-flash (both 01 and 02) throws a 500 error when audio is provided as input. I’ve tried with both inline audio and using the File API, both give the same (unhelpful) error below. Size of the audio file does not matter. We use exponential retry, and this does not help.

I should add that normal calls to gemini-1.5-flash (without audio) do work properly,

Because I make frequent use of audio, I’m 100% confident that this broke without any changes in the audio-files or code on our side. Something in the Gemini backend must have changed, as we also didn’t update the SDK version.

I am using the (recently deprecated) google-generativeai==0.8.4, don’t know if the new SDK solves the problem as that is a fairly significant refactor that I haven’t done yet.

The only fix that did work for me was to switch to the 2.0-flash and 2.0-flash-lite models. While it is a solution, it’s not great to be forced into it.

Exception: 500 Unable to submit request because the service is temporarily unavailable., 
Exception traceback: Traceback (most recent call last):
  File "/opt/render/project/src/.venv/lib/python3.11/site-packages/tenacity/__init__.py", line 382, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/opt/render/project/src/src/myrepo/llm_utils.py", line 177, in ask_gemini
    response = model.generate_content(contents)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/render/project/src/.venv/lib/python3.11/site-packages/google/generativeai/generative_models.py", line 331, in generate_content
    response = self._client.generate_content(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/render/project/src/.venv/lib/python3.11/site-packages/google/ai/generativelanguage_v1beta/services/generative_service/client.py", line 830, in generate_content
    response = rpc(
               ^^^^```

I’m having exactly the same issue. It used to work fine but a few days ago, every request with an audio file on it, started to fail with the above error.

Hi @erik,

I tried to replicate the issue with wav audio format but it worked for me, can you let me know what is the format that you tried and here is the gist of my testing.

Thank you!

Thanks @Siva_Sravana_Kumar_N. I refactored my code to the new SDK a few days ago, and I don’t see the same problem there. So it seems the combination of the google-generativeai SDK, and the 1.5 flash model. Differences with your code:

  • I tried gemini-1.5-flash-002 and gemini-1.5-flash-001
  • mp3 file instead of .wav
  • perhaps the config or safety settings (see code below)
  • input mime type: audio/mpeg
generation_config = genai.GenerationConfig(temperature=temperature,
                                               top_p=0.95,
                                               top_k=40,
                                               response_mime_type='application/json')
safety_settings = GEMINI_SAFETY_OFF
model = genai.GenerativeModel(model_name=model,
                              generation_config=generation_config,
                              system_instruction=system_prompt,
                              safety_settings=safety_settings)


contents = [{
  "parts": [{"text": system_prompt},
            {"file_data": {
                "mime_type": mime_type,
                "file_uri": file_uri
            }}]}]
response = model.generate_content(contents)

If you haven’t solved it yet, this is what worked for me:

  • Switch to the 2.0-flash-lite model: Almost the same price, and it seems to work well with only slight changes to the prompt.

Alternatively, switching to the new SDK might also work, as I’m unable to reproduce the issues there with 1.5-flash.

1 Like