google-gemini / generative-ai-android

The official Android library for the Google Gemini API
https://ai.google.dev/gemini-api/docs/get-started/tutorial?lang=android
Apache License 2.0
734 stars 160 forks source link

Sudden constant Error code 500 (Internal Error) with the Gemini API in my Android app #209

Closed theJayTea closed 3 months ago

theJayTea commented 4 months ago

Description of the bug:

Hello! Today, I've suddenly been having this error constantly, across Google Accounts and API keys when using the Gemini API through my Android app. It was working perfectly fine the last few days. I'm using the free API, and I was planning to pay for it but I'm having second thoughts now.

Error: Unexpected Response:

"error": {
"code": 500,
"message": "An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting",
"status": "INTERNAL"

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

The following is my model initialisation code. Is it because I'm doing something wrong here?

        Content systemInstructionsContent = new Content.Builder()
                .addText(systemInstructions)
                .build();

        GenerativeModel gm = new GenerativeModel(
                "gemini-1.5-pro",
                apiKey,
                null,
                null,
                new RequestOptions(), // Use default RequestOptions
                null,
                null,
                systemInstructionsContent
        );

I'm leaving some of the parameters as null, as I want them at the default and only want to add a system prompt. I'm using Java to call the model from my Android app!

Thanks so so much for the help!

Actual vs expected behavior:

Expected behaviour: API calls work, without randomly sometimes returning Error code 500

Actual behaviour: For the last day, requests have been constantly returning error code 500 almost all the time

Any other information you'd like to share?

No response

erendogan6 commented 4 months ago

I started getting this error today as well.

KawshikManikantan commented 4 months ago

Same error noted. How can this be resolved?

singhniraj08 commented 3 months ago

@theJayTea, Thank you reporting this issue. This looks like an intermittent error and should work now. This repository is for issues related to Android SDK client bugs or improvements and the client doesn't control the service's responses. For issues related to Gemini API, we would suggest you to use "Send Feedback" option in Gemini docs. Ref: Screenshot below. You can also post this issue on Google AI forum.

image