Posting here as this seems to be an API issue instead of SDK.
Sporadic 500 errors are (unfortunately) not that unusual. As long as they are truly sporadic.
I just tested a file upload via REST and it seems to work and respond correctly.
To add to the correct observation above, I usually recommend applying automatic retry with exponential backoff to both 429 and 500 HTTP error return codes (the exponential backoff is not needed in the case of the 500, but it is easier to code them the same).
Hope that helps!
Hi everybody,
sadly it is not sporadic and there’s no way to retry. I keep getting 500 for days. Yesterday I was happy that it got fixed, but it worked for 15 minutes, then it broke again and didn’t work since then.
It is broken via SDK and also direct URLs (hitting them via Postman or browser fetch).
I’ve been testing this for the past few hours and haven’t seen any issues. So something weird is going on.
Some questions and thoughts while following up:
- Can you show the code that is consistently causing problems?
- How much has been stored in the file API? (You can check this at https://console.cloud.google.com/apis/api/generativelanguage.googleapis.com/quotas)
Yup. This isn’t sporadic; no matter how many times I retry (even changing API keys to a different account) it errors out.
const response = await fileManager
.listFiles({
pageSize: 100,
pageToken: nextPageToken,
})
.catch((error) => {
console.error(chalk.red(`❌ Error fetching files: ${error}`));
return { files: [], nextPageToken: undefined };
});
This is the call that errors out. After swapping the API key, this didn’t error out at first—until I called:
const waitForFilesActive = async (files: File[]): Promise<void> => {
console.log(chalk.blue("⏳ Waiting for file processing..."));
for (const { name } of files) {
let file = FileSchema.parse(await fileManager.getFile(name));
while (file.state === "PROCESSING") {
process.stdout.write(chalk.yellow("."));
await new Promise((resolve) => setTimeout(resolve, 10_000));
file = FileSchema.parse(await fileManager.getFile(name));
}
if (file.state !== "ACTIVE") {
throw new Error(chalk.red(`❌ File ${file.name} failed to process`));
}
}
console.log(chalk.green("\nâś… All files ready"));
};
Which makes me believe it has something to do with the file being uploaded? Which is weird because it’s just a Youtube video (mp4 file).
Hmm, I can’t seem to find how much has been stored in the file API as I don’t even have a project associated with the account in Google Cloud. I just generated the API key from Google AI Studio.
There should always be an account associated with it. You may want to get to the quota page from these steps:
- Start at https://aistudio.google.com/app/apikey which should show a list of API Keys and projects
- Under the Project ID column, click on the square box that points to the upper right. This should open a new page.
- On the left menu, select “Enabled APIs and Services”
- On the list along the bottom, select “Generative Language API”
- In the horizontal list in the middle, select “Quotas & System Limits”
For it’s both code and just calling API via Postman with proper API keys.
Here is the screenshot from Postman:
But this error rate is pretty alarming:
PS: Sorry for multiple replies, but it says that new users can embed only 1 image in a post, so I had to do multiple ones.
How large is the file you are trying to upload? If it is a video, how long is it?
It doesn’t matter, it fails even when I do GET request (to see already uploaded files) and I have 2 files saved in the File Service.
But I tried it with 30s mp4 video, standard x264 encoding.
Does it only happen for videos? Do you have issue uploading images?
As I said - even GET for listing files fails, I don’t even have to upload something. I just get 500 straight away.
For me video/audio is key. If it would be about images, I can go use OpenAI or Claude. But Gemini has advantage with those multimedia.
I have the same problem uploading videos (less than 5 seconds length). Yesterday it worked fine and today a large percentage of attempts result in an error 500.
Is there anything I can do?
Getting the HTTP 500 error for gemini 1.5 pro vanilla prompting as well.
Yeah, Gemini reliability is pretty scuffed—I’m still getting 500 errors.
As an alternative, I’ve been using Whisper + Claude 3.5 Sonnet with timestamped screenshots. The quality and tone is better than Gemini (but obviously, more expensive).
Qwen2-VL just got released, which should accept native video inputs.