generative-ai-android icon indicating copy to clipboard operation
generative-ai-android copied to clipboard

Gemini API returns 503 error with MissingFieldException

Open surajsahani opened this issue 1 year ago • 11 comments

Description of the bug:

When interacting with the Gemini API, the following error message is received in the log:

D  Error message received: Unexpected Response:
{
  "error": {
    "code": 503,
    "message": "The model is overloaded. Please try again later.",
    "status": "UNAVAILABLE"
  }
}
kotlinx.serialization.MissingFieldException: Field 'details' is required for type with serial name 'com.google.ai.client.generativeai.common.server.GRpcError', but it was missing at path: $.error

This indicates that the API is overloaded, but it also throws a MissingFieldException related to the 'details' field when parsing the response.

Actual vs expected behavior:

Actual: The response includes a 503 error code with the message "The model is overloaded." Additionally, a MissingFieldException is thrown due to the missing 'details' field. Expected: The API should either provide a valid response with the necessary 'details' field or handle missing fields gracefully without throwing an exception.

Any other information you'd like to share?

This error occurs during normal API interaction when the model is under heavy load. It would be helpful to have the API gracefully handle missing fields in error responses to prevent application crashes.

surajsahani avatar Nov 16 '24 12:11 surajsahani

I think adding the missing field will give some inshights to the error that's happening in Google's side. It's a weekend so I doubt that that the team will be able to take a look at it today or tomorrow.

This is the error I'm also getting

{
"error": {
    "code": 503,
    "message": "The model is overloaded. Please try again later.",
    "status": "UNAVAILABLE"
    }
}
kotlinx.serialization.MissingFieldException: Field 'details' is required for type with serial name 'com.google.ai.client.generativeai.common.server.GRpcError', but it was missing at path: $.error

adrdev10 avatar Nov 16 '24 23:11 adrdev10

Hi @surajsahani,

Were you getting the errors earlier also?? I mean whether it was working earlier and suddenly you started seeing these errors or from very beginning you were getting these errors?

gmKeshari avatar Nov 21 '24 04:11 gmKeshari

This issue started suddenly from last 4-5 days @gmKeshari

surajsahani avatar Nov 21 '24 06:11 surajsahani

I think adding the missing field will give some inshights to the error that's happening in Google's side. It's a weekend so I doubt that that the team will be able to take a look at it today or tomorrow.

This is the error I'm also getting

{
"error": {
    "code": 503,
    "message": "The model is overloaded. Please try again later.",
    "status": "UNAVAILABLE"
    }
}
kotlinx.serialization.MissingFieldException: Field 'details' is required for type with serial name 'com.google.ai.client.generativeai.common.server.GRpcError', but it was missing at path: $.error

+1 This has been happening from last week, when new gemini model drop for Iphone

surajsahani avatar Nov 21 '24 06:11 surajsahani

Hey @surajsahani,

Due to overload this issue was reported by many users last week. Our team is working to fix this. You can consider this as a temporary issue.

Temporarily switch to another model (e.g. from Gemini 1.5 Pro to Gemini 1.5 Flash) and see if it works. Or wait a bit and retry your request.

gmKeshari avatar Nov 21 '24 10:11 gmKeshari

Hey @surajsahani,

Due to overload this issue was reported by many users last week. Our team is working to fix this. You can consider this as a temporary issue.

Temporarily switch to another model (e.g. from Gemini 1.5 Pro to Gemini 1.5 Flash) and see if it works. Or wait a bit and retry your request.

I've tried both Gemini 1.5 Flash and Pro, but I'm still facing model overload issues. It seems 1.5 Pro can't handle more than 2 API calls concurrently. Any suggestions or workarounds?

surajsahani avatar Nov 23 '24 14:11 surajsahani

Hi @surajsahani,

Model overload issues will be resolved, team is working. Regarding API calls there is free tier limit for each model, you can refer this link

gmKeshari avatar Nov 28 '24 06:11 gmKeshari

Hey, I experience the same issue when my IP address is in unsupported location, which results in a crash of the whole application if I won't implement some workarounds to handle such issues as gracefully as possible on my side. Luckily, the fix for a library is dead simple and is already dropped for review at #227. @daymxn I think it's critical enough to ping you

bpavuk avatar Nov 30 '24 17:11 bpavuk

I mark shifted to OpenAPI because of all of above issues.

surajsahani avatar Dec 01 '24 03:12 surajsahani

I mark shifted to OpenAPI because of all of above issues.

relatable, if you mean OpenAI

bpavuk avatar Dec 01 '24 07:12 bpavuk

i have the same issue although , I added some time out before fetching but still the same i don't understand , but the free tier is still there

ARGHYAHACKED avatar Jul 18 '25 17:07 ARGHYAHACKED