How to call Gemini GEM via API for a dedicated chatbot?

I am using Google Gemini Gems to create a dedicated chatbot for my application. I have uploaded the SOPs for the application in the knowledge section of the gem.

Now, I want to call this gem programmatically via API so that I can send questions and receive answers automatically.

I have tried the following endpoint format:

https://generativelanguage.googleapis.com/v1beta/gems/MY_GEM_ID/gemini-2.5-pro:generateContent?key=MY_API_KEY

But I get a 404 Not Found error.

Some additional information:

  • I am the owner of the gem and I am logged in with the same Gmail account.

  • I can interact with the gem in the Gemini console successfully.

i am having the same issue how did you go around this