How to fix 401 errors with Gemini embeddings

Dears, Good Afternoon,
Hope you are doing great !

I am using the AI plugin and currently using gemini model for both generative language and embeddings. However after some changes on google side it seems, there seem to be some errors for Discourse forum to reach gemini API - I am struggling to get my forum reach gemini for embeddings.

Embedding configurations

I used to have the following url in the configuration of the model for embeddings using gemini (but I got errors) :
https://generativelanguage.googleapis.com/v1beta/models/gemini-embedding-001:embedContent

Looking at documentation in internet, I found that the url should be instead following a pattern like:
https://{zone}-aiplatform.googleapis.com/v1/projects/{google cloud project reference}/locations/{zone}/publishers/google/models/gemini-embedding-001:embedContent

How the issue is materializing on my side

  1. I get the following errors:
    Trying to contact the model returned this error: { "error": { "code": 401, "message": "API keys are not supported by this API. Expected OAuth2 access token or other authentication credentials that assert a principal. See https://cloud.google.com/docs/authentication", "status": "UNAUTHENTICATED", "details": \[ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "CREDENTIALS_MISSING", "domain": "googleapis.com", "metadata": { "method": "google.cloud.aiplatform.v1.PredictionService.EmbedContent", "service": "aiplatform.googleapis.com" } } \] } }
  2. Newly created topics do not have embedding I presume and therefore instead of “Related topics” AI powered section after the post, the section is instead " New & Unread Topics" - only for the newly created topics since I get errors.

This suggest that we might need to pass more than just an API key ? I am a bit lost.

Additional information

My questions

  1. Is there anything I am missing ?
  2. Anyone has AI working with gemini models and had to change their configuration using service principals ?
  3. What is the right Embeddings service URL to use for gemini embedding models ?

Thanks a lot for your precious help and advices.
Cheers.

This is Google AI Studio vs Gemini Enterprise Agent Platform (formerly Vertex AI).

For embeddings, we are compatible only with the first one.

We just got a PR to make our LLM inference compatible with the second one, as we were only compatible with the first one for LLMs too.

Thanks a lot for the information, it is clear. I moved to AI Studio API instead for embeddings and indeed everything works now. I’ll go back to Enterprise Agent Platform once the LLM inference will be compatible.

Cheers.