Exception TypeError: Load failed sending request in ios device

Hi, I’m encountering an issue when using the Gemini 2.0 Flash API on iOS devices. I receive the following error: exception TypeError: Load failed sending request. Interestingly, the API works perfectly on Mac, Windows, and Android devices, but it consistently fails on iOS. Could this indicate compatibility issues with iOS devices? I’d greatly appreciate any assistance in resolving this problem.
Here’s the console log for reference:
Failed to load resource: the server responded with a status of 500 ()
:no_entry: Preflight response is not successful. Status code: 403
:no_entry: Fetch API cannot load https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp-image-generation:generateContent due to access control checks.
:no_entry: Failed to load resource: Preflight response is not successful. Status code: 403
https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp-image-generation:generateContent

Hi @Jing , Welcome to the forum.

Is this happening with all the models? 403 error usually means that your API key doesn’t have the required permissions. For example, you might be using the wrong API key.

Hi there, I’m actually facing the same issue. The requests work perfectly fine on Mac, Android, etc but fails only on iOS. I am using the Node.js API. Same 403 error

Facing the same error on iOS and Safari. What can we do?

One implementation that works is just to use the REST api with some JS fetch calls. Seems to do the trick on iOS.

But would be nice (and much cleaner) to use the official JS API on iOS.

I will escalate this to the engineering team.

Thanks

Yeah, fixed it by using the upload rest API and then moving the whole Gemini part to backend. I should not have called it straight from front end and now it works, but … would be nice to not have to do it for quick prototype projects.